44 if (exclamationMarkCountsAsGap)
54 if (state1 < 0 || !isIntInAlphabet(state1))
55 throw BadIntException(state1,
"AbstractAlphabet::isResolvedIn(int, int): Specified base " + intToChar(state1) +
" is unknown.",
this);
57 if (state2 < 0 || !isIntInAlphabet(state2))
58 throw BadIntException(state2,
"AbstractAlphabet::isResolvedIn(int, int): Specified base " + intToChar(state2) +
" is unknown.",
this);
60 if (isUnresolved(state2))
61 throw BadIntException(state2,
"AbstractAlphabet::isResolvedIn(int, int): Unresolved base " + intToChar(state2),
this);
79 throw BadIntException(state2,
"DNA::isResolvedIn : this should not happen",
this);
87 if (!isIntInAlphabet(state))
88 throw BadIntException(state,
"DNA::getAlias(int): Specified base unknown.",
this);
110 if (!isCharInAlphabet(locstate))
111 throw BadCharException(locstate,
"DNA::getAlias(int): Specified base unknown.",
this);
112 vector<int> vi = this->getAlias(this->charToInt(state));
114 for (
unsigned int i = 0; i < vi.size(); i++)
116 v.push_back(this->intToChar(vi[i]));
126 for (
size_t i = 0; i < states.size(); ++i)
128 if (!isIntInAlphabet(states[i]))
129 throw BadIntException(states[i],
"DNA::getGeneric(const vector<int>& states): Specified base unknown.",
this);
130 v |= getState(states[i]).getBinaryCode();
132 return getStateByBinCode(v).getNum();
140 for (
unsigned int i = 0; i < states.size(); ++i)
142 if (!isCharInAlphabet(states[i]))
143 throw BadCharException(states[i],
"DNA::getGeneric(const vector<string>& states): Specified base unknown.",
this);
144 vi.push_back(this->charToInt(states[i]));
146 return intToChar(getGeneric(vi));
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.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
DNA(bool exclamationMarkCountsAsGap=false)
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.
This is the base class to describe states in a NucleicAlphabet.
int getBinaryCode() const
Get the state's binary representation.
std::string toUpper(const std::string &s)
This alphabet is used to deal NumericAlphabet.