57 if (end >= sequence.size())
throw IndexOutOfBoundsException (
"SequenceTools::subseq : Invalid upper bound", end, 0, sequence.size());
58 if (end < begin)
throw Exception (
"SequenceTools::subseq : Invalid interval");
61 vector<int> temp(sequence.getContent());
62 vector<int> qualtemp(sequence.getQualities());
65 temp.erase(temp.begin() + end + 1, temp.end());
66 temp.erase(temp.begin(), temp.begin() + begin);
67 qualtemp.erase(qualtemp.begin() + end + 1, qualtemp.end());
68 qualtemp.erase(qualtemp.begin(), qualtemp.begin() + begin);
71 return new SequenceWithQuality(sequence.getName(), temp, qualtemp, sequence.getComments(), sequence.getAlphabet());
80 if ((seqwq1.getAlphabet()->getAlphabetType()) != (seqwq2.getAlphabet()->getAlphabetType()))
81 throw AlphabetMismatchException(
"SequenceTools::concatenate : Sequence's alphabets don't match ", seqwq1.getAlphabet(), seqwq2.getAlphabet());
84 if (seqwq1.getName() != seqwq2.getName())
85 throw Exception (
"SequenceTools::concatenate : Sequence's names don't match");
88 vector<int> sequence = seqwq1.getContent();
89 vector<int> sequence2 = seqwq2.getContent();
90 vector<int> qualities = seqwq1.getQualities();
91 vector<int> qualities2 = seqwq2.getQualities();
93 sequence.insert(sequence.end(), sequence2.begin(), sequence2.end());
94 qualities.insert(qualities.end(), qualities2.begin(), qualities2.end());
95 return new SequenceWithQuality(seqwq1.getName(), sequence, qualities, seqwq1.getComments(), seqwq1.getAlphabet());
104 if (sequence.getAlphabet()->getAlphabetType() ==
"DNA alphabet")
108 else if(sequence.getAlphabet()->getAlphabetType() ==
"RNA alphabet")
114 throw AlphabetException (
"SequenceTools::complement : Sequence must be nucleic.", sequence.getAlphabet());
127 if (sequence.getAlphabet()->getAlphabetType() !=
"DNA alphabet")
129 throw AlphabetException (
"SequenceTools::transcript : Sequence must be DNA", sequence.getAlphabet());
131 Sequence * seq = _transc.translate(sequence);
142 if (sequence.getAlphabet()->getAlphabetType() !=
"RNA alphabet")
144 throw AlphabetException (
"SequenceTools::reverseTranscript : Sequence must be RNA", sequence.getAlphabet());
147 Sequence * seq = _transc.reverse(sequence);
160 iSeq->setContent(iContent);
161 iSeq->setQualities(iQualities);
171 vector<int> qualities;
173 for(
unsigned int i = 0; i < seq.
size(); i++)
175 if(! alpha->
isGap(seq[i]))
177 content.push_back(seq[i]);
190 bool badqual =
false;
virtual const std::vector< int > & getContent() const
Get the whole content of the list as a vector of int.
virtual void setContent(const std::string &sequence)
Set the whole content of the sequence.
virtual const Alphabet * getAlphabet() const
Get the alphabet associated to the list.
virtual bool isGap(int state) const =0
This alphabet is used to deal NumericAlphabet.
A SequenceWithAnnotation class with quality scores attached.
int translate(int state) const
Translate a given state coded as a int from source alphabet to target alphabet.
The alphabet exception base class.
void setQualities(const std::vector< int > &quality)
Set the whole quality scores.
virtual const std::vector< int > & getContent() const =0
Get the whole content of the list as a vector of int.
This alphabet is used to deal with DNA sequences.
const std::vector< int > & getQualities() const
Get the whole quality scores.
This alphabet is used to deal with RNA sequences.
Exception thrown when two alphabets do not match.
virtual size_t size() const
Get the number of elements in the list.
Replication between to nucleic acids.
SequenceWithQuality * clone() const