bpp-seq3  3.0.0
bpp::GeneticCode Class Referenceabstract

Partial implementation of the Transliterator interface for genetic code object. More...

#include <Bpp/Seq/GeneticCode/GeneticCode.h>

+ Inheritance diagram for bpp::GeneticCode:
+ Collaboration diagram for bpp::GeneticCode:

Public Member Functions

 GeneticCode (std::shared_ptr< const NucleicAlphabet > alphabet)
 
virtual ~GeneticCode ()
 
virtual GeneticCodeclone () const override=0
 
Methods form the Transliterator interface.
std::shared_ptr< const AlphabetgetSourceAlphabet () const override
 Get the source alphabet. More...
 
const AlphabetsourceAlphabet () const override
 Get the source alphabet. More...
 
std::shared_ptr< const AlphabetgetTargetAlphabet () const override
 Get the target alphabet. More...
 
const AlphabettargetAlphabet () const override
 Get the target alphabet. More...
 
int translate (int state) const override
 Translate a given state coded as a int from source alphabet to target alphabet. More...
 
std::string translate (const std::string &state) const override
 Translate a given state coded as a string from source alphabet to target alphabet. More...
 
std::unique_ptr< Sequencetranslate (const SequenceInterface &sequence) const override
 Translate a whole sequence from source alphabet to target alphabet. More...
 
Specific methods.
virtual std::shared_ptr< const CodonAlphabetgetCodonAlphabet () const
 Alias for getSourceAlphabet return a pointer toward a CodonAlphabet. More...
 
virtual const CodonAlphabetcodonAlphabet () const
 Alias for getSourceAlphabet return a pointer toward a CodonAlphabet. More...
 
virtual std::shared_ptr< const ProteicAlphabetgetProteicAlphabet () const
 Alias for getTargetAlphabet return a pointer toward a ProteicAlphabet. More...
 
virtual const ProteicAlphabetproteicAlphabet () const
 Alias for getTargetAlphabet return a pointer toward a ProteicAlphabet. More...
 
virtual size_t getNumberOfStopCodons () const =0
 
virtual std::vector< int > getStopCodonsAsInt () const =0
 
virtual std::vector< std::string > getStopCodonsAsChar () const =0
 
virtual bool isStop (int state) const =0
 Tells is a particular codon is a stop codon. More...
 
virtual bool isStop (const std::string &state) const =0
 Tells is a particular codon is a stop codon. More...
 
virtual bool isStart (int state) const
 Tells is a particular codon is a start codon. More...
 
virtual bool isStart (const std::string &state) const
 Tells is a particular codon is a start codon. More...
 
virtual bool isAltStart (int state) const =0
 Tells is a particular codon is an alternative start codon. More...
 
virtual bool isAltStart (const std::string &state) const =0
 Tells is a particular codon is an alternative start codon. More...
 
bool areSynonymous (int i, int j) const
 Tell if two codons are synonymous, that is, if they encode the same amino-acid. More...
 
bool areSynonymous (const std::string &i, const std::string &j) const
 Tell if two codons are synonymous, that is, if they encode the same amino-acid. More...
 
std::vector< int > getSynonymous (int aminoacid) const
 
std::vector< std::string > getSynonymous (const std::string &aminoacid) const
 
bool isFourFoldDegenerated (int codon) const
 
std::unique_ptr< SequencegetCodingSequence (const SequenceInterface &sequence, bool lookForInitCodon=false, bool includeInitCodon=false) const
 Get the subsequence corresponding to the coding part of a given sequence. More...
 

Protected Attributes

std::shared_ptr< const CodonAlphabetcodonAlphabet_
 
std::shared_ptr< const ProteicAlphabetproteicAlphabet_
 
std::map< int, int > tlnTable_
 

Detailed Description

Partial implementation of the Transliterator interface for genetic code object.

A genetic code object if a translator from a codon alphabet to a proteic alphabet. Depending on the codon alphabet used, several genetic code can be implemented.

See also
CodonAlphabet, ProteicAlphabet

Definition at line 47 of file GeneticCode.h.

Constructor & Destructor Documentation

◆ GeneticCode()

bpp::GeneticCode::GeneticCode ( std::shared_ptr< const NucleicAlphabet alphabet)
inline

Definition at line 57 of file GeneticCode.h.

◆ ~GeneticCode()

virtual bpp::GeneticCode::~GeneticCode ( )
inlinevirtual

Definition at line 64 of file GeneticCode.h.

Member Function Documentation

◆ areSynonymous() [1/2]

bool bpp::GeneticCode::areSynonymous ( const std::string &  i,
const std::string &  j 
) const
inline

Tell if two codons are synonymous, that is, if they encode the same amino-acid.

Parameters
iThe character code for the first codon.
jThe character code for the second codon.
Returns
True if the two codons are synonymous.

Definition at line 217 of file GeneticCode.h.

References translate().

◆ areSynonymous() [2/2]

bool bpp::GeneticCode::areSynonymous ( int  i,
int  j 
) const
inline

