Bio::T...nTable(3pm)

πŸ“¦
version 1.7.8 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

✨ Bio::Tools::CodonTable ✨

the cutest little codon table object you ever did meet β€” from the User Contributed Perl Documentation, section 3pm πŸ’…


🌸 NAME 🌸

Bio::Tools::CodonTable β€” a Codon table object 🧬


πŸ¦‹ SYNOPSIS πŸ¦‹

okay bestie, here's the whole vibe in code:

# This is a read-only class for all known codon tables.  The IDs are
# the ones used by nucleotide sequence databases.  All common IUPAC
# ambiguity codes for DNA, RNA and amino acids are recognized.

use Bio::Tools::CodonTable;

# defaults to ID 1 "Standard"
$myCodonTable   = Bio::Tools::CodonTable->new();
$myCodonTable2  = Bio::Tools::CodonTable->new( -id => 3 );

# change codon table
$myCodonTable->id(5);

# examine codon table
print  join (' ', "The name of the codon table no.", $myCodonTable->id(4),
         "is:", $myCodonTable->name(), "\n");

# print possible codon tables
$tables = Bio::Tools::CodonTable->tables;
while ( ($id,$name) = each %{$tables} ) {
  print "$id = $name\n";
}

# translate a codon
$aa = $myCodonTable->translate('ACU');
$aa = $myCodonTable->translate('act');
$aa = $myCodonTable->translate('ytr');

# reverse translate an amino acid
@codons = $myCodonTable->revtranslate('A');
@codons = $myCodonTable->revtranslate('Ser');
@codons = $myCodonTable->revtranslate('Glx');
@codons = $myCodonTable->revtranslate('cYS', 'rna');

# reverse translate an entire amino acid sequence into a IUPAC
# nucleotide string

my $seqobj    = Bio::PrimarySeq->new(-seq => 'FHGERHEL');
my $iupac_str = $myCodonTable->reverse_translate_all($seqobj);

# boolean tests
print "Is a start\n"       if $myCodonTable->is_start_codon('ATG');
print "Is a terminator\n"  if $myCodonTable->is_ter_codon('tar');
print "Is a unknown\n"     if $myCodonTable->is_unknown_codon('JTG');

like. iconic. no notes πŸ’–


πŸ’– DESCRIPTION πŸ’–

so codon tables are also called translation tables or genetic codes, because like… that's literally what they represent bestie 😌. and if you want a way more complete picture of the full complexity of codon usage across all the different taxonomic groups, that's all sitting right there on the NCBI Genetic Codes Home page 🌈

CodonTable is a BioPerl class that knows all the current translation tables used by the primary nucleotide sequence databases β€” that's GenBank, EMBL and DDBJ β€” periodt πŸ’…. It hands you methods to spit out info about tables and about the relationships between codons and amino acids. slay.

