bpp-seq  2.2.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 (const NucleicAlphabet *alphabet)
 
virtual ~GeneticCode ()
 
virtual GeneticCodeclone () const =0
 
Methods form the Transliterator interface.
const CodonAlphabetgetSourceAlphabet () const
 Get the source alphabet. More...
 
const ProteicAlphabetgetTargetAlphabet () const
 Get the target alphabet. More...
 
virtual int translate (int state) const throw (BadIntException, Exception)
 Translate a given state coded as a int from source alphabet to target alphabet. More...
 
virtual std::string translate (const std::string &state) const throw (BadCharException, Exception)
 Translate a given state coded as a string from source alphabet to target alphabet. More...
 
virtual Sequencetranslate (const Sequence &sequence) const throw (Exception)
 Translate a whole sequence from source alphabet to target alphabet. More...
 
Specific methods.
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 throw (BadIntException)
 Tells is a particular codon is a stop codon. More...
 
virtual bool isStop (const std::string &state) const =0 throw (BadCharException)
 Tells is a particular codon is a stop codon. More...
 
virtual bool isStart (int state) const throw (BadIntException)
 Tells is a particular codon is a start codon. More...
 
virtual bool isStart (const std::string &state) const throw (BadCharException)
 Tells is a particular codon is a start codon. More...
 
virtual bool isAltStart (int state) const =0 throw (BadIntException)
 Tells is a particular codon is an alternative start codon. More...
 
virtual bool isAltStart (const std::string &state) const =0 throw (BadCharException)
 Tells is a particular codon is an alternative start codon. More...
 
bool areSynonymous (int i, int j) const throw (BadIntException)
 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 throw (BadCharException)
 Tell if two codons are synonymous, that is, if they encode the same amino-acid. More...
 
std::vector< int > getSynonymous (int aminoacid) const throw (BadIntException)
 
std::vector< std::string > getSynonymous (const std::string &aminoacid) const throw (BadCharException)
 
bool isFourFoldDegenerated (int codon) const
 
SequencegetCodingSequence (const Sequence &sequence, bool lookForInitCodon=false, bool includeInitCodon=false) const throw (Exception)
 Get the subsequence corresponding to the coding part of a given sequence. More...
 

Protected Attributes

CodonAlphabet codonAlphabet_
 
ProteicAlphabet proteicAlphabet_
 
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 79 of file GeneticCode.h.

Constructor & Destructor Documentation

◆ GeneticCode()

bpp::GeneticCode::GeneticCode ( const NucleicAlphabet alphabet)
inline

Definition at line 89 of file GeneticCode.h.

◆ ~GeneticCode()

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

Definition at line 96 of file GeneticCode.h.

Member Function Documentation

◆ areSynonymous() [1/2]

bool bpp::GeneticCode::areSynonymous ( int  i,
int  j 
) const
throw (BadIntException
)
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.
Exceptions
BadIntExceptionif at least one of the states is not supported by the alphabet.

Definition at line 206 of file GeneticCode.h.

References translate().

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

◆ areSynonymous() [2/2]

bool bpp::GeneticCode::areSynonymous ( const std::string &  i,
const std::string &  j 
) const
throw (BadCharException
)
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.
Exceptions
BadCharExceptionif at least one of the states is not supported by the alphabet.

Definition at line 219 of file GeneticCode.h.

References translate().

◆ clone()

◆ getCodingSequence()

Sequence * GeneticCode::getCodingSequence ( const Sequence sequence,
bool  lookForInitCodon = false,
bool  includeInitCodon = false 
) const
throw (Exception
)

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 begining 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 149 of file GeneticCode.cpp.

References bpp::AbstractAlphabet::intToChar(), bpp::AlphabetTools::isCodonAlphabet(), bpp::AlphabetTools::isNucleicAlphabet(), bpp::SymbolList::size(), and bpp::SequenceTools::subseq().

◆ getNumberOfStopCodons()

◆ getSourceAlphabet()

const CodonAlphabet* bpp::GeneticCode::getSourceAlphabet ( ) const
inlinevirtual

Get the source alphabet.

Returns
The source alphabet.

Implements bpp::Transliterator.

Definition at line 106 of file GeneticCode.h.

References codonAlphabet_.

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

◆ getStopCodonsAsChar()

virtual std::vector<std::string> bpp::GeneticCode::getStopCodonsAsChar ( ) const
pure virtual

