40 #ifndef _WORDALPHABET_H_ 41 #define _WORDALPHABET_H_ 49 #include "../Sequence.h" 82 WordAlphabet(
const std::vector<const Alphabet*>& vAlpha);
132 return static_cast<int>(
getSize());
158 return static_cast<unsigned int>(
vAbsAlph_.size());
175 return static_cast<int>(
getSize());
213 throw IndexOutOfBoundsException(
"WordAlphabet::getNPosition", n, 0,
vAbsAlph_.size());
227 virtual int getWord(
const std::vector<int>& vint,
size_t pos = 0)
const throw (IndexOutOfBoundsException);
251 throw IndexOutOfBoundsException(
"WordAlphabet::getNPosition", n, 0,
vAbsAlph_.size());
254 return vAbsAlph_[n]->charToInt(s.substr(n, 1));
267 std::vector<int> positions;
268 for (
size_t i = 0; i < s.size(); i++)
289 return "" + word.substr(n, 1);
303 std::vector<std::string> positions;
304 for (
size_t i = 0; i < word.size(); i++)
306 positions.push_back(word.substr(i, 1));
344 #endif // _WORDALPHABET_H_ An alphabet exception thrown when trying to specify a bad char to the alphabet.
Sequence * reverse(const Sequence &sequence) const
Translate a whole sequence from words alphabet to letters alphabet.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
const Alphabet * getNAlphabet(size_t n) const
Get the pointer to the Alphabet of the n-position.
bool containsUnresolved(const std::string &state) const
This alphabet is used to deal NumericAlphabet.
WordAlphabet * clone() const
Sequence * translate(const Sequence &sequence, size_t=0) const
Translate a whole sequence from letters alphabet to words alphabet.
unsigned int getLength() const
Returns the length of the word.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
int getNPosition(int word, size_t n) const
Get the int code of the n-position of a word given its int description.
AbstractAlphabet & operator=(const AbstractAlphabet &alph)
The base class for word alphabets.
bool isUnresolved(const std::string &state) const
WordAlphabet & operator=(const WordAlphabet &bia)
std::string getAlphabetType() const
Identification method.
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.
WordAlphabet(const std::vector< const Alphabet *> &vAlpha)
Builds a new word alphabet from a vector of Alphabets.
unsigned int getStateCodingSize() const
Get the size of the string coding a state.
std::vector< int > getPositions(int word) const
Get the int codes of each position of a word given its int description.
std::string getNPosition(const std::string &word, size_t n) const
Get the char code of the n-position of a word given its char description.
bool containsGap(const std::string &state) const
WordAlphabet(const WordAlphabet &bia)
std::vector< const Alphabet *> vAbsAlph_
A partial implementation of the Alphabet interface.
virtual int getWord(const std::vector< int > &vint, size_t pos=0) const
Get the int code for a word given the int code of the underlying positions.
bool isUnresolved(int state) const
An alphabet exception thrown when trying to specify a bad int to the alphabet.
unsigned int getNumberOfTypes() const
Returns the number of resolved states + one for unresolved.
int getUnknownCharacterCode() const
Exception thrown when two alphabets do not match.
bool hasUniqueAlphabet() const
Returns True if the Alphabet of the letters in the word are the same type.
std::vector< std::string > getPositions(const std::string &word) const
Get the char codes of each position of a word given its char description.
std::string getName(const std::string &state) const
Get the complete name of a state given its string description.
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...
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.