27 for (
size_t i = 0; i < num; i++)
39 for (
size_t i = 0; i <
vAbsAlph_.size(); ++i)
44 vector<AlphabetState*> states(size + 2);
47 for (
size_t i = 0; i <
vAbsAlph_.size(); ++i)
54 for (
size_t i = 0; i < size; ++i)
56 states[i + 1] =
new AlphabetState(
static_cast<int>(i),
"",
"");
61 for (
size_t na = 0; na <
vAbsAlph_.size(); ++na)
70 for (
size_t k = 0; k < lr; k++)
72 states[j]->setLetter(states[j]->getLetter() + c);
83 for (
size_t i = 0; i <
vAbsAlph_.size(); ++i)
88 states[size + 1] =
new AlphabetState(
static_cast<int>(size), s,
"Unresolved");
91 for (
size_t i = 0; i < states.size(); ++i)
102 for (
unsigned int i = 0; i <
vAbsAlph_.size(); i++)
117 string s =
vAbsAlph_[0]->getAlphabetType();
118 for (
unsigned int i = 1; i <
vAbsAlph_.size(); i++)
129 if (state.length() != s)
132 for (
size_t i = 0; i <
vAbsAlph_.size(); i++)
147 if (state.length() != s)
150 for (
size_t i = 0; i <
vAbsAlph_.size(); i++)
178 throw BadIntException(state1,
"WordAlphabet::isResolvedIn(int, int): Specified base unknown.",
this);
181 throw BadIntException(state2,
"WordAlphabet::isResolvedIn(int, int): Specified base unknown.",
this);
184 throw BadIntException(state2,
"WordAlphabet::isResolvedIn(int, int): Unresolved base.",
this);
186 return (state1 == (
int)
getSize()) ? (state2 >= 0) : (state1 == state2);
194 throw BadIntException(state,
"WordAlphabet::getAlias(int): Specified base unknown.",
this);
198 if (
static_cast<size_t>(state) == s)
201 for (
size_t i = 0; i < s; ++i)
203 v[i] =
static_cast<int>(i);
208 v.resize(1); v[0] = state;
219 throw BadCharException(locstate,
"WordAlphabet::getAlias(string): Specified base unknown.",
this);
225 for (
size_t i = 0; i <
vAbsAlph_.size(); ++i)
233 for (
size_t i = 0; i < s; ++i)
240 v.resize(1); v[0] = state;
267 for (
size_t i = 0; i <
vAbsAlph_.size(); i++)
280 if (vint.size() < pos +
vAbsAlph_.size())
284 for (
size_t i = 0; i <
vAbsAlph_.size(); i++)
296 if (vpos.size() < pos +
vAbsAlph_.size())
300 for (
size_t i = 0; i <
vAbsAlph_.size(); i++)
319 size_t s = sequence.
size();
325 content.push_back(
getWord(sequence, i));
329 auto alphaPtr = shared_from_this();
330 return make_unique<Sequence>(sequence.
getName(), content, alphaPtr);
342 auto seqPtr = make_unique<Sequence>(sequence.
getName(),
"", alphaPtr);
344 size_t s = sequence.
size();
345 for (
size_t i = 0; i < s; i++)
A partial implementation of the Alphabet interface.
std::string getName(const std::string &state) const
Get the complete name of a state given its string description.
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
std::string intToChar(int state) const
Give the string description of a state given its int description.
virtual void registerState(AlphabetState *st)
Add a state to the Alphabet.
bool isGap(int state) 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.
size_t size() const override
Get the number of elements in the list.
Exception thrown when two alphabets do not match.
This is the base class to describe states in an Alphabet.
const std::string & getName() const
Get the name of the state.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual const std::string & getName() const =0
Get the name of this sequence.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to the list.
virtual size_t size() const =0
Get the number of elements in the list.
A basic implementation of the Sequence interface.
bool isUnresolved(int state) const override
unsigned int getLength() const override
Returns the length of the word.
bool containsGap(const std::string &state) const override
bool containsUnresolved(const std::string &state) const override
virtual int getWord(const Sequence &seq, size_t pos=0) const override
Get the int code for a word given the int code of the underlying positions.
std::vector< std::shared_ptr< const Alphabet > > vAbsAlph_
std::vector< int > getAlias(int state) const override
Get all resolved states that match a generic state.
bool isResolvedIn(int state1, int state2) const override
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
bool hasUniqueAlphabet() const override
Returns True if the Alphabet of the letters in the word are the same type.
std::string getAlphabetType() const override
Identification method.
int getGeneric(const std::vector< int > &states) const override
Get the generic state that match a set of states.
std::unique_ptr< SequenceInterface > translate(const SequenceInterface &sequence, size_t=0) const override
Translate a whole sequence from letters alphabet to words alphabet.
std::unique_ptr< SequenceInterface > reverse(const SequenceInterface &sequence) const override
Translate a whole sequence from words alphabet to letters alphabet.
WordAlphabet(const std::vector< std::shared_ptr< const Alphabet >> &vAlpha)
Builds a new word alphabet from a vector of Alphabets.
int charToInt(const std::string &state) const override
Give the int description of a state given its string description.
unsigned int getSize() const override
std::vector< int > getPositions(int word) const override
Get the int codes of each position of a word given its int description.
std::string getName(const std::string &state) const override
Get the complete name of a state given its string description.
std::shared_ptr< const Alphabet > getNAlphabet(size_t n) const override
Get the pointer to the Alphabet at the n-position.
std::string toUpper(const std::string &s)
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.