I've submitted a pull request to add this codon table to Biopython, so hopefully it will be in the next release.
biopython translate error
I want to translate a sequence which I have already parsed the translation table from the genbank file.
My code works on some of the files, but in one file I have tranlation table = 24 and I'm getting the following error:
codon_table = CodonTable.ambiguous_generic_by_id[table_id]
KeyError: 24
The following is my code:
with open(file, 'r') as inF:
for line in inF:
if '/transl_table' in line:
l=line.split('=')
#I extracted already the gene sequence...
protein=gene.translate(table=l[1])
What is the cause of this error and how to solve it?
• 3,218 views
•
link
1 answer
If you look at the code for CodonTable, there are only tables registered with identifiers <23. I think you'll have to either use another equivalent table (if it exists), or you can register a new one like so:
• 0 views
•
link
• 0 views
•
link
Also not that I've updated the Gist to include the actual codon table you can use.
• 0 views
•
link
Log in to answer this question.
always show the actual error that you get
this is the error :