Tell if two codons are synonymous, that is, if they encode the same amino-acid.

Parameters
iThe numeric code for the first codon.
jThe numeric code for the second codon.
Returns
True if the two codons are synonymous.

Definition at line 205 of file GeneticCode.h.

References translate().

Referenced by bpp::CodonSiteTools::numberOfSynonymousDifferences().

◆ clone()

◆ codonAlphabet()

virtual const CodonAlphabet& bpp::GeneticCode::codonAlphabet ( ) const
inlinevirtual

Alias for getSourceAlphabet return a pointer toward a CodonAlphabet.

Returns
A reference toward the codon alphabet.

Definition at line 111 of file GeneticCode.h.

References codonAlphabet_.

◆ getCodingSequence()

unique_ptr< Sequence > GeneticCode::getCodingSequence ( const SequenceInterface sequence,
bool  lookForInitCodon = false,
bool  includeInitCodon = false 
) const

Get the subsequence corresponding to the coding part of a given sequence.

If lookForInitCodon if set to 'true', the subsequence will start at the first AUG motif, otherwise the subsequence will start at the beginning of the sequence. The subsequence ends at the first stop codon (excluded) found, or the end of the sequence.

The sequence may have a nucleotide or codon alphabet. The subsequence has the same alphabet, name and comments of the input sequence. In case of nucleotide sequence and if the lookForInitCodon option is checked, the phase will be determined from the sequence.

Parameters
sequenceThe sequence to parse.
lookForInitCodonTell if the AUG codon must be found.
includeInitCodon(if lookForInitCodon is true) tell if the init codon must be included in the subsequence.
Returns
A nucleotide/codon subsequence.

Definition at line 114 of file GeneticCode.cpp.

References bpp::CruxSymbolListInterface::alphabet(), codonAlphabet_, bpp::AlphabetTools::isCodonAlphabet(), bpp::AlphabetTools::isNucleicAlphabet(), isStop(), and bpp::CruxSymbolListInterface::size().

◆ getCodonAlphabet()

virtual std::shared_ptr<const CodonAlphabet> bpp::GeneticCode::getCodonAlphabet ( ) const
inlinevirtual

◆ getNumberOfStopCodons()

◆ getProteicAlphabet()

virtual std::shared_ptr<const ProteicAlphabet> bpp::GeneticCode::getProteicAlphabet ( ) const
inlinevirtual

Alias for getTargetAlphabet return a pointer toward a ProteicAlphabet.

Returns
A pointer toward the protein alphabet.

Definition at line 118 of file GeneticCode.h.

References proteicAlphabet_.

◆ getSourceAlphabet()

std::shared_ptr<const Alphabet> bpp::GeneticCode::getSourceAlphabet ( ) const
inlineoverridevirtual

Get the source alphabet.

Returns
A pointer toward the source alphabet.

Implements bpp::TransliteratorInterface.

Definition at line 74 of file GeneticCode.h.

References codonAlphabet_.

Referenced by bpp::CodonSiteTools::isSynonymousPolymorphic().

◆ getStopCodonsAsChar()

◆ getStopCodonsAsInt()

◆ getSynonymous() [1/2]

std::vector< std::string > GeneticCode::getSynonymous ( const std::string &  aminoacid) const

Definition at line 63 of file GeneticCode.cpp.

References codonAlphabet_, proteicAlphabet_, and translate().

◆ getSynonymous() [2/2]

vector< int > GeneticCode::getSynonymous ( int  aminoacid) const

Definition at line 42 of file GeneticCode.cpp.

References codonAlphabet_, proteicAlphabet_, and translate().

◆ getTargetAlphabet()

std::shared_ptr<const Alphabet> bpp::GeneticCode::getTargetAlphabet ( ) const
inlineoverridevirtual

Get the target alphabet.

Returns
A pointer toward the target alphabet.

Implements bpp::TransliteratorInterface.

Definition at line 78 of file GeneticCode.h.

References proteicAlphabet_.

◆ isAltStart() [1/2]

virtual bool bpp::GeneticCode::isAltStart ( const std::string &  state) const
pure virtual

Tells is a particular codon is an alternative start codon.

Parameters
stateThe character code for the state to test.
Returns
True if the state corresponds to an alternative start codon.

Implemented in bpp::YeastMitochondrialGeneticCode, bpp::VertebrateMitochondrialGeneticCode, bpp::StandardGeneticCode, bpp::MoldMitochondrialGeneticCode, bpp::InvertebrateMitochondrialGeneticCode, bpp::EchinodermMitochondrialGeneticCode, bpp::CiliateNuclearGeneticCode, and bpp::AscidianMitochondrialGeneticCode.

◆ isAltStart() [2/2]

virtual bool bpp::GeneticCode::isAltStart ( int  state) const
pure virtual

Tells is a particular codon is an alternative start codon.

Parameters
stateThe numeric code for the state to test.
Returns
True if the state corresponds to an alternative start codon.

