Search code examples
python-2.7bioinformaticsbiopython

How to calculate codon usage bias (RSCU) in biopython


I'm looking to calculate the RSCU values for a given sequence using the module CodonUsage. In the source code for CodonUsage (here) RSCU values are calculated inside the function generate_index, which sits inside the class CodonAdaptionIndex (RSCU calculated at line 101). How do I access generate_index? Also, how do i get my script to access my sequences (so far they are in FASTA format on a .txt).

Thanks for reading


Solution

  • You can access the function by importing it like this and generating a CodonAdaptionIndex object:

    from Bio.SeqUtils import CodonUsage as CU
    
    myIndex = CU.CodonAdaptationIndex()
    myIndex.generate_index("/path/to/myFastaFile")
    

    From the documentation it looks like a FASTA formated file is perfectly fine to use.