5 #ifndef BPP_SEQ_ALPHABET_ABSTRACTALPHABET_H
6 #define BPP_SEQ_ALPHABET_ABSTRACTALPHABET_H
72 for (
size_t i = 0; i < alph.
alphabet_.size(); ++i)
80 for (
size_t i = 0; i <
alphabet_.size(); ++i)
85 for (
size_t i = 0; i < alph.
alphabet_.size(); ++i)
102 for (
size_t i = 0; i <
alphabet_.size(); ++i)
116 std::string
getName(
const std::string& state)
const;
117 std::string
getName(
int state)
const;
118 int charToInt(
const std::string& state)
const;
123 std::vector<int>
getAlias(
int state)
const;
124 std::vector<std::string>
getAlias(
const std::string& state)
const;
125 int getGeneric(
const std::vector<int>& states)
const;
126 std::string
getGeneric(
const std::vector<std::string>& states)
const;
131 bool isGap(
int state)
const {
return state == -1; }
235 for (
size_t i = 0; i <
alphabet_.size(); ++i)
A partial implementation of the Alphabet interface.
bool equals(const Alphabet &alphabet) const
Comparison of alphabets.
AbstractAlphabet(const AbstractAlphabet &alph)
int getIntCodeAt(size_t stateIndex) const
std::vector< AlphabetState * > alphabet_
Alphabet: vector of AlphabetState.
virtual ~AbstractAlphabet()
std::string getName(const std::string &state) const
Get the complete name of a state given its string description.
const std::vector< int > & getSupportedInts() const
virtual AbstractAlphabet * clone() const =0
void resize(size_t size)
Resize the private alphabet_ vector.
void updateMaps_(size_t pos, const AlphabetState &st)
Update the private maps letters_ and nums_ when adding a state.
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
const std::vector< std::string > & getResolvedChars() const
unsigned int getNumberOfChars() const
Get the number of supported characters in this alphabet, including generic characters (e....
AbstractAlphabet & operator=(const AbstractAlphabet &alph)
const AlphabetState & getState(const std::string &letter) const
Get a state by its letter.
virtual void setState(size_t pos, AlphabetState *st)
Set a state in the Alphabet.
std::string intToChar(int state) const
Give the string description of a state given its int description.
const std::vector< std::string > & getSupportedChars() const
std::map< int, size_t > nums_
bool isGap(const std::string &state) const
size_t getNumberOfStates() const
This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.
size_t getStateIndex(int state) const
virtual void registerState(AlphabetState *st)
Add a state to the Alphabet.
bool isGap(int state) const
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
int getGapCharacterCode() const
unsigned int getStateCodingSize() const
Get the size of the string coding a state.
std::vector< std::string > charList_
std::vector< int > intList_
bool isResolvedIn(int state1, int state2) const
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
std::map< std::string, size_t > letters_
void remap()
Re-update the maps using the alphabet_ vector content.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
const std::string & getCharCodeAt(size_t stateIndex) const
bool isIntInAlphabet(int state) const
Tell if a state (specified by its int description) is allowed by the the alphabet.
bool isCharInAlphabet(const std::string &state) const
Tell if a state (specified by its string description) is allowed by the the alphabet.
This is the base class to describe states in an Alphabet.
const std::string & getLetter() const
Get the letter(s) corresponding to the state.
int getNum() const
Get the state's number.
virtual std::string getAlphabetType() const =0
Identification method.
This alphabet is used to deal NumericAlphabet.