◆ getStopCodonsAsInt()

virtual std::vector<int> bpp::GeneticCode::getStopCodonsAsInt ( ) const
pure virtual

◆ getSynonymous() [1/2]

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

Definition at line 77 of file GeneticCode.cpp.

◆ getSynonymous() [2/2]

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

Definition at line 98 of file GeneticCode.cpp.

◆ getTargetAlphabet()

const ProteicAlphabet* bpp::GeneticCode::getTargetAlphabet ( ) const
inlinevirtual

Get the target alphabet.

Returns
The target alphabet.

Implements bpp::Transliterator.

Definition at line 107 of file GeneticCode.h.

References proteicAlphabet_.

◆ isAltStart() [1/2]

virtual bool bpp::GeneticCode::isAltStart ( int  state) const
throw (BadIntException
)
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.
Exceptions
BadIntExceptionif the state is not supported by the alphabet.

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

◆ isAltStart() [2/2]

virtual bool bpp::GeneticCode::isAltStart ( const std::string &  state) const
throw (BadCharException
)
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.
Exceptions
BadCharExceptionif the state is not supported by the alphabet.

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

◆ 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 119 of file GeneticCode.cpp.

References codonAlphabet_, bpp::CodonAlphabet::getCodon(), bpp::WordAlphabet::getPositions(), isStop(), and translate().

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

◆ isStart() [1/2]

virtual bool bpp::GeneticCode::isStart ( int  state) const
throw (BadIntException
)
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.
Exceptions
BadIntExceptionif the state is not supported by the alphabet.

Definition at line 163 of file GeneticCode.h.

References codonAlphabet_, and bpp::AbstractAlphabet::intToChar().

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

◆ isStart() [2/2]

virtual bool bpp::GeneticCode::isStart ( const std::string &  state) const
throw (BadCharException
)
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.
Exceptions
BadCharExceptionif the state is not supported by the alphabet.

Definition at line 176 of file GeneticCode.h.

References bpp::WordAlphabet::charToInt(), codonAlphabet_, and isStart().

◆ isStop() [1/2]

virtual bool bpp::GeneticCode::isStop ( int  state) const
throw (BadIntException
)
pure virtual

Tells is a particular codon is a stop codon.

Parameters
stateThe numeric code for the state to test.
Returns
True if the state corresponds to a stop codon.
Exceptions
BadIntExceptionif the state is not supported by the alphabet.

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

Referenced by bpp::SequenceTools::getCDS(), isFourFoldDegenerated(), and bpp::CodonSiteTools::numberOfSynonymousDifferences().

◆ isStop() [2/2]

virtual bool bpp::GeneticCode::isStop ( const std::string &  state) const
throw (BadCharException
)
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.
Exceptions
BadCharExceptionif the state is not supported by the alphabet.

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

◆ translate() [1/3]

int GeneticCode::translate ( int  state) const
throw (BadIntException,
Exception
)
virtual

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.
Exceptions
BadIntExceptionIf the state is not a proper state for source alphabet.
ExceptionOther kind of error, depending on the implementation.

Implements bpp::AbstractTransliterator.

Definition at line 55 of file GeneticCode.cpp.

Referenced by areSynonymous(), and isFourFoldDegenerated().

◆ translate() [2/3]

std::string GeneticCode::translate ( const std::string &  state) const
throw (BadCharException,
Exception
)
virtual

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.
Exceptions
BadCharExceptionIf the state is not a proper state for source alphabet.
ExceptionOther kind of error, depending on the implementation.

Implements bpp::AbstractTransliterator.

Definition at line 69 of file GeneticCode.cpp.

◆ translate() [3/3]

virtual Sequence* bpp::GeneticCode::translate ( const Sequence sequence) const
throw (Exception
)
inlinevirtual

Translate a whole sequence from source alphabet to target alphabet.

Parameters
sequenceA sequence in source alphabet.
Returns
The corresponding sequence in target alphabet.
Exceptions
AlphabetMismatchExceptionIf the sequence alphabet do not match the source alphabet.
ExceptionOther kind of error, depending on the implementation.

Reimplemented from bpp::AbstractTransliterator.

Definition at line 110 of file GeneticCode.h.

References bpp::AbstractTransliterator::translate().

Member Data Documentation

◆ codonAlphabet_

◆ proteicAlphabet_

◆ tlnTable_


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