Bio.Data.CodonTable module provides genetic code tables from the NCBI, used for translating nucleotide sequences to proteins.
Overview
Biopython includes all NCBI genetic code tables, supporting both DNA and RNA sequences, with ambiguous and unambiguous variants.CodonTable Class
Base class representing a codon table or genetic code.Attributes
forward_table-dict[str, str]- Maps codons to amino acidsback_table-dict[str, str]- Maps amino acids to codons (for back-translation)start_codons-list[str]- List of valid start codonsstop_codons-list[str]- List of stop codonsnucleotide_alphabet-str | None- Nucleotide alphabet (DNA/RNA)protein_alphabet-str | None- Protein alphabet
Methods
__init__()
__str__()
Returns a formatted text representation of the codon table.
NCBICodonTable Classes
Specialized classes for NCBI genetic code tables.NCBICodonTable
Base class for generic nucleotide sequences (accepts both DNA and RNA). Attributes:id-int- NCBI genetic code IDnames-list[str]- List of names for this table
NCBICodonTableDNA
Codon table for unambiguous DNA sequences. Attributes:nucleotide_alphabet- Set toIUPACData.unambiguous_dna_letters
NCBICodonTableRNA
Codon table for unambiguous RNA sequences. Attributes:nucleotide_alphabet- Set toIUPACData.unambiguous_rna_letters
AmbiguousCodonTable
Codon table supporting ambiguous nucleotide codes.Table Dictionaries
Tables are accessible via dictionaries by ID or name:By ID
unambiguous_dna_by_id- DNA tables (unambiguous)unambiguous_rna_by_id- RNA tables (unambiguous)generic_by_id- Generic nucleotide tables (DNA or RNA)ambiguous_dna_by_id- DNA tables with ambiguity codesambiguous_rna_by_id- RNA tables with ambiguity codesambiguous_generic_by_id- Generic tables with ambiguity codes
By Name
unambiguous_dna_by_name- DNA tables by nameunambiguous_rna_by_name- RNA tables by namegeneric_by_name- Generic tables by nameambiguous_dna_by_name- Ambiguous DNA tables by nameambiguous_rna_by_name- Ambiguous RNA tables by nameambiguous_generic_by_name- Ambiguous generic tables by name
Standard Tables
standard_dna_table- The standard genetic code (ID 1) for DNAstandard_rna_table- The standard genetic code (ID 1) for RNA
Common Genetic Codes
Table 1: Standard
Table 2: Vertebrate Mitochondrial
Table 11: Bacterial, Archaeal and Plant Plastid
Exceptions
TranslationError
- Invalid codon encountered
- Ambiguous codon with no unique translation
Example Usage
See Also
- Bio.Data - Biological data constants
- Bio.Seq - Sequence objects with translation methods
- Bio.SeqUtils - Sequence utilities
