bpp-seq  2.2.0
bpp::CodonAlphabet Class Reference

Codon alphabet class. More...

#include <Bpp/Seq/Alphabet/CodonAlphabet.h>

+ Inheritance diagram for bpp::CodonAlphabet:
+ Collaboration diagram for bpp::CodonAlphabet:

Public Member Functions

 CodonAlphabet (const NucleicAlphabet *alpha)
 Builds a new codon alphabet from a nucleic alphabet. More...
 
 CodonAlphabet (const CodonAlphabet &bia)
 
CodonAlphabetoperator= (const CodonAlphabet &bia)
 
CodonAlphabetclone () const
 
virtual ~CodonAlphabet ()
 
std::string getAlphabetType () const
 Identification method. More...
 
bool hasUniqueAlphabet () const
 Returns True if the Alphabet of the letters in the word are the same type. More...
 
unsigned int getLength () const
 Returns the length of the word. More...
 
unsigned int getNumberOfTypes () const
 Returns the number of resolved states + one for unresolved. More...
 
int getUnknownCharacterCode () const
 
bool isUnresolved (int state) const
 
bool isUnresolved (const std::string &state) const
 
std::vector< int > getAlias (int state) const throw (BadIntException)
 Get all resolved states that match a generic state. More...
 
std::vector< std::string > getAlias (const std::string &state) const throw (BadCharException)
 Get all resolved states that match a generic state. More...
 
int getGeneric (const std::vector< int > &states) const throw (BadIntException)
 Get the generic state that match a set of states. More...
 
std::string getGeneric (const std::vector< std::string > &states) const throw (BadCharException)
 Get the generic state that match a set of states. More...
 
Codon specific methods
virtual int getCodon (int pos1, int pos2, int pos3) const throw (BadIntException)
 Get the int code for a codon given the int code of the three underlying positions. More...
 
virtual std::string getCodon (const std::string &pos1, const std::string &pos2, const std::string &pos3) const throw (BadCharException)
 Get the char code for a codon given the char code of the three underlying positions. More...
 
virtual int getFirstPosition (int codon) const throw (BadIntException)
 Get the int code of the first position of a codon given its int description. More...
 
virtual int getSecondPosition (int codon) const throw (BadIntException)
 Get the int code of the second position of a codon given its int description. More...
 
virtual int getThirdPosition (int codon) const throw (BadIntException)
 Get the int code of the third position of a codon given its int description. More...
 
virtual std::string getFirstPosition (const std::string &codon) const throw (BadCharException)
 Get the char code of the first position of a codon given its char description. More...
 
virtual std::string getSecondPosition (const std::string &codon) const throw (BadCharException)
 Get the char code of the second position of a codon given its char description. More...
 
virtual std::string getThirdPosition (const std::string &codon) const throw (BadCharException)
 Get the char code of the third position of a codon given its char description. More...
 
virtual const NucleicAlphabet *const getNucleicAlphabet () const
 
Methods redefined from Alphabet
std::string getName (const std::string &state) const throw (BadCharException)
 Get the complete name of a state given its string description. More...
 
int charToInt (const std::string &state) const throw (BadCharException)
 Give the int description of a state given its string description. More...
 
unsigned int getSize () const
 Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you'll need in most cases. More...
 
Implement these methods from the Alphabet interface.
std::string getName (int state) const throw (BadIntException)
 Get the complete name of a state given its int description. More...
 
size_t getNumberOfStates () const
 This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int. More...
 
unsigned int getNumberOfChars () const
 Get the number of supported characters in this alphabet, including generic characters (e.g. return 20 for DNA alphabet). More...
 
std::string intToChar (int state) const throw (BadIntException)
 Give the string description of a state given its int description. More...
 
bool isIntInAlphabet (int state) const
 Tell if a state (specified by its int description) is allowed by the the alphabet. More...
 
bool isCharInAlphabet (const std::string &state) const
 Tell if a state (specified by its string description) is allowed by the the alphabet. More...
 
const std::vector< int > & getSupportedInts () const
 
const std::vector< std::string > & getSupportedChars () const
 
int getGapCharacterCode () const
 
bool isGap (int state) const
 
bool isGap (const std::string &state) const
 
Word specific methods
const AlphabetgetNAlphabet (size_t n) const
 Get the pointer to the Alphabet of the n-position. More...
 
virtual int getWord (const std::vector< int > &vint, size_t pos=0) const throw (IndexOutOfBoundsException)
 Get the int code for a word given the int code of the underlying positions. More...
 
virtual std::string getWord (const std::vector< std::string > &vpos, size_t pos=0) const throw (IndexOutOfBoundsException, BadCharException)
 Get the char code for a word given the char code of the underlying positions. More...
 
int getNPosition (int word, size_t n) const throw (BadIntException)
 Get the int code of the n-position of a word given its int description. More...
 
std::string getNPosition (const std::string &word, size_t n) const throw (BadCharException)
 Get the char code of the n-position of a word given its char description. More...
 
std::vector< int > getPositions (int word) const throw (BadIntException)
 Get the int codes of each position of a word given its int description. More...
 
std::vector< std::string > getPositions (const std::string &word) const throw (BadCharException)
 Get the char codes of each position of a word given its char description. More...
 
Sequencetranslate (const Sequence &sequence, size_t=0) const throw (AlphabetMismatchException, Exception)
 Translate a whole sequence from letters alphabet to words alphabet. More...
 
Sequencereverse (const Sequence &sequence) const throw (AlphabetMismatchException, Exception)
 Translate a whole sequence from words alphabet to letters alphabet. More...
 
Overloaded AbstractAlphabet methods.
unsigned int getStateCodingSize () const
 Get the size of the string coding a state. More...
 
Specific methods to access AlphabetState
virtual AlphabetStategetStateAt (size_t stateIndex) throw (IndexOutOfBoundsException)
 Get a state at a position in the alphabet_ vector. More...
 
virtual const AlphabetStategetStateAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 Get a state at a position in the alphabet_ vector. More...
 
const AlphabetStategetState (const std::string &letter) const throw (BadCharException)
 Get a state by its letter. More...
 
AlphabetStategetState (const std::string &letter) throw (BadCharException)
 
const AlphabetStategetState (int num) const throw (BadIntException)
 Get a state by its num. More...
 
AlphabetStategetState (int num) throw (BadIntException)
 
int getIntCodeAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 
const std::string & getCharCodeAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 
size_t getStateIndex (int state) const throw (BadIntException)
 
size_t getStateIndex (const std::string &state) const throw (BadCharException)
 

Protected Member Functions

virtual void registerState (AlphabetState *st) throw (Exception)
 Add a state to the Alphabet. More...
 
virtual void setState (size_t pos, AlphabetState *st) throw (Exception, IndexOutOfBoundsException)
 Set a state in the Alphabet. More...
 
void resize (size_t size)
 Resize the private alphabet_ vector. More...
 
void remap ()
 Re-update the maps using the alphabet_ vector content. More...
 
bool equals (const Alphabet &alphabet) const
 Comparison of alphabets. More...
 

Protected Attributes

std::vector< const Alphabet *> vAbsAlph_
 
Available codes

These vectors will be computed the first time you call the getAvailableInts or getAvailableChars method.

std::vector< std::string > charList_
 
std::vector< int > intList_
 

Detailed Description

Codon alphabet class.

Author
Laurent Guéguen, Julien Dutheil

A codon alphabet object is a particular case of WordAlphabet with three letters. Since codons are made of 3 nucleic bases (RNA or DNA), this class has a NucleicAlphabet field used to check char description. This nucleic alphabet is passed to the constructor. This class also adds some methods specific to codon manipulation.

Definition at line 63 of file CodonAlphabet.h.

Constructor & Destructor Documentation

◆ CodonAlphabet() [1/2]

bpp::CodonAlphabet::CodonAlphabet ( const NucleicAlphabet alpha)
inline

Builds a new codon alphabet from a nucleic alphabet.

Parameters
alphaThe nucleic alphabet to be used.

Definition at line 73 of file CodonAlphabet.h.

Referenced by clone().

◆ CodonAlphabet() [2/2]

bpp::CodonAlphabet::CodonAlphabet ( const CodonAlphabet bia)
inline

Definition at line 76 of file CodonAlphabet.h.

◆ ~CodonAlphabet()

