Bio::T...nTable(3pm)
β¨ 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β AlanineR/Argβ ArginineN/Asnβ AsparagineD/Aspβ Aspartic acidC/Cysβ CysteineQ/Glnβ GlutamineE/Gluβ Glutamic acidG/Glyβ GlycineH/Hisβ HistidineI/Ileβ IsoleucineL/Leuβ LeucineK/Lysβ LysineM/Metβ MethionineF/Pheβ PhenylalanineP/Proβ ProlineO/Pylβ Pyrrolysine (the 22nd amino acid π)U/Secβ Selenocysteine (the 21st amino acid π)S/Serβ SerineT/Thrβ ThreonineW/Trpβ TryptophanY/Tyrβ TyrosineV/Valβ ValineB/Asxβ Aspartic acid or AsparagineZ/Glxβ Glutamine or Glutamic acidJ/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 tablename()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
Bfor Aspartic Acid and Asparagine is used. - the IUPAC amino acid code
Zfor 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::PrimarySeqIcompatible object (mandatory, you gotta give her something) - a
Bio::CodonUsage::Tableobject and a threshold β but only if you want codons with a relative frequency above the threshold to be considered.
- a
β 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::PrimarySeqIcompatible object and aBio::CodonUsage::Tableobject
π 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
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms