[Python] How do I properly use codonbias.scores.FrequencyOfOptimalCodons?

Discussão em 'Python' iniciado por Stack, Março 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write a script analyzing codon usage in sequence utilizing the codon-bias package.

    I am trying to use the class codonbias.scores.FrequencyOfOptimalCodons, but when I do so in my code:

    FOC = cb.scores.FrequencyOfOptimalCodons (ref_seq=sequence_list, genetic_code=11)

    where sequence_list is a list of str objects containing ORFs, and the genetic_code is set for Bacterial, archaeal and plant plastid code,

    I get the following from my Shell:

    Traceback (most recent call last):
    File "I:\R&D\Product Research Group\Metabolic&Regulatory modeling\Codon usage\Python scripts\CodonBias CAI analyzer.py", line 117, in <module>
    codon_df, total_orfs, analyzed_orfs = analyze_codon_usage(orfs_file, trna_file)
    File "I:\R&D\Product Research Group\Metabolic&Regulatory modeling\Codon usage\Python scripts\CodonBias CAI analyzer.py", line 71, in analyze_codon_usage
    FOC = cb.scores.FrequencyOfOptimalCodons (ref_seq=sequence_list, genetic_code=11)
    File "C:\Users\shlomog\AppData\Local\Programs\Python\Python312\Lib\site-packages\codonbias\scores.py", line 199, in __init__
    self.weights = self.weights.droplevel('aa')
    File "C:\Users\shlomog\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\generic.py", line 943, in droplevel
    new_labels = labels.droplevel(level)
    File "C:\Users\shlomog\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\indexes\base.py", line 2155, in droplevel
    levnums = sorted(self._get_level_number(lev) for lev in level)[::-1]
    File "C:\Users\shlomog\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\indexes\base.py", line 2155, in <genexpr>
    levnums = sorted(self._get_level_number(lev) for lev in level)[::-1]
    File "C:\Users\shlomog\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\indexes\multi.py", line 1660, in _get_level_number
    raise ValueError(
    ValueError: The name aa occurs multiple times, use a level number


    Any idea what I'm doing wrong? I had the program print out the sequences in sequence_list before the call, and they appear in order.

    Here the offending code in init of FrequencyOfOptimalCodons.

    Continue reading...

Compartilhe esta Página