virtual bpp::CodonAlphabet::~CodonAlphabet ( )
inlinevirtual

Definition at line 89 of file CodonAlphabet.h.

Member Function Documentation

◆ charToInt()

◆ clone()

CodonAlphabet* bpp::CodonAlphabet::clone ( ) const
inlinevirtual

Implements bpp::AbstractAlphabet.

Definition at line 84 of file CodonAlphabet.h.

References CodonAlphabet().

◆ equals()

bool bpp::AbstractAlphabet::equals ( const Alphabet alphabet) const
inlineprotectedvirtualinherited

Comparison of alphabets.

Returns
true If the two instances are of the same class.

Implements bpp::Alphabet.

Definition at line 268 of file AbstractAlphabet.h.

References bpp::Alphabet::getAlphabetType().

◆ getAlias() [1/2]

std::vector< int > WordAlphabet::getAlias ( int  state) const
throw (BadIntException
)
virtualinherited

Get all resolved states that match a generic state.

If the given state is not a generic code then the output vector will contain this unique code.

Parameters
stateThe alias to resolve.
Returns
A vector of resolved states.
Exceptions
BadIntExceptionWhen state is not a valid integer.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 206 of file WordAlphabet.cpp.

◆ getAlias() [2/2]

std::vector< std::string > WordAlphabet::getAlias ( const std::string &  state) const
throw (BadCharException
)
virtualinherited

Get all resolved states that match a generic state.

If the given state is not a generic code then the output vector will contain this unique code.

Parameters
stateThe alias to resolve.
Returns
A vector of resolved states.
Exceptions
BadCharExceptionWhen state is not a valid char description.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 230 of file WordAlphabet.cpp.

◆ getAlphabetType()

std::string bpp::CodonAlphabet::getAlphabetType ( ) const
inlinevirtual

Identification method.

Used to tell if two alphabets describe the same type of sequences. For instance, this method is used by sequence containers to compare two alphabets and allow or deny addition of sequences.

Returns
A text describing the alphabet.

Implements bpp::Alphabet.

Definition at line 91 of file CodonAlphabet.h.

References bpp::WordAlphabet::vAbsAlph_.

◆ getCharCodeAt()

const std::string& bpp::AbstractAlphabet::getCharCodeAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited
Returns
The char code of a given state.
Parameters
stateIndexThe index of the state to fetch.

Implements bpp::Alphabet.

Definition at line 220 of file AbstractAlphabet.h.

References bpp::AlphabetState::getLetter(), and bpp::AbstractAlphabet::getStateAt().

◆ getCodon() [1/2]

int CodonAlphabet::getCodon ( int  pos1,
int  pos2,
int  pos3 
) const
throw (BadIntException
)
virtual

Get the int code for a codon given the int code of the three underlying positions.

The int code of each position must match the nucleic alphabet specified for this alphabet.

Parameters
pos1Int description for position 1.
pos2Int description for position 2.
pos3Int description for position 3.
Returns
The int code of the codon.

Definition at line 52 of file CodonAlphabet.cpp.

Referenced by bpp::GeneticCode::isFourFoldDegenerated(), bpp::CodonSiteTools::numberOfSynonymousDifferences(), and bpp::CodonSiteTools::numberOfSynonymousPositions().

◆ getCodon() [2/2]

string CodonAlphabet::getCodon ( const std::string &  pos1,
const std::string &  pos2,
const std::string &  pos3 
) const
throw (BadCharException
)
virtual

Get the char code for a codon given the char code of the three underlying positions.

The char code of each position must match the nucleic alphabet specified for this alphabet. NB: This performs pos1 + pos2 + pos3 after checking for each position validity.

Parameters
pos1Char description for position 1.
pos2Char description for position 2.
pos3Char description for position 3.
Returns
The Char code of the codon.

Definition at line 65 of file CodonAlphabet.cpp.

◆ getFirstPosition() [1/2]

int CodonAlphabet::getFirstPosition ( int  codon) const
throw (BadIntException
)
virtual

Get the int code of the first position of a codon given its int description.

Parameters
codonThe int description of the codon.
Returns
The int description of the first position of the codon.

Definition at line 78 of file CodonAlphabet.cpp.

