58 return getState(aa).getAbbreviation();
65 return getState(aa).getAbbreviation();
72 if (!isIntInAlphabet(state1))
73 throw BadIntException(state1,
"DNA::isResolvedIn(int, int): Specified base unknown.",
this);
75 if (!isIntInAlphabet(state2))
76 throw BadIntException(state2,
"DNA::isResolvedIn(int, int): Specified base unknown.",
this);
78 if (isUnresolved(state2))
79 throw BadIntException(state2,
"DNA::isResolvedIn(int, int): Unresolved base.",
this);
82 return state2 == 2 || state2 == 3;
83 else if (state1 == 21)
84 return state2 == 5 || state2 == 6;
85 else if (state1 == 22)
86 return state2 == 9 || state2 == 10;
87 else if (state1 == 23)
90 return state1 == state2;
98 if (!isIntInAlphabet(state))
99 throw BadIntException(state,
"ProteicAlphabet::getAlias(int): Specified base unknown.",
this);
103 v.resize(2); v[0] = 2; v[1] = 3;
105 else if (state == 21)
107 v.resize(2); v[0] = 5; v[1] = 6;
109 else if (state == 22)
111 v.resize(2); v[0] = 9; v[1] = 10;
113 else if (state == 23)
116 for (
size_t i = 0; i < 20; i++)
118 v[i] =
static_cast<int>(i);
123 v.resize(1); v[0] = state;
133 if (!isCharInAlphabet(locstate))
134 throw BadCharException(locstate,
"ProteicAlphabet::getAlias(int): Specified base unknown.",
this);
138 v.resize(2); v[0] =
"N"; v[1] =
"D";
140 else if (locstate ==
"Z")
142 v.resize(2); v[0] =
"Q"; v[1] =
"E";
144 else if (locstate ==
"J")
146 v.resize(2); v[0] =
"I"; v[1] =
"L";
148 else if (locstate ==
"X"
154 for (
int i = 0; i < 20; i++)
156 v[
static_cast<size_t>(i)] = getState(i).getLetter();
161 v.resize(1); v[0] = locstate;
171 for (
size_t i = 0; i < states.size(); ++i)
173 vector<int> tmp_s = this->getAlias(states[i]);
174 for (
size_t j = 0; j < tmp_s.size(); ++j)
182 for (
size_t i = 0; i < ve.size(); ++i)
184 if (!isIntInAlphabet(ve[i]))
185 throw BadIntException(ve[i],
"ProteicAlphabet::getGeneric(const vector<int>): Specified base unknown.",
this);
193 map<string, int>::iterator it = g.find(key);
198 else if (it != g.end())
214 for (
size_t i = 0; i < states.size(); ++i)
216 vector<string> tmp_s = this->getAlias(states[i]);
217 for (
size_t j = 0; j < tmp_s.size(); ++j)
225 for (
size_t i = 0; i < ve.size(); ++i)
227 if (!isCharInAlphabet(ve[i]))
228 throw BadCharException(ve[i],
"ProteicAlphabet::getAlias(const vector<string>): Specified base unknown.",
this);
231 map<string, string> g;
236 map<string, string>::iterator it = g.find(key);
241 else if (it != g.end())
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.
This is the base class to describe states in a ProteicAlphabet.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
bool isResolvedIn(int state1, int state2) const
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
std::string getAbbr(const std::string &aa) const
Get the abbreviation (3 letter code) for a state coded as char.
std::string toUpper(const std::string &s)
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.