bpp-seq
2.2.0
|
Specialized partial implementation of Alphabet using single letters. More...
#include <Bpp/Seq/Alphabet/LetterAlphabet.h>
Public Member Functions | |
LetterAlphabet (bool caseSensitive=false) | |
LetterAlphabet (const LetterAlphabet &bia) | |
LetterAlphabet & | operator= (const LetterAlphabet &bia) |
virtual LetterAlphabet * | clone () const =0 |
virtual | ~LetterAlphabet () |
bool | isCharInAlphabet (char state) const |
bool | isCharInAlphabet (const std::string &state) const |
Tell if a state (specified by its string description) is allowed by the the alphabet. More... | |
int | charToInt (const std::string &state) const throw (BadCharException) |
Give the int description of a state given its string description. More... | |
virtual std::string | getAlphabetType () const =0 |
Identification method. More... | |
Implement these methods from the Alphabet interface. | |
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 | getName (const std::string &state) const throw (BadCharException) |
Get the complete name of a state given its string description. More... | |
std::string | getName (int state) const throw (BadIntException) |
Get the complete name of a state given its int description. 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... | |
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 (AlphabetException) |
Get the generic state that match a set of states. 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 |
Specific methods to access AlphabetState | |
virtual AlphabetState & | getStateAt (size_t stateIndex) throw (IndexOutOfBoundsException) |
Get a state at a position in the alphabet_ vector. More... | |
virtual const AlphabetState & | getStateAt (size_t stateIndex) const throw (IndexOutOfBoundsException) |
Get a state at a position in the alphabet_ vector. More... | |
const AlphabetState & | getState (const std::string &letter) const throw (BadCharException) |
Get a state by its letter. More... | |
AlphabetState & | getState (const std::string &letter) throw (BadCharException) |
const AlphabetState & | getState (int num) const throw (BadIntException) |
Get a state by its num. More... | |
AlphabetState & | getState (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) |
Sizes. | |
virtual unsigned int | getNumberOfTypes () const =0 |
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number of integers used for state description. More... | |
virtual unsigned int | getSize () const =0 |
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... | |
Utilitary methods | |
virtual int | getUnknownCharacterCode () const =0 |
virtual bool | isUnresolved (int state) const =0 |
virtual bool | isUnresolved (const std::string &state) const =0 |
Protected Member Functions | |
void | registerState (AlphabetState *st) throw (Exception) |
Add a state to the Alphabet. More... | |
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... | |
unsigned int | getStateCodingSize () const |
Get the size of the string coding a state. More... | |
bool | equals (const Alphabet &alphabet) const |
Comparison of alphabets. More... | |
Protected Attributes | |
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_ |
Private Attributes | |
std::vector< int > | letters_ |
bool | caseSensitive_ |
Static Private Attributes | |
static const int | LETTER_UNDEF_VALUE = -99 |
Specialized partial implementation of Alphabet using single letters.
Definition at line 57 of file LetterAlphabet.h.
|
inline |
Definition at line 66 of file LetterAlphabet.h.
|
inline |
Definition at line 68 of file LetterAlphabet.h.
|
inlinevirtual |
Definition at line 84 of file LetterAlphabet.h.
|
inlinevirtual |
Give the int description of a state given its string description.
state | The string description. |
BadCharException | When state is not a valid char description. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 93 of file LetterAlphabet.h.
References isCharInAlphabet(), and letters_.
Referenced by bpp::AAIndex1Entry::getIndex(), bpp::AAMassIndex::getIndex(), bpp::AASEA1030Index::getIndex(), bpp::AASEAInf10Index::getIndex(), bpp::AASEASup30Index::getIndex(), bpp::AASurfaceIndex::getIndex(), bpp::AAChouFasmanBSheetIndex::getIndex(), bpp::AAChouFasmanTurnIndex::getIndex(), bpp::AAVolumeIndex::getIndex(), bpp::AAChouFasmanAHelixIndex::getIndex(), bpp::AAChenGuHuangHydrophobicityIndex::getIndex(), bpp::GranthamAAPolarityIndex::getIndex(), bpp::KleinAANetChargeIndex::getIndex(), bpp::GranthamAAVolumeIndex::getIndex(), bpp::AAChargeIndex::getIndex(), bpp::NucleicAlphabet::getOverlap(), bpp::ProteicAlphabet::isUnresolved(), bpp::NucleicAlphabet::isUnresolved(), and bpp::NucleicAlphabet::subtract().
|
pure virtual |
Implements bpp::AbstractAlphabet.
Implemented in bpp::ProteicAlphabet, bpp::NucleicAlphabet, bpp::DNA, bpp::CaseMaskedAlphabet, bpp::DefaultAlphabet, and bpp::RNA.
|
inlineprotectedvirtualinherited |
Comparison of alphabets.
Implements bpp::Alphabet.
Definition at line 268 of file AbstractAlphabet.h.
References bpp::Alphabet::getAlphabetType().
|
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.
state | The alias to resolve. |
BadIntException | When state is not a valid integer. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DNA, and bpp::RNA.
Definition at line 212 of file AbstractAlphabet.cpp.
|
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.
state | The alias to resolve. |
BadCharException | When state is not a valid char description. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DNA, and bpp::RNA.
Definition at line 222 of file AbstractAlphabet.cpp.
|
pure virtualinherited |
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.
Implemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::CodonAlphabet, bpp::DNA, bpp::DefaultAlphabet, bpp::RNA, bpp::CaseMaskedAlphabet, bpp::IntegerAlphabet, and bpp::BinaryAlphabet.
Referenced by bpp::SiteTools::areSitesIdentical(), bpp::AbstractAlphabet::equals(), and bpp::SequenceTools::invertComplement().
|
inlinevirtualinherited |
stateIndex | The 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().
|
inlinevirtualinherited |
Implements bpp::Alphabet.
Definition at line 159 of file AbstractAlphabet.h.
Referenced by bpp::SequenceTools::replaceStopsWithGaps().
|
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.
states | A vector of states to resolve. |
BadIntException | When a state is not a valid integer. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::DNA, and bpp::RNA.
Definition at line 232 of file AbstractAlphabet.cpp.
|
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.
states | A vector of states to resolve. |
BadCharException | when a state is not a valid char description. |
CharStateNotSupportedException | when the alphabet does not support Char state for unresolved state. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::DNA, and bpp::RNA.
Definition at line 258 of file AbstractAlphabet.cpp.
|
inlinevirtualinherited |
stateIndex | The 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().
|
virtualinherited |
Get the complete name of a state given its string description.
In case of several states with identical number (i.e. N and X for nucleic alphabets), this method will return the name of the first found in the vector.
state | The string description of the given state. |
BadCharException | When state is not a valid char description. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet.
Definition at line 164 of file AbstractAlphabet.cpp.
Referenced by bpp::WordAlphabet::getName().
|
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.
state | The int description of the given state. |
BadIntException | When state is not a valid integer. |
Implements bpp::Alphabet.
Definition at line 171 of file AbstractAlphabet.cpp.
|
inlinevirtualinherited |
Get the number of supported characters in this alphabet, including generic characters (e.g. return 20 for DNA alphabet).
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().
|
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_.
|
pure virtualinherited |
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number of integers used for state description.
Implemented in bpp::NucleicAlphabet, bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::DefaultAlphabet, bpp::NumericAlphabet, bpp::CaseMaskedAlphabet, bpp::IntegerAlphabet, and bpp::BinaryAlphabet.
Referenced by bpp::CaseMaskedAlphabet::getNumberOfTypes().
|
pure virtualinherited |
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.
Implemented in bpp::NucleicAlphabet, bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::DefaultAlphabet, bpp::NumericAlphabet, bpp::CaseMaskedAlphabet, bpp::IntegerAlphabet, and bpp::BinaryAlphabet.
Referenced by bpp::SequenceTools::bowkerTest(), bpp::SequenceContainerTools::getFrequencies(), bpp::SequenceTools::getRandomSequence(), bpp::SequenceApplicationTools::getSitesToAnalyse(), bpp::CaseMaskedAlphabet::getSize(), and bpp::SimpleScore::SimpleScore().
|
virtualinherited |
Get a state by its letter.
This method must be overloaded in specialized classes to send back a reference of the corect type.
letter | The letter of the state to find. |
BadCharException | If 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().
|
inherited |
Definition at line 130 of file AbstractAlphabet.cpp.
|
virtualinherited |
Get a state by its num.
This method must be overloaded in specialized classes to send back a reference of the corect type.
num | The num of the state to find. |
BadIntException | If 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.
|
inherited |
Definition at line 139 of file AbstractAlphabet.cpp.
|
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.
stateIndex | The index of the state in the alphabet_ vector. |
IndexOutOfBoundsException | If 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().
|
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.
stateIndex | The index of the state in the alphabet_ vector. |
IndexOutOfBoundsException | If the index is invalid. |
Implements bpp::Alphabet.
Reimplemented in bpp::NucleicAlphabet, bpp::NumericAlphabet, and bpp::ProteicAlphabet.
Definition at line 156 of file AbstractAlphabet.cpp.
|
inlineprotectedvirtualinherited |
Get the size of the string coding a state.
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet.
Definition at line 266 of file AbstractAlphabet.h.
|
virtualinherited |
Implements bpp::Alphabet.
Definition at line 121 of file AbstractAlphabet.cpp.
Referenced by bpp::AAIndex2Entry::getIndex().
|
virtualinherited |
Implements bpp::Alphabet.
Definition at line 103 of file AbstractAlphabet.cpp.
|
virtualinherited |
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().
|
virtualinherited |
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.
|
pure virtualinherited |
Implemented in bpp::NucleicAlphabet, bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::DefaultAlphabet, bpp::NumericAlphabet, bpp::CaseMaskedAlphabet, bpp::IntegerAlphabet, and bpp::BinaryAlphabet.
Referenced by bpp::SymbolListTools::changeGapsToUnknownCharacters(), bpp::SiteContainerTools::changeGapsToUnknownCharacters(), bpp::CaseMaskedAlphabet::getUnknownCharacterCode(), bpp::SiteTools::hasUnknown(), and bpp::SequenceTools::subtractHaplotype().
|
virtualinherited |
Give the string description of a state given its int description.
state | The int description. |
BadIntException | When state is not a valid integer. |
Implements bpp::Alphabet.
Reimplemented in bpp::RNY.
Definition at line 185 of file AbstractAlphabet.cpp.
Referenced by bpp::RNY::getAlias(), bpp::GeneticCode::getCodingSequence(), bpp::WordAlphabet::getNPosition(), bpp::NucleicAlphabet::getOverlap(), bpp::WordAlphabet::getPositions(), bpp::EchinodermMitochondrialGeneticCode::isAltStart(), bpp::MoldMitochondrialGeneticCode::isAltStart(), bpp::StandardGeneticCode::isAltStart(), bpp::YeastMitochondrialGeneticCode::isAltStart(), bpp::InvertebrateMitochondrialGeneticCode::isAltStart(), bpp::AscidianMitochondrialGeneticCode::isAltStart(), bpp::VertebrateMitochondrialGeneticCode::isAltStart(), bpp::GeneticCode::isStart(), bpp::EchinodermMitochondrialGeneticCode::isStop(), bpp::MoldMitochondrialGeneticCode::isStop(), bpp::InvertebrateMitochondrialGeneticCode::isStop(), bpp::YeastMitochondrialGeneticCode::isStop(), bpp::StandardGeneticCode::isStop(), bpp::VertebrateMitochondrialGeneticCode::isStop(), bpp::AscidianMitochondrialGeneticCode::isStop(), and bpp::NucleicAlphabet::subtract().
|
inline |
Definition at line 87 of file LetterAlphabet.h.
References LETTER_UNDEF_VALUE, and letters_.
Referenced by charToInt(), and isCharInAlphabet().
|
inlinevirtual |
Tell if a state (specified by its string description) is allowed by the the alphabet.
state | The string description. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 90 of file LetterAlphabet.h.
References isCharInAlphabet().
|
inlinevirtualinherited |
state | The state to test. |
Implements bpp::Alphabet.
Reimplemented in bpp::RNY, and bpp::NumericAlphabet.
Definition at line 160 of file AbstractAlphabet.h.
|
inlinevirtualinherited |
state | The state to test. |
Implements bpp::Alphabet.
Definition at line 161 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::charToInt().
|
virtualinherited |
Tell if a state (specified by its int description) is allowed by the the alphabet.
state | The int description. |
Implements bpp::Alphabet.
Definition at line 192 of file AbstractAlphabet.cpp.
|
pure virtualinherited |
state | The state to test. |
Implemented in bpp::NucleicAlphabet, bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DefaultAlphabet, bpp::IntegerAlphabet, bpp::CaseMaskedAlphabet, and bpp::BinaryAlphabet.
Referenced by bpp::SequenceTools::bowkerTest(), bpp::SymbolListTools::changeUnresolvedCharactersToGaps(), bpp::SiteContainerTools::changeUnresolvedCharactersToGaps(), bpp::SiteContainerTools::computeSimilarity(), bpp::SequenceTools::getNumberOfCompleteSites(), bpp::SequenceTools::getNumberOfUnresolvedSites(), bpp::SequenceTools::getSequenceWithCompleteSites(), bpp::SiteTools::isComplete(), bpp::SiteTools::isGapOrUnresolvedOnly(), bpp::CaseMaskedAlphabet::isUnresolved(), and bpp::SequenceTools::subtractHaplotype().
|
pure virtualinherited |
state | The state to test. |
Implemented in bpp::NucleicAlphabet, bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DefaultAlphabet, bpp::IntegerAlphabet, bpp::CaseMaskedAlphabet, and bpp::BinaryAlphabet.
|
inline |
Definition at line 70 of file LetterAlphabet.h.
References caseSensitive_, letters_, and bpp::AbstractAlphabet::operator=().
Referenced by bpp::DefaultAlphabet::operator=(), bpp::CaseMaskedAlphabet::operator=(), bpp::NucleicAlphabet::operator=(), and bpp::ProteicAlphabet::operator=().
|
inlineprotectedvirtual |
Add a state to the Alphabet.
st | The state to add. |
Exception | If a wrong alphabet state is provided. |
Reimplemented from bpp::AbstractAlphabet.
Reimplemented in bpp::NucleicAlphabet.
Definition at line 100 of file LetterAlphabet.h.
References caseSensitive_, letters_, and bpp::AbstractAlphabet::registerState().
Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet(), and bpp::NucleicAlphabet::registerState().
|
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().
|
inlineprotectedinherited |
Resize the private alphabet_ vector.
size | The new size of the Alphabet. |
Definition at line 253 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::alphabet_.
Referenced by bpp::IntegerAlphabet::IntegerAlphabet().
|
inlineprotectedvirtual |
Set a state in the Alphabet.
pos | The index of the state in the alphabet_ vector. |
st | The new state to put in the Alphabet. |
Exception | If a wrong alphabet state is provided. |
IndexOutOfBoundsException | If an incorrect index is provided. |
Reimplemented from bpp::AbstractAlphabet.
Reimplemented in bpp::NucleicAlphabet.
Definition at line 110 of file LetterAlphabet.h.
References caseSensitive_, letters_, and bpp::AbstractAlphabet::setState().
Referenced by bpp::NucleicAlphabet::setState().
|
private |
Definition at line 63 of file LetterAlphabet.h.
Referenced by operator=(), registerState(), and setState().
|
mutableprotectedinherited |
Definition at line 99 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=().
|
mutableprotectedinherited |
Definition at line 100 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=().
|
staticprivate |
Definition at line 61 of file LetterAlphabet.h.
Referenced by isCharInAlphabet().
|
private |
Definition at line 62 of file LetterAlphabet.h.
Referenced by charToInt(), isCharInAlphabet(), operator=(), registerState(), and setState().