Referenced by bpp::CodonSiteTools::fixedDifferences(), bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::CodonSiteTools::isMonoSitePolymorphic(), bpp::CodonSiteTools::numberOfDifferences(), and bpp::CodonSiteTools::numberOfSubsitutions().

◆ getFirstPosition() [2/2]

string CodonAlphabet::getFirstPosition ( const std::string &  codon) const
throw (BadCharException
)
virtual

Get the char code of the first position of a codon given its char description.

Parameters
codonThe char description of the codon.
Returns
The char description of the first position of the codon.

Definition at line 99 of file CodonAlphabet.cpp.

◆ getGapCharacterCode()

int bpp::AbstractAlphabet::getGapCharacterCode ( ) const
inlinevirtualinherited
Returns
The int code for gap characters.

Implements bpp::Alphabet.

Definition at line 159 of file AbstractAlphabet.h.

Referenced by bpp::SequenceTools::replaceStopsWithGaps().

◆ getGeneric() [1/2]

int WordAlphabet::getGeneric ( const std::vector< int > &  states) const
throw (BadIntException
)
virtualinherited

Get the generic state that match a set of states.

If the given states contain generic code, each generic code is first resolved and then the new generic state is returned. If only a single resolved state is given the function return this state.

Parameters
statesA vector of states to resolve.
Returns
A int code for the computed state.
Exceptions
BadIntExceptionWhen a state is not a valid integer.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 262 of file WordAlphabet.cpp.

◆ getGeneric() [2/2]

std::string WordAlphabet::getGeneric ( const std::vector< std::string > &  states) const
throw (BadCharException
)
virtualinherited

Get the generic state that match a set of states.

If the given states contain generic code, each generic code is first resolved and then the new generic state is returned. If only a single resolved state is given the function return this state.

Parameters
statesA vector of states to resolve.
Returns
A string code for the computed state.
Exceptions
BadCharExceptionwhen a state is not a valid char description.
CharStateNotSupportedExceptionwhen the alphabet does not support Char state for unresolved state.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 269 of file WordAlphabet.cpp.

◆ getIntCodeAt()

int bpp::AbstractAlphabet::getIntCodeAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited
Returns
The int code of a given state.
Parameters
stateIndexThe index of the state to fetch.

Implements bpp::Alphabet.

Definition at line 216 of file AbstractAlphabet.h.

References bpp::AlphabetState::getNum(), and bpp::AbstractAlphabet::getStateAt().

◆ getLength()

unsigned int bpp::WordAlphabet::getLength ( ) const
inlineinherited

Returns the length of the word.

Definition at line 156 of file WordAlphabet.h.

References bpp::WordAlphabet::vAbsAlph_.

◆ getNAlphabet()

const Alphabet* bpp::WordAlphabet::getNAlphabet ( size_t  n) const
inlineinherited

Get the pointer to the Alphabet of the n-position.

Parameters
nThe position in the word (starting at 0).
Returns
The pointer to the Alphabet of the n-position.

Definition at line 210 of file WordAlphabet.h.

References bpp::WordAlphabet::vAbsAlph_.

◆ getName() [1/2]

std::string WordAlphabet::getName ( const std::string &  state) const
throw (BadCharException
)
virtualinherited

Get the complete name of a state given its string description.

In case of undefined characters (i.e. N and X for nucleic alphabets), this method will return the name of the undefined word.

Parameters
stateThe string description of the given state.
Returns
The name of the state.
Exceptions
BadCharExceptionWhen state is not a valid char description.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 192 of file WordAlphabet.cpp.

References bpp::AbstractAlphabet::getName().

◆ getName() [2/2]

std::string AbstractAlphabet::getName ( int  state) const
throw (BadIntException
)
virtualinherited

Get the complete name of a state given its int description.

In case of several states with identical number (i.e. N and X for nucleic alphabets), this method returns the name of the first found in the vector.

Parameters
stateThe int description of the given state.
Returns
The name of the state.
Exceptions
BadIntExceptionWhen state is not a valid integer.

Implements bpp::Alphabet.

Definition at line 171 of file AbstractAlphabet.cpp.

◆ getNPosition() [1/2]

int bpp::WordAlphabet::getNPosition ( int  word,
size_t  n 
) const
throw (BadIntException
)
inlineinherited

