bpp-seq3
3.0.0
|
#include <Bpp/Seq/Alphabet/NumericAlphabet.h>
Public Member Functions | |
NumericAlphabet (const UniformDiscreteDistribution &) | |
virtual | ~NumericAlphabet () |
NumericAlphabet (const NumericAlphabet &) | |
NumericAlphabet & | operator= (const NumericAlphabet &) |
NumericAlphabet * | clone () const |
void | setState (size_t pos, AlphabetState *st) |
Set a state in the Alphabet. More... | |
void | registerState (AlphabetState *st) |
Add a state to the Alphabet. More... | |
bool | containsGap (const std::string &state) const |
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... | |
unsigned int | getNumberOfTypes () const |
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... | |
int | getUnknownCharacterCode () const |
bool | isGap (int state) const |
std::vector< int > | getAlias (int state) const |
Get all resolved states that match a generic state. More... | |
std::vector< std::string > | getAlias (const std::string &state) const |
Get all resolved states that match a generic state. More... | |
bool | isUnresolved (int state) const |
bool | isUnresolved (const std::string &state) const |
std::string | getAlphabetType () const |
Identification method. More... | |
AlphabetNumericState & | getStateAt (size_t stateIndex) |
Get a state at a position in the alphabet_ vector. More... | |
const AlphabetNumericState & | getStateAt (size_t stateIndex) const |
Get a state at a position in the alphabet_ vector. More... | |
double | getDelta () const |
Returns the difference between successive values. More... | |
double | intToValue (int state) const |
Returns the value for the character number. More... | |
size_t | getValueIndex (double value) const |
Returns the CategoryIndex of the category to which the value belongs. More... | |
void | remap () |
Re-update the maps. 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 |
Get the complete name of a state given its string description. More... | |
std::string | getName (int state) const |
Get the complete name of a state given its int description. More... | |
int | charToInt (const std::string &state) const |
Give the int description of a state given its string description. More... | |
std::string | intToChar (int state) const |
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... | |
bool | isResolvedIn (int state1, int state2) const |
Tells if a given (potentially unresolved) state can be resolved in another resolved state. More... | |
int | getGeneric (const std::vector< int > &states) const |
Get the generic state that match a set of states. More... | |
std::string | getGeneric (const std::vector< std::string > &states) const |
Get the generic state that match a set of states. More... | |
const std::vector< int > & | getSupportedInts () const |
const std::vector< std::string > & | getSupportedChars () const |
const std::vector< std::string > & | getResolvedChars () const |
int | getGapCharacterCode () const |
bool | isGap (const std::string &state) const |
Specific methods to access AlphabetState | |
const AlphabetState & | getState (const std::string &letter) const |
Get a state by its letter. More... | |
AlphabetState & | getState (const std::string &letter) |
const AlphabetState & | getState (int num) const |
Get a state by its num. More... | |
AlphabetState & | getState (int num) |
int | getIntCodeAt (size_t stateIndex) const |
const std::string & | getCharCodeAt (size_t stateIndex) const |
size_t | getStateIndex (int state) const |
size_t | getStateIndex (const std::string &state) const |
Protected Member Functions | |
void | resize (size_t size) |
Resize the private alphabet_ vector. 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 Member Functions | |
void | updateMaps_ (size_t pos, const AlphabetState &st) |
Update the private maps letters_ and nums_ when adding a state. More... | |
Private Attributes | |
const UniformDiscreteDistribution * | pdd_ |
std::map< double, size_t > | values_ |
std::vector< AlphabetState * > | alphabet_ |
Alphabet: vector of AlphabetState. More... | |
maps used to quick search for letter and num. | |
std::map< std::string, size_t > | letters_ |
std::map< int, size_t > | nums_ |
Definition at line 21 of file NumericAlphabet.h.
NumericAlphabet::NumericAlphabet | ( | const UniformDiscreteDistribution & | pd | ) |
Definition at line 16 of file NumericAlphabet.cpp.
References bpp::UniformDiscreteDistribution::getCategories(), bpp::UniformDiscreteDistribution::getNumberOfCategories(), pdd_, registerState(), and bpp::TextTools::toString().
Referenced by clone().
|
inlinevirtual |
Definition at line 31 of file NumericAlphabet.h.
References pdd_.
NumericAlphabet::NumericAlphabet | ( | const NumericAlphabet & | na | ) |
Definition at line 30 of file NumericAlphabet.cpp.
|
virtualinherited |
Give the int description of a state given its string description.
state | The string description. |
BadCharException | When state is not a valid char description. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::CodonAlphabet, bpp::AllelicAlphabet, bpp::RNY, and bpp::LetterAlphabet.
Definition at line 153 of file AbstractAlphabet.cpp.
Referenced by bpp::RNY::charToInt(), bpp::AllelicAlphabet::charToInt(), bpp::CodonAlphabet::charToInt(), bpp::WordAlphabet::charToInt(), bpp::AbstractAlphabet::isGap(), bpp::BinaryAlphabet::isUnresolved(), and bpp::LexicalAlphabet::isUnresolved().
|
inlinevirtual |
Implements bpp::AbstractAlphabet.
Definition at line 37 of file NumericAlphabet.h.
References NumericAlphabet().
bool NumericAlphabet::containsGap | ( | const std::string & | state | ) | const |
Definition at line 96 of file NumericAlphabet.cpp.
|
inlineprotectedvirtualinherited |
Comparison of alphabets.
Implements bpp::Alphabet.
Definition at line 243 of file AbstractAlphabet.h.
References bpp::Alphabet::getAlphabetType().
|
virtual |
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. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 82 of file NumericAlphabet.cpp.
|
virtual |
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. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 75 of file NumericAlphabet.cpp.
|
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.
Implements bpp::Alphabet.
Definition at line 57 of file NumericAlphabet.h.
|
inlinevirtualinherited |
stateIndex | The index of the state to fetch. |
Implements bpp::Alphabet.
Definition at line 192 of file AbstractAlphabet.h.
References bpp::AlphabetState::getLetter(), and bpp::AbstractAlphabet::getStateAt().
double NumericAlphabet::getDelta | ( | ) | const |
Returns the difference between successive values.
@ brief Specific methods
Definition at line 135 of file NumericAlphabet.cpp.
References bpp::UniformDiscreteDistribution::getLowerBound(), bpp::UniformDiscreteDistribution::getNumberOfCategories(), bpp::UniformDiscreteDistribution::getUpperBound(), and pdd_.
|
inlinevirtualinherited |
Implements bpp::Alphabet.
Definition at line 130 of file AbstractAlphabet.h.
|
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::CodonAlphabet, bpp::AllelicAlphabet, bpp::RNA, bpp::ProteicAlphabet, and bpp::DNA.
Definition at line 225 of file AbstractAlphabet.cpp.
References bpp::MapTools::getKeys(), and bpp::TextTools::toString().
|
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::CodonAlphabet, bpp::AllelicAlphabet, bpp::RNA, bpp::ProteicAlphabet, and bpp::DNA.
Definition at line 259 of file AbstractAlphabet.cpp.
References bpp::MapTools::getKeys(), and bpp::TextTools::toString().
|
inlinevirtualinherited |
stateIndex | The index of the state to fetch. |
Implements bpp::Alphabet.
Definition at line 187 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 139 of file AbstractAlphabet.cpp.
Referenced by bpp::WordAlphabet::getName(), and bpp::LexicalAlphabet::LexicalAlphabet().
|
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 146 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 115 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::alphabet_.
Referenced by bpp::LexicalAlphabet::getNumberOfTypes(), bpp::AllelicAlphabet::getNumberOfTypes(), bpp::WordAlphabet::getNumberOfTypes(), bpp::LexicalAlphabet::getSize(), bpp::AllelicAlphabet::getSize(), bpp::WordAlphabet::getSize(), and bpp::NucleicAlphabet::registerState().
|
inlinevirtualinherited |
This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.
This function is typically used il loops over all states of an alphabet.
Implements bpp::Alphabet.
Definition at line 114 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::alphabet_.
Referenced by bpp::LexicalAlphabet::getAlphabetType().
|
virtual |
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.
Implements bpp::Alphabet.
Definition at line 116 of file NumericAlphabet.cpp.
References values_.
|
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 327 of file AbstractAlphabet.cpp.
|
virtual |
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.
Implements bpp::Alphabet.
Definition at line 111 of file NumericAlphabet.cpp.
References values_.
Referenced by registerState(), and remap().
|
inherited |
Definition at line 101 of file AbstractAlphabet.cpp.
|
virtualinherited |
Get a state by its letter.
This method must be overloaded in specialized classes to send back a reference of the correct type.
letter | The letter of the state to find. |
BadCharException | If the letter is not in the Alphabet. |
Implements bpp::Alphabet.
Reimplemented in bpp::ProteicAlphabet, and bpp::NucleicAlphabet.
Definition at line 61 of file AbstractAlphabet.cpp.
Referenced by bpp::AllelicAlphabet::getAlias(), bpp::NucleicAlphabet::getState(), bpp::ProteicAlphabet::getState(), bpp::RNY::intToChar(), and intToValue().
|
inherited |
Definition at line 111 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 correct type.
num | The num of the state to find. |
BadIntException | If the num is not in the Alphabet. |
Implements bpp::Alphabet.
Reimplemented in bpp::ProteicAlphabet, and bpp::NucleicAlphabet.
Definition at line 81 of file AbstractAlphabet.cpp.
|
virtual |
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 correct type.
stateIndex | The index of the state in the alphabet_ vector. |
IndexOutOfBoundsException | If the index is invalid. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 151 of file NumericAlphabet.cpp.
References bpp::AbstractAlphabet::getStateAt().
Referenced by remap().
|
virtual |
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 correct type.
stateIndex | The index of the state in the alphabet_ vector. |
IndexOutOfBoundsException | If the index is invalid. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 156 of file NumericAlphabet.cpp.
References bpp::AbstractAlphabet::getStateAt().
|
inlineprotectedvirtualinherited |
Get the size of the string coding a state.
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::CodonAlphabet, and bpp::AllelicAlphabet.
Definition at line 241 of file AbstractAlphabet.h.
|
virtualinherited |
Implements bpp::Alphabet.
Definition at line 71 of file AbstractAlphabet.cpp.
|
virtualinherited |
Implements bpp::Alphabet.
Definition at line 91 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 310 of file AbstractAlphabet.cpp.
Referenced by bpp::AllelicAlphabet::getAlias().
|
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 293 of file AbstractAlphabet.cpp.
Referenced by bpp::AllelicAlphabet::getAlias().
|
inlinevirtual |
Implements bpp::Alphabet.
Definition at line 50 of file NumericAlphabet.h.
size_t NumericAlphabet::getValueIndex | ( | double | value | ) | const |
Returns the CategoryIndex of the category to which the value belongs.
Definition at line 145 of file NumericAlphabet.cpp.
References bpp::UniformDiscreteDistribution::getValueCategory(), pdd_, and values_.
|
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 160 of file AbstractAlphabet.cpp.
Referenced by bpp::RNY::getAlias(), bpp::WordAlphabet::getAlias(), bpp::CaseMaskedAlphabet::getMaskedEquivalentState(), bpp::WordAlphabet::getNPosition(), bpp::NucleicAlphabet::getOverlap(), bpp::WordAlphabet::getPositions(), bpp::WordAlphabet::getWord(), bpp::BinaryAlphabet::isResolvedIn(), and bpp::NucleicAlphabet::subtract().
double NumericAlphabet::intToValue | ( | int | state | ) | const |
Returns the value for the character number.
Definition at line 140 of file NumericAlphabet.cpp.
References bpp::AbstractAlphabet::getState().
|
virtualinherited |
Tell if a state (specified by its string description) is allowed by the the alphabet.
state | The string description. |
Implements bpp::Alphabet.
Reimplemented in bpp::LetterAlphabet.
Definition at line 177 of file AbstractAlphabet.cpp.
Referenced by bpp::BinaryAlphabet::getAlias(), bpp::RNY::getAlias(), bpp::AllelicAlphabet::getAlias(), and bpp::WordAlphabet::getAlias().
|
inlinevirtualinherited |
state | The state to test. |
Implements bpp::Alphabet.
Definition at line 132 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::charToInt().
|
virtual |
state | The state to test. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 91 of file NumericAlphabet.cpp.
|
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 167 of file AbstractAlphabet.cpp.
Referenced by bpp::BinaryAlphabet::getAlias(), bpp::RNY::getAlias(), bpp::AllelicAlphabet::getAlias(), bpp::WordAlphabet::getAlias(), bpp::CaseMaskedAlphabet::getMaskedEquivalentState(), bpp::BinaryAlphabet::isResolvedIn(), bpp::RNY::isResolvedIn(), bpp::AllelicAlphabet::isResolvedIn(), and bpp::WordAlphabet::isResolvedIn().
|
virtualinherited |
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
state1 | The alias to resolve. |
state2 | The candidate for resolution. |
BadIntException | When state is not a valid integer. |
Implements bpp::Alphabet.
Reimplemented in bpp::WordAlphabet, bpp::CodonAlphabet, bpp::AllelicAlphabet, bpp::RNY, bpp::RNA, bpp::ProteicAlphabet, bpp::DNA, and bpp::BinaryAlphabet.
Definition at line 187 of file AbstractAlphabet.cpp.
|
virtual |
state | The state to test. |
Implements bpp::Alphabet.
Definition at line 101 of file NumericAlphabet.cpp.
|
virtual |
state | The state to test. |
Implements bpp::Alphabet.
Definition at line 106 of file NumericAlphabet.cpp.
NumericAlphabet & NumericAlphabet::operator= | ( | const NumericAlphabet & | na | ) |
Definition at line 36 of file NumericAlphabet.cpp.
References bpp::UniformDiscreteDistribution::clone(), bpp::AbstractAlphabet::operator=(), and pdd_.
|
virtual |
Add a state to the Alphabet.
st | The state to add. |
Exception | If a wrong alphabet state is provided. |
Reimplemented from bpp::AbstractAlphabet.
Definition at line 60 of file NumericAlphabet.cpp.
References getSize(), bpp::AbstractAlphabet::registerState(), and values_.
Referenced by NumericAlphabet().
void NumericAlphabet::remap | ( | ) |
Re-update the maps.
Definition at line 121 of file NumericAlphabet.cpp.
References getSize(), getStateAt(), bpp::AlphabetNumericState::getValue(), bpp::AbstractAlphabet::remap(), and values_.
|
inlineprotectedinherited |
Resize the private alphabet_ vector.
size | The new size of the Alphabet. |
Definition at line 226 of file AbstractAlphabet.h.
References bpp::AbstractAlphabet::alphabet_.
|
virtual |
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.
Definition at line 45 of file NumericAlphabet.cpp.
References bpp::AbstractAlphabet::setState(), and values_.
|
privateinherited |
Update the private maps letters_ and nums_ when adding a state.
pos | The index of the state in the alphabet_ vector. |
st | The state that has been added or modified |
Definition at line 22 of file AbstractAlphabet.cpp.
References bpp::AlphabetState::getLetter(), and bpp::AlphabetState::getNum().
Referenced by bpp::AbstractAlphabet::remap().
|
privateinherited |
Alphabet: vector of AlphabetState.
Definition at line 37 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::AbstractAlphabet(), bpp::AbstractAlphabet::getNumberOfChars(), bpp::AbstractAlphabet::getNumberOfStates(), bpp::AbstractAlphabet::operator=(), bpp::AbstractAlphabet::remap(), bpp::AbstractAlphabet::resize(), and bpp::AbstractAlphabet::~AbstractAlphabet().
|
mutableprotectedinherited |
Definition at line 63 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=().
|
mutableprotectedinherited |
Definition at line 64 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=().
|
privateinherited |
Definition at line 43 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=(), and bpp::AbstractAlphabet::remap().
|
privateinherited |
Definition at line 44 of file AbstractAlphabet.h.
Referenced by bpp::AbstractAlphabet::operator=(), and bpp::AbstractAlphabet::remap().
|
private |
Definition at line 24 of file NumericAlphabet.h.
Referenced by getDelta(), getValueIndex(), NumericAlphabet(), operator=(), and ~NumericAlphabet().
|
private |
Definition at line 26 of file NumericAlphabet.h.
Referenced by getNumberOfTypes(), getSize(), getValueIndex(), registerState(), remap(), and setState().