codeine.TranslationTable

class codeine.TranslationTable(table_id: int = 1, rna: bool = False)[source]

Bases: object

Translation table. Here we use the NCBI translation table IDs (see https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi) Uses DNA by default, but can switch to RNA by setting rna=True.

Parameters:
  • table_id – Which translation table to use. Default is 1, which is the standard genetic code.

  • rna – Whether to use RNA. Default is no (False), i.e. use DNA.

Methods

custom(codons_to_aa[, name, rna])

Create a custom translation table.

normalise_sequence(seq)

Format a sequence in the format specified by this codon table, i.e. convert to RNA/DNA and cast to upper case.

translate(seq)

Translate a DNA/RNA coding sequence into its amino-acid sequence.

classmethod TranslationTable.custom(codons_to_aa: Dict[str, str], name: str = 'Custom', rna: bool = False) TranslationTable[source]

Create a custom translation table.

This is useful for synthetic, partial, experimental, or externally defined translation tables, or for tables that have been discovered but not yet added to Codeine. Codons are normalised to DNA or RNA according to the rna argument.

Parameters:
  • codons_to_aa – Mapping from codons to amino-acid symbols.

  • name – Name of the custom translation table. Default is 'Custom'.

  • rna – Whether the table should use RNA codons.

Returns:

A custom translation table.

Return type:

TranslationTable

TranslationTable.normalise_sequence(seq: str) str[source]

Format a sequence in the format specified by this codon table, i.e. convert to RNA/DNA and cast to upper case.

Parameters:

codon – The inputted codon.

Return type:

The normalised codon.

TranslationTable.translate(seq: str) str[source]

Translate a DNA/RNA coding sequence into its amino-acid sequence.