Get the int code of the n-position of a word given its int description.

Parameters
wordThe int description of the word.
nThe position in the word (starting at 0).
Returns
The int description of the n-position of the word.

Definition at line 248 of file WordAlphabet.h.

References bpp::AbstractAlphabet::intToChar(), and bpp::WordAlphabet::vAbsAlph_.

Referenced by bpp::SequenceContainerTools::getCodonPosition().

◆ getNPosition() [2/2]

std::string bpp::WordAlphabet::getNPosition ( const std::string &  word,
size_t  n 
) const
throw (BadCharException
)
inlineinherited

Get the char code of the n-position of a word given its char description.

Parameters
wordThe char description of the word.
nThe position in the word (starting at 0).
Returns
The char description of the n-position of the word.

Definition at line 282 of file WordAlphabet.h.

References bpp::WordAlphabet::charToInt(), and bpp::WordAlphabet::vAbsAlph_.

◆ getNucleicAlphabet()

◆ getNumberOfChars()

unsigned int bpp::AbstractAlphabet::getNumberOfChars ( ) const
inlinevirtualinherited

Get the number of supported characters in this alphabet, including generic characters (e.g. return 20 for DNA alphabet).

Returns
The total number of supported character descriptions.

Implements bpp::Alphabet.

Definition at line 146 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::WordAlphabet::getNumberOfTypes(), bpp::WordAlphabet::getSize(), and bpp::NucleicAlphabet::registerState().

◆ getNumberOfStates()

size_t bpp::AbstractAlphabet::getNumberOfStates ( ) const
inlinevirtualinherited

This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.

This funcion is typically used il loops over all states of an alphabet.

Implements bpp::Alphabet.

Definition at line 145 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

◆ getNumberOfTypes()

unsigned int bpp::WordAlphabet::getNumberOfTypes ( ) const
inlinevirtualinherited

Returns the number of resolved states + one for unresolved.

Implements bpp::Alphabet.

Definition at line 166 of file WordAlphabet.h.

References bpp::AbstractAlphabet::getNumberOfChars().

◆ getPositions() [1/2]

std::vector<int> bpp::WordAlphabet::getPositions ( int  word) const
throw (BadIntException
)
inlineinherited

Get the int codes of each position of a word given its int description.

Parameters
wordThe int description of the word.
Returns
The int description of the positions of the codon.

Definition at line 264 of file WordAlphabet.h.

References bpp::WordAlphabet::charToInt(), bpp::AbstractAlphabet::intToChar(), and bpp::WordAlphabet::vAbsAlph_.

Referenced by bpp::GeneticCode::isFourFoldDegenerated(), bpp::CodonSiteTools::numberOfSynonymousDifferences(), and bpp::CodonSiteTools::numberOfSynonymousPositions().

◆ getPositions() [2/2]

std::vector<std::string> bpp::WordAlphabet::getPositions ( const std::string &  word) const
throw (BadCharException
)
inlineinherited

Get the char codes of each position of a word given its char description.

Parameters
wordThe char description of the word.
Returns
The char description of the three positions of the word.

Definition at line 300 of file WordAlphabet.h.

References bpp::WordAlphabet::charToInt().

◆ getSecondPosition() [1/2]

int CodonAlphabet::getSecondPosition ( int  codon) const
throw (BadIntException
)
virtual

Get the int code of the second position of a codon given its int description.

Parameters
codonThe int description of the codon.
Returns
The int description of the second position of the codon.

Definition at line 85 of file CodonAlphabet.cpp.

Referenced by bpp::CodonSiteTools::fixedDifferences(), bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::CodonSiteTools::isMonoSitePolymorphic(), bpp::CodonSiteTools::numberOfDifferences(), and bpp::CodonSiteTools::numberOfSubsitutions().

◆ getSecondPosition() [2/2]

string CodonAlphabet::getSecondPosition ( const std::string &  codon) const
throw (BadCharException
)
virtual

Get the char code of the second position of a codon given its char description.

Parameters
codonThe char description of the codon.
Returns
The char description of the second position of the codon.

Definition at line 107 of file CodonAlphabet.cpp.

◆ getSize()

unsigned int bpp::WordAlphabet::getSize ( ) const
inlinevirtualinherited

Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you'll need in most cases.

