17 RNY::RNY( std::shared_ptr<const NucleicAlphabet> na) : nuclalph_(na)
20 vector<AlphabetState*> states(351,
nullptr);
44 for (
size_t i = 0; i < 3; ++i)
46 for (
size_t j = 0; j < 4; ++j)
48 for (
size_t k = 0; k < 3; ++k)
50 size_t l = i * 12 + j * 3 + k;
61 for (
size_t i = 0; i < 3; ++i)
63 for (
size_t j = 0; j < 4; ++j)
65 size_t l = 50 + 12 * i + j * 3;
75 for (
size_t i = 0; i < 3; ++i)
77 for (
size_t k = 0; k < 3; ++k)
79 size_t l = 100 + 12 * i + k;
89 for (
size_t i = 0; i < 3; ++i)
91 size_t l = 150 + 12 * i;
100 for (
size_t j = 0; j < 4; ++j)
102 for (
size_t k = 0; k < 3; ++k)
104 size_t l = 200 + j * 3 + k;
115 for (
size_t j = 0; j < 4; ++j)
117 size_t l = 250 + 3 * j;
126 for (
size_t k = 0; k < 3; ++k)
144 for (
size_t i = 0; i < states.size(); ++i)
156 throw BadIntException(state,
"RNY::getAlias(int): Specified base unknown.",
this);
171 for (k = 0; k < 3; ++k)
173 v[
static_cast<size_t>(k)] = k + rs;
178 for (j = 0; j < 4; ++j)
180 v[
static_cast<size_t>(j)] = 3 * j + rs;
185 for (j = 0; j < 4; ++j)
187 for (k = 0; k < 3; ++k)
189 v[
static_cast<size_t>(3 * j + k)] = rs + 3 * j + k;
195 for (i = 0; i < 3; ++i)
197 v[
static_cast<size_t>(i)] = 12 * i + rs;
202 for (i = 0; i < 3; ++i)
204 for (k = 0; k < 3; ++k)
206 v[
static_cast<size_t>(3 * i + k)] = rs + 12 * i + k;
212 for (i = 0; i < 3; ++i)
214 for (j = 0; j < 4; ++j)
216 v[
static_cast<size_t>(4 * i + j)] = rs + 12 * i + 3 * j;
222 for (i = 0; i < 3; ++i)
224 for (j = 0; j < 4; ++j)
226 for (k = 0; k < 3; ++k)
228 v[
static_cast<size_t>(12 * i + 3 * j + k)] = 12 * i + 3 * j + k;
242 throw BadIntException(state1,
"RNY::isResolvedIn(int, int): Specified base unknown.",
this);
245 throw BadIntException(state2,
"RNY::isResolvedIn(int, int): Specified base unknown.",
this);
248 throw BadIntException(state2,
"RNY::isResolvedIn(int, int): Unresolved base.",
this);
250 int qs = state1 / 50;
251 int rs = state1 % 50;
258 return (state2 < rs + 3) && (state2 >= rs);
260 return (state2 - rs) % 3 == 0 && (state2 >= rs) && (state2 < rs + 12);
262 return (state2 >= rs) && (state2 < rs + 12);
264 return (state2 - rs) % 12 == 0 && (state2 >= rs) && (state2 < rs + 36);
266 return (state2 - rs) % 12 < 3 && (state2 >= rs) && (state2 < rs + 27);
268 return (state2 - rs) % 3 == 0 && (state2 >= rs) && (state2 < rs + 36);
272 throw BadIntException(state1,
"RNY:isResolvedIn : this should not happen.",
this);
281 throw BadCharException(state,
"RNY::getAlias(int): Specified base unknown.",
this);
285 size_t size = v.size();
288 for (
size_t i = 0; i < size; i++)
297 string RNY::getRNY(
const string& pos1,
const string& pos2,
const string& pos3)
const
301 if (pos1 ==
"A" || pos1 ==
"G")
308 if (pos3 ==
"T" || pos3 ==
"U" || pos3 ==
"C")
352 throw BadCharException(&li,
"RNY::getRNY(int,int;int,alph): Specified base unknown.",
this);
378 throw BadCharException(&lj,
"RNY::getRNY(int,int;int,alph): Specified base unknown.",
this);
402 throw BadCharException(&lk,
"RNY::getRNY(int,int;int,alph): Specified base unknown.",
this);
416 return state.find(
"-") != string::npos;
426 return state >= 50 && state != 350;
433 if (state.size() != 3)
445 for (i = 0; i < 3; ++i)
447 for (j = 0; j < 4; ++j)
449 for (k = 0; k < 3; ++k)
451 l = i * 12 + j * 3 + k;
460 for (i = 0; i < 3; ++i)
462 for (j = 0; j < 4; ++j)
464 l = 50 + 12 * i + j * 3;
472 for (i = 0; i < 3; ++i)
474 for (k = 0; k < 3; ++k)
476 l = 100 + 12 * i + k;
484 for (i = 0; i < 3; ++i)
493 for (j = 0; j < 4; ++j)
495 for (k = 0; k < 3; ++k)
506 for (j = 0; j < 4; ++j)
515 for (k = 0; k < 3; ++k)
529 throw BadIntException(state,
"RNY::intToChar: Specified base unknown",
this);
const AlphabetState & getState(const std::string &letter) const
Get a state by its letter.
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.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
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.
The alphabet exception base class.
This is the base class to describe states in an Alphabet.
const std::string & getLetter() const
Get the letter(s) corresponding to the state.
virtual std::string intToChar(int state) const =0
Give the string description of a state given its int description.
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.
bool isGap(int state) const
bool containsGap(const std::string &state) const
bool isUnresolved(int state) const
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
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.
bool isResolvedIn(int state1, int state2) const
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
This alphabet is used to deal NumericAlphabet.