This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How can I calculate the codon adaptation index of my sequences with Biopython?

Hi there,

I need to figure out if my sequences have been codon optimized. I learned about the Biopython CodonUsage module and tried to get it running. When I run my code:

from Bio import SeqIO
from Bio.SeqUtils import CodonUsage
from Bio.SeqUtils.CodonUsage import CodonAdaptationIndex

Sequence = SeqIO.read("my_seq.fasta", format="fasta")

Seq_Cai = CodonUsage.CodonAdaptationIndex()

Seq_Cai.cai_for_gene(Sequence)

print(SeqCai)

I receive an error: "AttributeError: 'SeqRecord' object has no attribute 'islower' ". I looked that error up but cannot find a solution. Please forgive me if that question is stupid, I started coding a few days ago. Your help is very much appreciated!

Thanks, Philipp

codon biopython optimization

2 answers

The input should be a string, not SeqRecord. Make sure you set the index first. http://biopython.org/DIST/docs/api/Bio.SeqUtils.CodonUsage.CodonAdaptationIndex-class.html

Thanks for the hint. I got that script working.

Log in to answer this question.