Returns
The number of resolved states.

Implements bpp::Alphabet.

Definition at line 138 of file WordAlphabet.h.

References bpp::AbstractAlphabet::getNumberOfChars().

Referenced by bpp::WordAlphabet::build_(), bpp::WordAlphabet::charToInt(), and bpp::WordAlphabet::getUnknownCharacterCode().

◆ getState() [1/4]

const AlphabetState & AbstractAlphabet::getState ( const std::string &  letter) const
throw (BadCharException
)
virtualinherited

Get a state by its letter.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
letterThe letter of the state to find.
Exceptions
BadCharExceptionIf the letter is not in the Alphabet.

Implements bpp::Alphabet.

Reimplemented in bpp::NucleicAlphabet, and bpp::ProteicAlphabet.

Definition at line 94 of file AbstractAlphabet.cpp.

Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet(), bpp::ProteicAlphabet::getState(), and bpp::NucleicAlphabet::getState().

◆ getState() [2/4]

AlphabetState & AbstractAlphabet::getState ( const std::string &  letter)
throw (BadCharException
)
inherited

Definition at line 130 of file AbstractAlphabet.cpp.

◆ getState() [3/4]

const AlphabetState & AbstractAlphabet::getState ( int  num) const
throw (BadIntException
)
virtualinherited

Get a state by its num.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
numThe num of the state to find.
Exceptions
BadIntExceptionIf the num is not in the Alphabet.

Implements bpp::Alphabet.

Reimplemented in bpp::NucleicAlphabet, and bpp::ProteicAlphabet.

Definition at line 112 of file AbstractAlphabet.cpp.

◆ getState() [4/4]

AlphabetState & AbstractAlphabet::getState ( int  num)
throw (BadIntException
)
inherited

Definition at line 139 of file AbstractAlphabet.cpp.

◆ getStateAt() [1/2]

AlphabetState & AbstractAlphabet::getStateAt ( size_t  stateIndex)
throw (IndexOutOfBoundsException
)
virtualinherited

Get a state at a position in the alphabet_ vector.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
stateIndexThe index of the state in the alphabet_ vector.
Exceptions
IndexOutOfBoundsExceptionIf the index is invalid.

Reimplemented in bpp::NucleicAlphabet, bpp::NumericAlphabet, and bpp::ProteicAlphabet.

Definition at line 148 of file AbstractAlphabet.cpp.

Referenced by bpp::AbstractAlphabet::getCharCodeAt(), bpp::AbstractAlphabet::getIntCodeAt(), bpp::ProteicAlphabet::getStateAt(), bpp::NumericAlphabet::getStateAt(), and bpp::NucleicAlphabet::getStateAt().

◆ getStateAt() [2/2]

const AlphabetState & AbstractAlphabet::getStateAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
virtualinherited

Get a state at a position in the alphabet_ vector.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
stateIndexThe index of the state in the alphabet_ vector.
Exceptions
IndexOutOfBoundsExceptionIf the index is invalid.

Implements bpp::Alphabet.

Reimplemented in bpp::NucleicAlphabet, bpp::NumericAlphabet, and bpp::ProteicAlphabet.

Definition at line 156 of file AbstractAlphabet.cpp.

◆ getStateCodingSize()

unsigned int bpp::WordAlphabet::getStateCodingSize ( ) const
inlinevirtualinherited

Get the size of the string coding a state.

Returns
The size of the tring coding each states in the Alphabet.
Author
Sylvain Gaillard

Reimplemented from bpp::AbstractAlphabet.

Definition at line 339 of file WordAlphabet.h.

References bpp::WordAlphabet::vAbsAlph_.

◆ getStateIndex() [1/2]

size_t AbstractAlphabet::getStateIndex ( int  state) const
throw (BadIntException
)
virtualinherited
Returns
The indices of the states with corresponding int code.

Implements bpp::Alphabet.

Definition at line 121 of file AbstractAlphabet.cpp.

Referenced by bpp::AAIndex2Entry::getIndex().

◆ getStateIndex() [2/2]

size_t AbstractAlphabet::getStateIndex ( const std::string &  state) const
throw (BadCharException
)
virtualinherited
Returns
The index of the state with corresponding char code.

Implements bpp::Alphabet.