this class and its methods recognize all common IUPAC ambiguity codes for DNA, RNA and animo acids (yes, the original says "animo", we keep it, it's part of the lore 🫢). the translation method follows the conventions in EMBL and TREMBL databases.

ngl, separating RNA and cDNA representations of nucleic acid transcripts is SUCH a nuisance 😭. so the CodonTable object just accepts codons of both types as input, and lets you set the mode for output when reverse translating. its default for output is DNA. (iykyk)

Note: πŸ“Œ
This class deals primarily with individual codons and amino acids. However in the interest of speed you can translate longer sequence, too. The full complexity of protein translation is tackled by Bio::PrimarySeqI::translate.

🧚 The amino acid codes

these are the IUPAC recommendations for common amino acids, and they are giving ✨ main character energy ✨:

  • A / Ala β€” Alanine
  • R / Arg β€” Arginine
  • N / Asn β€” Asparagine
  • D / Asp β€” Aspartic acid
  • C / Cys β€” Cysteine
  • Q / Gln β€” Glutamine
  • E / Glu β€” Glutamic acid
  • G / Gly β€” Glycine
  • H / His β€” Histidine
  • I / Ile β€” Isoleucine
  • L / Leu β€” Leucine
  • K / Lys β€” Lysine
  • M / Met β€” Methionine
  • F / Phe β€” Phenylalanine
  • P / Pro β€” Proline
  • O / Pyl β€” Pyrrolysine (the 22nd amino acid πŸ‘‘)
  • U / Sec β€” Selenocysteine (the 21st amino acid πŸ‘‘)
  • S / Ser β€” Serine
  • T / Thr β€” Threonine
  • W / Trp β€” Tryptophan
  • Y / Tyr β€” Tyrosine
  • V / Val β€” Valine
  • B / Asx β€” Aspartic acid or Asparagine
  • Z / Glx β€” Glutamine or Glutamic acid
  • J / Xle β€” Isoleucine or Valine (mass spec ambiguity πŸ”¬)
  • X / Xaa β€” Any or unknown amino acid

πŸŽ€ the codon table 11 lore

okay this is worth noting bestie, because it's confusing: the "Bacterial" codon table no. 11 produces a polypeptide that is, confusingly, identical to the standard one. the only differences are in available initiator codons. that's it. that's the tea β˜•

NCBI Genetic Codes home page:

(Last update of the Genetic Codes: Nov. 18, 2016)
https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi?mode=c

ASN.1 version with ids 1 to 25 is at:

ftp://ftp.ncbi.nih.gov/entrez/misc/data/gc.prt

and a huge thank you to Matteo diTomasso for the original Perl implementation of these tables πŸ«ΆπŸ’


πŸ“£ FEEDBACK πŸ“£

πŸ’Œ Mailing Lists

user feedback is an integral part of the evolution of this and other Bioperl modules. send your comments and suggestions preferably to the Bioperl mailing lists β€” your participation is much appreciated πŸ₯ΉπŸ’–

bioperl-l@bioperl.org                  - General discussion
http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

πŸ›Ÿ Support

please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. many experienced and reponsive experts will be able look at the problem and quickly address it (yes, "reponsive" β€” we don't fix typos in this house, we preserve them πŸ’€). please include a thorough description of the problem with code and data examples if at all possible πŸ™

πŸ› Reporting Bugs

report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. bug reports can be submitted via the web:

https://github.com/bioperl/bioperl-live/issues

✍️ AUTHOR - Heikki Lehvaslaiho

Email: heikki-at-bioperl-dot-org πŸ’Œ


okay bestie that's part 1 of 2 β€” do NOT go anywhere, the rest is right there πŸ‘€πŸ’…

🌈 APPENDIX 🌈

okay so this is the part where we go method by method, bestie. every single one, no skipping πŸ’… and heads up: internal methods usually start with an _ β€” that underscore is the universal "this is private, don't @ me" signal ✨


πŸŽ€ id

  • Title: id
  • Usage: $obj->id(3); $id_integer = $obj->id();
  • Function: sets or returns the id of the translation table. IDs are integers from 0 (the special ATG-only start, iconic) all the way up to 25, except 7-8 and 17-20 which got removed, rip. If you hand it an invalid ID, it just returns 1 β€” the standard table. it's giving "we don't know her, here's the default."
  • Example: (none given, she left it blank πŸ™ˆ)
  • Returns: the value of id, a scalar. and if the id you specified isn't valid? it warns and falls back to 1, the standard table. no cap.
  • Args: newvalue (optional)

πŸ¦‹ name

  • Title: name
  • Usage: $obj->name()
  • Function: returns the descriptive name of the translation table
  • Example: (blank, we move)
  • Returns: a string
  • Args: none

🌸 tables

  • Title: tables
  • Usage: $obj->tables() or Bio::Tools::CodonTable->tables()
  • Function: returns a hash reference where every key is a valid codon table id() number, and every value is the matching codon table name() string. it's a lil lookup map, she's organized πŸ’–
  • Example: (not here, but you got the vibe)
  • Returns: a hashref
  • Args: none

πŸ‘‘ translate

  • Title: translate
  • Usage: $obj->translate('YTR')
  • Function: returns a string of one letter amino acid codes from nucleotide sequence input. the input can be any length. periodt.

returns 'X' for unknown codons and for codons that code for more than one amino acid. returns an empty string if the input isn't three characters long. but wait β€” there are exceptions, and they're lowkey important:

  • the IUPAC amino acid code B for Aspartic Acid and Asparagine is used.
  • the IUPAC amino acid code Z for Glutamic Acid and Glutamine is used.
  • if the codon is two nucleotides long and adding a third character 'N' makes it code for a single amino acid (with the exceptions above), it returns that. otherwise, empty string, sorry bestie 🫢

for other input strings that aren't three characters long, you get an empty string too.

  • Example: (she didn't write one 😭)
  • Returns: a string of one letter ambiguous IUPAC amino acid codes
  • Args: ambiguous IUPAC nucleotide string

πŸ”₯ translate_strict

  • Title: translate_strict
  • Usage: $obj->translate_strict('ACT')
  • Function: returns one letter amino acid code for a codon input.

this one is fast and simple β€” the bare minimum, the low-effort queen. you are responsible for resolving ambiguous nucleotide codes before you call this method. returns 'X' for unknown codons, and an empty string for input strings that aren't three characters long.

bestie, it is not recommended to use this method in a production environment. use method translate instead. fr fr. don't be chaotic.
  • Example: (empty, as per usual)
  • Returns: a string
  • Args: a codon = a three nucleotide character string

πŸ’œ revtranslate

  • Title: revtranslate
  • Usage: $obj->revtranslate('G')
  • Function: returns codons for an amino acid.

returns an empty string for unknown amino acid codes. the ambiguous IUPAC codes Asx, B (Asp, D; Asn, N) and Glx, Z (Glu, E; Gln, Q) get resolved. both single and three letter amino acid codes are accepted, so she's flexible πŸ’… '*' and 'Ter' are used for terminator.

by default the output codons show up in DNA. if you need the output in RNA (tr/t/u/), just add a second argument 'RNA'. iykyk.

  • Example: $obj->revtranslate('Gly', 'RNA')
  • Returns: an array of three lower case letter strings, i.e. codons
  • Args: amino acid, 'RNA'

🧚 reverse_translate_all

  • Title: reverse_translate_all
  • Usage:
my $iup_str = $cttable->reverse_translate_all($seq_object)
my $iup_str = $cttable->reverse_translate_all($seq_object,
                                              $cutable,
                                              15);
  • Function: reverse translates a protein sequence into IUPAC nucleotide sequence. an 'X' in the protein sequence becomes 'NNN' in the nucleotide sequence. no cap.
  • Returns: a string
  • Args:
    • a Bio::PrimarySeqI compatible object (mandatory, you gotta give her something)
    • a Bio::CodonUsage::Table object and a threshold β€” but only if you want codons with a relative frequency above the threshold to be considered.

⭐ reverse_translate_best

  • Title: reverse_translate_best
  • Usage: my $str = $cttable->reverse_translate_best($seq_object,$cutable);
  • Function: reverse translates a protein sequence into plain nucleotide sequence (GATC), and it uses the most common codon for each amino acid. she picks the popular one, main character energy πŸ‘‘
  • Returns: a string
  • Args: a Bio::PrimarySeqI compatible object and a Bio::CodonUsage::Table object

πŸ’– is_start_codon

  • Title: is_start_codon
  • Usage: $obj->is_start_codon('ATG')
  • Function: returns true (1) for all codons that can be used as a translation start, false (0) for the others.
  • Example: $myCodonTable->is_start_codon('ATG')
  • Returns: boolean
  • Args: codon

πŸ“ is_ter_codon

  • Title: is_ter_codon
  • Usage: $obj->is_ter_codon('GAA')
  • Function: returns true (1) for all codons that can be used as a translation terminator, false (0) for the others. (yes, the original spells it "tarminator" β€” we love her, typos and all 🫢)
  • Example: $myCodonTable->is_ter_codon('ATG')
  • Returns: boolean
  • Args: codon

πŸ¦„ is_unknown_codon

  • Title: is_unknown_codon
  • Usage: $obj->is_unknown_codon('GAJ')
  • Function: returns false (0) for all codons that are valid, true (1) for the others.
  • Example: $myCodonTable->is_unknown_codon('NTG')
  • Returns: boolean
  • Args: codon

🌈 unambiguous_codons

  • Title: unambiguous_codons
  • Usage: @codons = $self->unambiguous_codons('ACN')
  • Returns: array of strings (one-letter unambiguous amino acid codes)
  • Args: a codon = a three IUPAC nucleotide character string

πŸ’€ _unambiquous_codons

deprecated β€” now just an alias for unambiguous_codons. she's retired but still shows up to the party. (and yes, that spelling with the missing i is exactly how it's written, do not "fix" it, the underscore in front means internal anyway)


πŸŽ€ add_table

  • Title: add_table
  • Usage: $newid = $ct->add_table($name, $table, $starts)
  • Function: add a custom Codon Table into the object.
okay so listen: know what you are doing. only the length of the argument strings is checked. that's it. she is not your babysitter, she's not validating your biology, she's just counting characters πŸ’€
  • Returns: the id of the new codon table
  • Args:
    • name, a string, optional (can be empty)
    • table, a string of 64 characters
    • startcodons, a string of 64 characters, defaults to standard

and that's a wrap on the whole page, bestie 🫢 this was Bio::T...nTable(3pm) from perl v5.32.1, dated 2021-08-15 β€” go forth and translate responsibly, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from