42 #ifndef _ABSTRACTALPHABET_H_ 43 #define _ABSTRACTALPHABET_H_ 47 #include <Bpp/Exceptions.h> 109 for (
size_t i = 0; i < alph.
alphabet_.size(); ++i)
115 for (
size_t i = 0 ; i <
alphabet_.size() ; ++i)
118 for (
size_t i = 0; i < alph.
alphabet_.size(); ++i)
129 #ifndef NO_VIRTUAL_COV 135 for (
size_t i = 0 ; i <
alphabet_.size() ; ++i)
160 bool isGap(
int state)
const {
return state == -1; }
216 int getIntCodeAt(
size_t stateIndex)
const throw (IndexOutOfBoundsException) {
220 const std::string&
getCharCodeAt(
size_t stateIndex)
const throw (IndexOutOfBoundsException) {
261 for (
size_t i = 0; i <
alphabet_.size(); ++i) {
275 #endif // _ABSTRACTALPHABET_H_ This is the base class to describe states in an Alphabet.
AbstractAlphabet(const AbstractAlphabet &alph)
An alphabet exception thrown when trying to specify a bad char to the alphabet.
int getNum() const
Get the state's number.
This alphabet is used to deal NumericAlphabet.
void updateMaps_(size_t pos, const AlphabetState &st)
Update the private maps letters_ and nums_ when adding a state.
std::map< std::string, size_t > letters_
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
bool isIntInAlphabet(int state) const
Tell if a state (specified by its int description) is allowed by the the alphabet.
const std::vector< std::string > & getSupportedChars() const
bool isGap(int state) const
virtual ~AbstractAlphabet()
AbstractAlphabet & operator=(const AbstractAlphabet &alph)
const AlphabetState & getState(const std::string &letter) const
Get a state by its letter.
int getIntCodeAt(size_t stateIndex) const
const std::string & getCharCodeAt(size_t stateIndex) const
size_t getNumberOfStates() const
This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int...
virtual AbstractAlphabet * clone() const =0
std::vector< std::string > charList_
virtual void setState(size_t pos, AlphabetState *st)
Set a state in the Alphabet.
The alphabet exception base class.
std::vector< AlphabetState * > alphabet_
Alphabet: vector of AlphabetState.
A partial implementation of the Alphabet interface.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
std::map< int, size_t > nums_
const std::string & getLetter() const
Get the letter(s) corresponding to the state.
int getGapCharacterCode() const
bool isGap(const std::string &state) const
std::string getName(const std::string &state) const
Get the complete name of a state given its string description.
bool isCharInAlphabet(const std::string &state) const
Tell if a state (specified by its string description) is allowed by the the alphabet.
bool equals(const Alphabet &alphabet) const
Comparison of alphabets.
void resize(size_t size)
Resize the private alphabet_ vector.
void remap()
Re-update the maps using the alphabet_ vector content.
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
std::vector< int > intList_
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
virtual void registerState(AlphabetState *st)
Add a state to the Alphabet.
const std::vector< int > & getSupportedInts() const
unsigned int getStateCodingSize() const
Get the size of the string coding a state.
std::string intToChar(int state) const
Give the string description of a state given its int description.
unsigned int getNumberOfChars() const
Get the number of supported characters in this alphabet, including generic characters (e...
size_t getStateIndex(int state) const
virtual std::string getAlphabetType() const =0
Identification method.