Definition at line 103 of file AbstractAlphabet.cpp.

◆ getSupportedChars()

const std::vector< std::string > & AbstractAlphabet::getSupportedChars ( ) const
virtualinherited
Returns
A list of all supported character codes.

Note for developers of new alphabets: we return a const reference here since the list is supposed to be stored within the class and should not be modified outside the class.

Implements bpp::Alphabet.

Definition at line 301 of file AbstractAlphabet.cpp.

Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet().

◆ getSupportedInts()

const std::vector< int > & AbstractAlphabet::getSupportedInts ( ) const
virtualinherited
Returns
A list of all supported int codes.

Note for developers of new alphabets: we return a const reference here since the list is supposed to be stored within the class and should not be modified outside the class.

Implements bpp::Alphabet.

Definition at line 284 of file AbstractAlphabet.cpp.

◆ getThirdPosition() [1/2]

int CodonAlphabet::getThirdPosition ( int  codon) const
throw (BadIntException
)
virtual

Get the int code of the third position of a codon given its int description.

Parameters
codonThe int description of the codon.
Returns
The int description of the third position of the codon.

Definition at line 92 of file CodonAlphabet.cpp.

Referenced by bpp::CodonSiteTools::fixedDifferences(), bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::CodonSiteTools::isMonoSitePolymorphic(), bpp::CodonSiteTools::numberOfDifferences(), and bpp::CodonSiteTools::numberOfSubsitutions().

◆ getThirdPosition() [2/2]

string CodonAlphabet::getThirdPosition ( const std::string &  codon) const
throw (BadCharException
)
virtual

Get the char code of the third position of a codon given its char description.

Parameters
codonThe char description of the codon.
Returns
The char description of the third position of the codon.

Definition at line 115 of file CodonAlphabet.cpp.

◆ getUnknownCharacterCode()

◆ getWord() [1/2]

int WordAlphabet::getWord ( const std::vector< int > &  vint,
size_t  pos = 0 
) const
throw (IndexOutOfBoundsException
)
virtualinherited

Get the int code for a word given the int code of the underlying positions.

The int code of each position must match the corresponding alphabet specified at this position.

Parameters
vintdescription for all the positions.
posthe start position to match in the vector.
Returns
The int code of the word.
Exceptions
IndexOutOfBoundsExceptionIn case of wrong position.

Definition at line 276 of file WordAlphabet.cpp.

◆ getWord() [2/2]

std::string WordAlphabet::getWord ( const std::vector< std::string > &  vpos,
size_t  pos = 0 
) const
throw (IndexOutOfBoundsException,
BadCharException
)
virtualinherited

Get the char code for a word given the char code of the underlying positions.

The char code of each position must match the corresponding alphabet specified at this position.

Parameters
vposvector description for all the positions.
posthe start position to match in the vector.
Returns
The string of the word.
Exceptions
IndexOutOfBoundsExceptionIn case of wrong position.

Definition at line 292 of file WordAlphabet.cpp.

◆ hasUniqueAlphabet()

bool WordAlphabet::hasUniqueAlphabet ( ) const
inherited

Returns True if the Alphabet of the letters in the word are the same type.

Definition at line 146 of file WordAlphabet.cpp.

References bpp::WordAlphabet::getAlphabetType(), and bpp::WordAlphabet::vAbsAlph_.

◆ intToChar()

◆ isCharInAlphabet()

bool AbstractAlphabet::isCharInAlphabet ( const std::string &  state) const
virtualinherited

Tell if a state (specified by its string description) is allowed by the the alphabet.

Parameters
stateThe string description.
Returns
'true' if the state in known.

Implements bpp::Alphabet.

Reimplemented in bpp::LetterAlphabet.

Definition at line 202 of file AbstractAlphabet.cpp.

◆ isGap() [1/2]

bool bpp::AbstractAlphabet::isGap ( int  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is a gap.

Implements bpp::Alphabet.

Reimplemented in bpp::RNY, and bpp::NumericAlphabet.

Definition at line 160 of file AbstractAlphabet.h.

◆ isGap() [2/2]

bool bpp::AbstractAlphabet::isGap ( const std::string &  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is a gap.

Implements bpp::Alphabet.

Definition at line 161 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::charToInt().

◆ isIntInAlphabet()

bool AbstractAlphabet::isIntInAlphabet ( int  state) const
virtualinherited

Tell if a state (specified by its int description) is allowed by the the alphabet.

Parameters
stateThe int description.
Returns
'true' if the state in known.

Implements bpp::Alphabet.

Definition at line 192 of file AbstractAlphabet.cpp.

◆ isUnresolved() [1/2]

bool bpp::WordAlphabet::isUnresolved ( int  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is unresolved.

Implements bpp::Alphabet.

Definition at line 178 of file WordAlphabet.h.

References bpp::WordAlphabet::getUnknownCharacterCode().

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

◆ isUnresolved() [2/2]

bool bpp::WordAlphabet::isUnresolved ( const std::string &  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is unresolved.

Implements bpp::Alphabet.

Definition at line 179 of file WordAlphabet.h.

References bpp::WordAlphabet::charToInt(), and bpp::WordAlphabet::getUnknownCharacterCode().

◆ operator=()

CodonAlphabet& bpp::CodonAlphabet::operator= ( const CodonAlphabet bia)
inline

Definition at line 78 of file CodonAlphabet.h.

References bpp::WordAlphabet::operator=().

◆ registerState()

void AbstractAlphabet::registerState ( AlphabetState st)
throw (Exception
)
protectedvirtualinherited

◆ remap()

void bpp::AbstractAlphabet::remap ( )
inlineprotectedinherited

Re-update the maps using the alphabet_ vector content.

Definition at line 258 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_, bpp::AbstractAlphabet::letters_, bpp::AbstractAlphabet::nums_, and bpp::AbstractAlphabet::updateMaps_().

Referenced by bpp::NumericAlphabet::remap().

◆ resize()

void bpp::AbstractAlphabet::resize ( size_t  size)
inlineprotectedinherited

Resize the private alphabet_ vector.

Parameters
sizeThe new size of the Alphabet.

Definition at line 253 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::IntegerAlphabet::IntegerAlphabet().

◆ reverse()

Sequence * WordAlphabet::reverse ( const Sequence sequence) const
throw (AlphabetMismatchException,
Exception
)
inherited

Translate a whole sequence from words alphabet to letters alphabet.

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

Definition at line 333 of file WordAlphabet.cpp.

References bpp::Sequence::append(), and bpp::BasicSymbolList::size().

◆ setState()

void AbstractAlphabet::setState ( size_t  pos,
AlphabetState st 
)
throw (Exception,
IndexOutOfBoundsException
)
protectedvirtualinherited

Set a state in the Alphabet.

Parameters
posThe index of the state in the alphabet_ vector.
stThe new state to put in the Alphabet.
Exceptions
ExceptionIf a wrong alphabet state is provided.
IndexOutOfBoundsExceptionIf an incorrect index is provided.

Reimplemented in bpp::LetterAlphabet, bpp::NucleicAlphabet, and bpp::NumericAlphabet.

Definition at line 79 of file AbstractAlphabet.cpp.

Referenced by bpp::NumericAlphabet::setState(), and bpp::LetterAlphabet::setState().

◆ translate()

Sequence * WordAlphabet::translate ( const Sequence sequence,
size_t  pos = 0 
) const
throw (AlphabetMismatchException,
Exception
)
inherited

Translate a whole sequence from letters alphabet to words alphabet.

Parameters
sequenceA sequence in letters alphabet.
posthe start postion (default 0)
Returns
The corresponding sequence in words alphabet.
Exceptions
AlphabetMismatchExceptionIf the sequence alphabet do not match the source alphabet.
ExceptionOther kind of error, depending on the implementation.

Definition at line 309 of file WordAlphabet.cpp.

Member Data Documentation

◆ charList_

std::vector<std::string> bpp::AbstractAlphabet::charList_
mutableprotectedinherited

Definition at line 99 of file AbstractAlphabet.h.

Referenced by bpp::AbstractAlphabet::operator=().

◆ intList_

std::vector<int> bpp::AbstractAlphabet::intList_
mutableprotectedinherited

Definition at line 100 of file AbstractAlphabet.h.

Referenced by bpp::AbstractAlphabet::operator=().

◆ vAbsAlph_


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