Implemented in bpp::YeastMitochondrialGeneticCode, bpp::VertebrateMitochondrialGeneticCode, bpp::StandardGeneticCode, bpp::MoldMitochondrialGeneticCode, bpp::InvertebrateMitochondrialGeneticCode, bpp::EchinodermMitochondrialGeneticCode, bpp::CiliateNuclearGeneticCode, and bpp::AscidianMitochondrialGeneticCode.

◆ isFourFoldDegenerated()

bool GeneticCode::isFourFoldDegenerated ( int  codon) const
Returns
True if the specified codon is fourfold degenerated (that is, if a mutation in the fourth position does not change the aminoacid).
Author
Benoit Nabholz, Annabelle Haudry
Parameters
codonThe codon to test.

Definition at line 84 of file GeneticCode.cpp.

References codonAlphabet_, isStop(), and translate().

Referenced by bpp::CodonSiteTools::isFourFoldDegenerated().

◆ isStart() [1/2]

virtual bool bpp::GeneticCode::isStart ( const std::string &  state) const
inlinevirtual

Tells is a particular codon is a start codon.

Parameters
stateThe character code for the state to test.
Returns
True if the state corresponds to a start codon.

Definition at line 177 of file GeneticCode.h.

References codonAlphabet_, and isStart().

◆ isStart() [2/2]

virtual bool bpp::GeneticCode::isStart ( int  state) const
inlinevirtual

Tells is a particular codon is a start codon.

Parameters
stateThe numeric code for the state to test.
Returns
True if the state corresponds to a start codon.

Definition at line 164 of file GeneticCode.h.

References codonAlphabet_.

Referenced by bpp::SequenceTools::getCDS(), and isStart().

◆ isStop() [1/2]

virtual bool bpp::GeneticCode::isStop ( const std::string &  state) const
pure virtual

Tells is a particular codon is a stop codon.

Parameters
stateThe character code for the state to test.
Returns
True if the state corresponds to a stop codon.

Implemented in bpp::YeastMitochondrialGeneticCode, bpp::VertebrateMitochondrialGeneticCode, bpp::StandardGeneticCode, bpp::MoldMitochondrialGeneticCode, bpp::InvertebrateMitochondrialGeneticCode, bpp::EchinodermMitochondrialGeneticCode, bpp::CiliateNuclearGeneticCode, and bpp::AscidianMitochondrialGeneticCode.

◆ isStop() [2/2]

◆ proteicAlphabet()

virtual const ProteicAlphabet& bpp::GeneticCode::proteicAlphabet ( ) const
inlinevirtual

Alias for getTargetAlphabet return a pointer toward a ProteicAlphabet.

Returns
A reference toward the protein alphabet.

Definition at line 125 of file GeneticCode.h.

References proteicAlphabet_.

◆ sourceAlphabet()

const Alphabet& bpp::GeneticCode::sourceAlphabet ( ) const
inlineoverridevirtual

◆ targetAlphabet()

const Alphabet& bpp::GeneticCode::targetAlphabet ( ) const
inlineoverridevirtual

Get the target alphabet.

Returns
A reference toward the target alphabet.

Implements bpp::TransliteratorInterface.

Definition at line 80 of file GeneticCode.h.

References proteicAlphabet_.

◆ translate() [1/3]

std::unique_ptr<Sequence> bpp::GeneticCode::translate ( const SequenceInterface sequence) const
inlineoverridevirtual

Translate a whole sequence from source alphabet to target alphabet.

Parameters
sequenceA sequence in source alphabet.
Returns
The corresponding sequence in target alphabet.

Implements bpp::TransliteratorInterface.

Definition at line 86 of file GeneticCode.h.

References bpp::AbstractTransliterator::translate().

◆ translate() [2/3]

std::string GeneticCode::translate ( const std::string &  state) const
overridevirtual

Translate a given state coded as a string from source alphabet to target alphabet.

Parameters
stateA state in source alphabet.
Returns
The corresponding state in target alphabet.

Implements bpp::AbstractTransliterator.

Definition at line 34 of file GeneticCode.cpp.

References codonAlphabet_, proteicAlphabet_, and translate().

◆ translate() [3/3]

int GeneticCode::translate ( int  state) const
overridevirtual

Translate a given state coded as a int from source alphabet to target alphabet.

Parameters
stateA state in source alphabet.
Returns
The corresponding state in target alphabet.

Implements bpp::AbstractTransliterator.

Definition at line 20 of file GeneticCode.cpp.

References codonAlphabet_, isStop(), and tlnTable_.

Referenced by areSynonymous(), getSynonymous(), isFourFoldDegenerated(), bpp::CodonSiteTools::isSynonymousPolymorphic(), bpp::CodonSiteTools::numberOfSynonymousPositions(), and translate().

Member Data Documentation

◆ codonAlphabet_

◆ proteicAlphabet_

std::shared_ptr<const ProteicAlphabet> bpp::GeneticCode::proteicAlphabet_
protected

◆ tlnTable_

std::map<int, int> bpp::GeneticCode::tlnTable_
protected

Definition at line 54 of file GeneticCode.h.

Referenced by translate().


The documentation for this class was generated from the following files: