44 #include <Bpp/Text/TextTools.h> 45 #include <Bpp/Utils/MapTools.h> 92 string AA = TextTools::toUpper(aa);
93 return getState(aa).getAbbreviation();
100 return getState(aa).getAbbreviation();
107 if (!isIntInAlphabet(state))
108 throw BadIntException(state,
"ProteicAlphabet::getAlias(int): Specified base unknown.");
112 v.resize(2); v[0] = 2; v[1] = 3;
114 else if (state == 21)
116 v.resize(2); v[0] = 5; v[1] = 6;
118 else if (state == 22)
121 for (
size_t i = 0; i < 20; i++)
123 v[i] =
static_cast<int>(i);
128 v.resize(1); v[0] = state;
137 string locstate = TextTools::toUpper(state);
138 if (!isCharInAlphabet(locstate))
139 throw BadCharException(locstate,
"ProteicAlphabet::getAlias(int): Specified base unknown.");
143 v.resize(2); v[0] =
"N"; v[1] =
"D";
145 else if (locstate ==
"Z")
147 v.resize(2); v[0] =
"Q"; v[1] =
"E";
149 else if (locstate ==
"X" 155 for (
int i = 0; i < 20; i++)
157 v[
static_cast<size_t>(i)] = getState(i).getLetter();
162 v.resize(1); v[0] = locstate;
172 for (
unsigned int i = 0; i < states.size(); ++i)
174 vector<int> tmp_s = this->getAlias(states[i]);
175 for (
unsigned int j = 0; j < tmp_s.size(); ++j)
180 vector<int> ve = MapTools::getKeys(m);
183 for (
unsigned int i = 0; i < ve.size(); ++i)
185 if (!isIntInAlphabet(ve[i]))
186 throw BadIntException(ve[i],
"ProteicAlphabet::getGeneric(const vector<int>): Specified base unknown.");
187 key +=
"_" + TextTools::toString(ve[i]);
193 map<string, int>::iterator it = g.find(key);
198 else if (it != g.end())
214 for (
unsigned int i = 0; i < states.size(); ++i)
216 vector<string> tmp_s = this->getAlias(states[i]);
217 for (
unsigned int j = 0; j < tmp_s.size(); ++j)
222 vector<string> ve = MapTools::getKeys(m);
225 for (
unsigned int i = 0; i < ve.size(); ++i)
227 if (!isCharInAlphabet(ve[i]))
228 throw BadCharException(ve[i],
"ProteicAlphabet::getAlias(const vector<string>): Specified base unknown.");
229 key += TextTools::toString(ve[i]);
231 map<string, string> g;
235 map<string, string>::iterator it = g.find(key);
240 else if (it != g.end())
An alphabet exception thrown when trying to specify a bad char to the alphabet.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
This alphabet is used to deal NumericAlphabet.
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
std::string getAbbr(const std::string &aa) const
Get the abbreviation (3 letter code) for a state coded as char.
This is the base class to describe states in a ProteicAlphabet.
The alphabet exception base class.
An alphabet exception thrown when trying to specify a bad int to the alphabet.