This is a test version of Biostars. For the public version, visit https://www.biostars.org.
List of valid tables for Seq.translate()

Is there a way to get the list of valid values for table argument of the translate() method programatically?

Or, if I want to try all, do I need to provide the list of the valid tables manually?

python seq

Are you referring to BioPython Seq.translate() or Python string.translate()?

1 answer

Take a look at the end of this file, where the codon tables are defined.

EDIT

Looks like you just need to do:

>>> from Bio.Data.CodonTable import generic_by_name

>>> generic_by_name.keys()

dict_keys(['Hexamita Nuclear', 'SGC4', 'Alternative Yeast Nuclear', 'SGC1', 'SGC8', 'Standard', 'SGC9', 'Yeast Mitochondrial', 'Scenedesmus obliquus Mitochondrial', 'Plant Plastid', 'Alternative Flatworm Mitochondrial', 'Ascidian Mitochondrial', 'Vertebrate Mitochondrial', 'SGC0', 'Dasycladacean Nuclear', 'Coelenterate Mitochondrial', 'Invertebrate Mitochondrial', 'Trematode Mitochondrial', 'Bacterial', 'Flatworm Mitochondrial', 'Echinoderm Mitochondrial', 'Mycoplasma', 'Blepharisma Macronuclear', 'SGC2', 'Ciliate Nuclear', 'Thraustochytrium Mitochondrial', 'Mold Mitochondrial', 'Euplotid Nuclear', 'Chlorophycean Mitochondrial', 'Spiroplasma', 'SGC5', 'SGC3', 'Protozoan Mitochondrial'])

If I have time I'll look into adding this as a new function.

that would be great, thanks

I have found that already, but the problem is, that new codes may be added/removed and I want the program to know all codes in the recent version without rewriting the code after each change.

Take a look at my edit. It seems like you can already find this list of codes.

Log in to answer this question.