biopython translate error
1
0
Entering edit mode
9.8 years ago
MAK ▴ 10

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?

biopython genbank codon translation python • 2.4k views
ADD COMMENT
0
Entering edit mode

always show the actual error that you get

ADD REPLY
0
Entering edit mode

this is the error :

codon_table = CodonTable.ambiguous_generic_by_id[table_id]
KeyError: 24
ADD REPLY
4
Entering edit mode
9.8 years ago

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:

ADD COMMENT
2
Entering edit mode

I've submitted a pull request to add this codon table to Biopython, so hopefully it will be in the next release.

ADD REPLY
1
Entering edit mode

Also not that I've updated the Gist to include the actual codon table you can use.

ADD REPLY

Login before adding your answer.

Traffic: 3112 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6