biotite.sequence.CodonTable

class biotite.sequence.CodonTable(codon_dict, starts)[source]

Bases: object

A CodonTable maps a codon (sequence of 3 nucleotides) to an amino acid. It also defines start codons. A CodonTable takes/outputs either the symbols or code of the codon/amino acid.

Furthermore, this class is able to give a list of codons that corresponds to a given amino acid.

The load() method allows loading of NCBI codon tables.

Objects of this class are immutable.

Parameters:
codon_dict : dict

A dictionary that maps codons to amino acids. The keys must be strings of length 3 and the values strings of length 1 (all upper case). The dictionary must provide entries for all 64 possible codons.

starts : iterable object of str

The start codons. Each entry must be a string of length 3 (all upper case).

Examples

Get the amino acid coded by a given codon (symbol and code):

>>> table = CodonTable.default_table()
>>> print(table["ATG"])
M
>>> print(table[(1,2,3)])
14

Get the codons coding for a given amino acid (symbol and code):

>>> table = CodonTable.default_table()
>>> print(table["M"])
('ATG',)
>>> print(table[14])
((1, 2, 3), (1, 2, 1), (1, 2, 0), (1, 2, 2), (0, 2, 0), (0, 2, 2))
codon_dict(code=False)[source]

Get the codon to amino acid mappings dictionary.

Parameters:
code : bool

If true, the dictionary contains keys and values as code. Otherwise, the dictionary contains strings for codons and amino acid. (Default: False)

Returns:
codon_dict : dict

The dictionary mapping codons to amino acids.

start_codons(code=False)[source]

Get the start codons of the codon table.

Parameters:
code : bool

If true, the code will be returned instead of strings. (Default: False)

Returns:
start_codons : tuple

The start codons. Contains strings or tuples, depending on the code parameter.

static load(table_name)[source]

Load a NCBI codon table.

Parameters:
table_name : str or int

If a string is given, it is interpreted as official NCBI codon table name (e.g. “Vertebrate Mitochondrial”). An integer is interpreted as NCBI codon table ID.

Returns:
table : CodonTable

The NCBI codon table.

static table_names()[source]

The possible codon table names for load().

Returns:
names : list of str

List of valid codon table names.

static default_table()[source]

The default codon table. The table is equal to the NCBI “Standard” codon table, with the difference that only “ATG” is a start codon.

Returns:
table : CodonTable

The default codon table.