43 #include <Bpp/Text/TextTools.h> 55 vector<AlphabetState*> states;
56 for (
int i = 0; i < 351; ++i)
58 states.push_back(
new AlphabetState(i, TextTools::toString(i),
""));
83 for (
size_t i = 0; i < 3; ++i)
85 for (
size_t j = 0; j < 4; ++j)
87 for (
size_t k = 0; k < 3; ++k)
89 size_t l = i * 12 + j * 3 + k;
100 for (
size_t i = 0; i < 3; ++i)
102 for (
size_t j = 0; j < 4; ++j)
104 size_t l = 50 + 12 * i + j * 3;
114 for (
size_t i = 0; i < 3; ++i)
116 for (
size_t k = 0; k < 3; ++k)
118 size_t l = 100 + 12 * i + k;
128 for (
size_t i = 0; i < 3; ++i)
130 size_t l = 150 + 12 * i;
139 for (
size_t j = 0; j < 4; ++j)
141 for (
size_t k = 0; k < 3; ++k)
143 size_t l = 200 + j * 3 + k;
154 for (
size_t j = 0; j < 4; ++j)
156 size_t l = 250 + 3 * j;
165 for (
size_t k = 0; k < 3; ++k)
183 for (
size_t i = 0; i < states.size(); ++i)
191 if (!isIntInAlphabet(state))
192 throw BadIntException(state,
"RNY::getAlias(int): Specified base unknown.");
207 for (k = 0; k < 3; ++k)
209 v[
static_cast<size_t>(k)] = k + rs;
214 for (j = 0; j < 4; ++j)
216 v[
static_cast<size_t>(j)] = 3 * j + rs;
221 for (j = 0; j < 4; ++j)
223 for (k = 0; k < 3; ++k)
225 v[
static_cast<size_t>(3 * j + k)] = rs + 3 * j + k;
231 for (i = 0; i < 3; ++i)
233 v[
static_cast<size_t>(i)] = 12 * i + rs;
238 for (i = 0; i < 3; ++i)
240 for (k = 0; k < 3; ++k)
242 v[
static_cast<size_t>(3 * i + k)] = rs + 12 * i + k;
248 for (i = 0; i < 3; ++i)
250 for (j = 0; j < 4; ++j)
252 v[
static_cast<size_t>(4 * i + j)] = rs + 12 * i + 3 * j;
258 for (i = 0; i < 3; ++i)
260 for (j = 0; j < 4; ++j)
262 for (k = 0; k < 3; ++k)
264 v[
static_cast<size_t>(12 * i + 3 * j + k)] = 12 * i + 3 * j + k;
282 if (!isCharInAlphabet(state))
283 throw BadCharException(state,
"RNY::getAlias(int): Specified base unknown.");
285 vector<int> v = getAlias(charToInt(state));
287 size_t size = v.size();
290 for (
size_t i = 0; i < size; i++)
303 if (pos1 ==
"A" || pos1 ==
"G")
310 if (pos3 ==
"T" || pos3 ==
"U" || pos3 ==
"C")
329 char li = alph.intToChar(i)[0];
330 char lj = alph.intToChar(j)[0];
331 char lk = alph.intToChar(k)[0];
354 throw BadCharException(&li,
"RNY::getRNY(int,int;int,alph): Specified base unknown.");
380 throw BadCharException(&lj,
"RNY::getRNY(int,int;int,alph): Specified base unknown.");
404 throw BadCharException(&lk,
"RNY::getRNY(int,int;int,alph): Specified base unknown.");
418 return state.find(
"-") != string::npos;
428 return state >= 50 && state != 350;
435 if (state.size() != 3)
447 for (i = 0; i < 3; ++i)
449 for (j = 0; j < 4; ++j)
451 for (k = 0; k < 3; ++k)
453 l = i * 12 + j * 3 + k;
454 if (getState(l).getNum() == state)
455 return getState(l).getLetter();
462 for (i = 0; i < 3; ++i)
464 for (j = 0; j < 4; ++j)
466 l = 50 + 12 * i + j * 3;
467 if (getState(l).getNum() == state)
468 return getState(l).getLetter();
474 for (i = 0; i < 3; ++i)
476 for (k = 0; k < 3; ++k)
478 l = 100 + 12 * i + k;
479 if (getState(l).getNum() == state)
480 return getState(l).getLetter();
486 for (i = 0; i < 3; ++i)
489 if (getState(l).getNum() == state)
490 return getState(l).getLetter();
495 for (j = 0; j < 4; ++j)
497 for (k = 0; k < 3; ++k)
500 if (getState(l).getNum() == state)
501 return getState(l).getLetter();
508 for (j = 0; j < 4; ++j)
511 if (getState(l).getNum() == state)
512 return getState(l).getLetter();
517 for (k = 0; k < 3; ++k)
520 if (getState(l).getNum() == state)
521 return getState(l).getLetter();
528 if (getState(l).getNum() == state)
529 return getState(l).getLetter();
531 throw BadIntException(state,
"RNY::intToChar: Specified base unknown",
this);
This is the base class to describe states in an Alphabet.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
bool isGap(int state) const
const NucleicAlphabet & getLetterAlphabet() const
This alphabet is used to deal NumericAlphabet.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
const NucleicAlphabet & nuclalph_
bool containsGap(const std::string &state) const
bool isUnresolved(int state) const
The alphabet exception base class.
std::string intToChar(int state) const
Give the string description of a state given its int description.
std::string getRNY(const std::string &, const std::string &, const std::string &) const
Get the char code for a triplet given the char code of the three underlying positions.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual void registerState(AlphabetState *st)
Add a state to the Alphabet.
The abstract base class for nucleic alphabets.
std::string intToChar(int state) const
Give the string description of a state given its int description.