5 #include "../Alphabet/AlphabetTools.h"
6 #include "../SequenceTools.h"
15 Exception(
"StopCodonException: " + text +
"(" + codon +
")"),
25 map<int, int>::const_iterator it =
tlnTable_.find(state);
48 for (
int i = 0; i < static_cast<int>(
codonAlphabet_->getSize()); ++i)
53 synonyms.push_back(i);
68 vector<string> synonyms;
69 for (
int i = 0; i < static_cast<int>(
codonAlphabet_->getSize()); ++i)
93 for (
int an = 0; an < 4; an++)
97 vector<int> mutcodon = codon;
99 int intcodon =
codonAlphabet_->getCodon(mutcodon[0], mutcodon[1], mutcodon[2]);
116 bool lookForInitCodon,
117 bool includeInitCodon)
const
120 size_t stopPos = sequence.
size();
124 if (lookForInitCodon)
126 for (
size_t i = 0; i < sequence.
size(); i++)
129 if (pos[0] == 0 && pos[1] == 3 && pos[2] == 2)
131 initPos = includeInitCodon ? i : i + 1;
137 for (
size_t i = initPos; i < sequence.
size(); i++)
149 if (lookForInitCodon)
151 for (
size_t i = 0; i < sequence.
size() - 2; i++)
153 if (sequence[i] == 0 && sequence[i + 1] == 3 && sequence[i + 2] == 2)
155 initPos = includeInitCodon ? i : i + 3;
161 shared_ptr<const NucleicAlphabet> nucAlpha =
codonAlphabet_->getNucleicAlphabet();
162 for (
size_t i = initPos; i < sequence.
size() - 2; i += 3)
164 string codon = nucAlpha->intToChar(sequence[i])
165 + nucAlpha->intToChar(sequence[i + 1])
166 + nucAlpha->intToChar(sequence[i + 2]);
177 return SequenceTools::subseq<Sequence>(sequence, initPos, stopPos - 1);
Exception thrown when two alphabets do not match.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
virtual size_t size() const =0
Get the number of elements in the list.
virtual const Alphabet & alphabet() const =0
Get the alphabet associated to the list.
bool isFourFoldDegenerated(int codon) const
std::unique_ptr< Sequence > getCodingSequence(const SequenceInterface &sequence, bool lookForInitCodon=false, bool includeInitCodon=false) const
Get the subsequence corresponding to the coding part of a given sequence.
std::vector< int > getSynonymous(int aminoacid) const
std::shared_ptr< const CodonAlphabet > codonAlphabet_
int translate(int state) const override
Translate a given state coded as a int from source alphabet to target alphabet.
std::map< int, int > tlnTable_
std::shared_ptr< const ProteicAlphabet > proteicAlphabet_
virtual bool isStop(int state) const =0
Tells is a particular codon is a stop codon.
Exception thrown when a stop codon is found.
StopCodonException(const std::string &text, const std::string &codon)
This alphabet is used to deal NumericAlphabet.