5 #ifndef BPP_SEQ_SEQUENCEWITHQUALITY_H
6 #define BPP_SEQ_SEQUENCEWITHQUALITY_H
102 if (throwException &&
qualScores_.size() != sequence.
size())
throw Exception(
"SequenceQuality. Quality scores must match the sequence size.");
125 throw DimensionException(
"SequenceQuality::setScores. Trying to replace score by a vector with different length.", scores.size(),
qualScores_.size());
141 void setScores(
size_t pos,
const std::vector<int>& scores)
145 std::copy(scores.begin(), scores.end(),
qualScores_.begin() +
static_cast<ptrdiff_t
>(pos));
156 catch (std::exception& e)
167 qualScores_.begin() +
static_cast<ptrdiff_t
>(pos + len)),
201 std::shared_ptr<const Alphabet>& alpha) :
222 const std::string& name,
223 const std::string& sequence,
224 std::shared_ptr<const Alphabet>& alpha) :
248 const std::string& name,
249 const std::string& sequence,
251 std::shared_ptr<const Alphabet>& alpha) :
275 const std::string& name,
276 const std::string& sequence,
277 const std::vector<int>& quality,
278 std::shared_ptr<const Alphabet>& alpha) :
305 const std::string& name,
306 const std::string& sequence,
307 const std::vector<int>& quality,
309 std::shared_ptr<const Alphabet>& alpha) :
330 const std::string& name,
331 const std::vector<int>& sequence,
332 std::shared_ptr<const Alphabet>& alpha) :
356 const std::string& name,
357 const std::vector<int>& sequence,
359 std::shared_ptr<const Alphabet>& alpha) :
383 const std::string& name,
384 const std::vector<int>& sequence,
385 const std::vector<int>& quality,
386 std::shared_ptr<const Alphabet>& alpha) :
413 const std::string& name,
414 const std::vector<int>& sequence,
415 const std::vector<int>& quality,
417 std::shared_ptr<const Alphabet>& alpha) :
454 const std::vector<int>& sc) :
567 const std::vector<int>& content,
568 const std::vector<int>& qualities)
570 if (content.size() != qualities.size())
571 throw DimensionException(
"SequenceWithQuality::append: qualities must fit content size", qualities.size(), content.size());
590 const std::vector<std::string>& content,
591 const std::vector<int>& qualities)
593 if (content.size() != qualities.size())
594 throw DimensionException(
"SequenceWithQuality::append: qualities must fit content size", qualities.size(), content.size());
613 const std::string& content,
614 const std::vector<int>& qualities)
616 if (content.size() / this->getAlphabet()->getStateCodingSize()
618 throw DimensionException(
"SequenceWithQuality::append: qualities must fit content size", qualities.size(), content.size() / this->getAlphabet()->getStateCodingSize());
656 size_t pos,
const std::string& c,
int q)
A partial implementation of a SymbolList object.
size_t size() const override
Get the number of elements in the list.
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to the list.
virtual size_t size() const =0
Get the number of elements in the list.
virtual void addElement(const T &c)=0
Add a character to the end of the list.
void addElement(const T &c) override
Interface for sequence annotations.
The SequenceQuality class.
void afterSequenceChanged(const IntSymbolListEditionEvent &event) override
const std::string & getType() const override
static const std::string QUALITY_SCORE
const int & operator[](size_t i) const
void init(const Sequence &seq) override
void setScores(const std::vector< int > &scores)
bool isShared() const override
SequenceQuality(const std::vector< int > &quality, bool removable=true)
Build a new SequenceQuality object.
const std::vector< int > & getScores() const
SequenceQuality * clone() const override
void afterSequenceInserted(const IntSymbolListInsertionEvent &event) override
std::vector< int > qualScores_
void setScore(size_t pos, int score)
bool merge(const SequenceAnnotation &anno) override
Merge the input annotation with the current one.
bool isValidWith(const SequenceWithAnnotation &sequence, bool throwException=true) const override
Test is the annotation is valid for a given sequence.
void afterSequenceDeleted(const IntSymbolListDeletionEvent &event) override
int & operator[](size_t i)
virtual ~SequenceQuality()
SequenceQuality(size_t size=0, bool removable=true)
Build a new SequenceQuality object.
void beforeSequenceInserted(const IntSymbolListInsertionEvent &event) override
void afterSequenceSubstituted(const IntSymbolListSubstitutionEvent &event) override
static const int DEFAULT_QUALITY_VALUE
void beforeSequenceDeleted(const IntSymbolListDeletionEvent &event) override
void beforeSequenceSubstituted(const IntSymbolListSubstitutionEvent &event) override
void setScores(size_t pos, const std::vector< int > &scores)
bool isRemovable() const override
std::unique_ptr< SequenceAnnotation > getPartAnnotation(size_t pos, size_t len) const override
void beforeSequenceChanged(const IntSymbolListEditionEvent &event) override
An implementation of the Sequence interface that supports annotation.
void append(const SequenceInterface &seq) override
Append the content of a sequence to the current one.
virtual void addAnnotation(std::shared_ptr< SequenceAnnotation > anno)
Add a new annotation to the sequence.
virtual const SequenceAnnotation & annotation(const std::string &type) const
SequenceWithAnnotation & operator=(const Sequence &s)
The Sequence generic assignment operator.
A SequenceWithAnnotation class with quality scores attached.
void addElement(int v, int q)
Add a character to the end of the list with quality.
virtual ~SequenceWithQuality()
SequenceWithQuality(std::shared_ptr< const Alphabet > &alpha)
Build a new empty SequenceWithQuality.
SequenceWithQuality & operator=(const SequenceWithQuality &sequence)
SequenceWithQuality(const std::string &name, const std::string &sequence, const std::vector< int > &quality, const Comments &comments, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::string.
SequenceWithQuality(const std::string &name, const std::vector< int > &sequence, const std::vector< int > &quality, const Comments &comments, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::vector<int>
SequenceWithQuality(const std::string &name, const std::vector< int > &sequence, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::vector<int>
SequenceWithQuality(const std::string &name, const std::vector< int > &sequence, const std::vector< int > &quality, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::vector<int>
void setQuality(size_t pos, int quality)
Set the quality score.
void setQualities(const std::vector< int > &quality)
Set the whole quality scores.
void addElement(const std::string &c, int q)
SequenceWithQuality(const std::string &name, const std::string &sequence, const Comments &comments, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::string.
SequenceWithQuality(const std::string &name, const std::vector< int > &sequence, const Comments &comments, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::vector<int>
void append(const SequenceInterface &seq) override
Append the content of a sequence to the current one.
SequenceWithQuality * clone() const override
int getQuality(size_t pos) const
Get the quality score.
void addElement(size_t pos, const std::string &c, int q)
Add a character to a certain position in the list with quality.
std::shared_ptr< SequenceQuality > qualScores_
virtual void append(const std::vector< int > &content, const std::vector< int > &qualities)
Append content with quality.
SequenceWithQuality(const std::string &name, const std::string &sequence, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::string.
SequenceWithQuality(const Sequence &s, const std::vector< int > &sc)
Build a new SequenceWithQuality.
virtual void append(const std::string &content, const std::vector< int > &qualities)
Append content with quality.
void addElement(size_t pos, int v, int q)
Add a character to a certain position in the list with quality.
const std::vector< int > & getQualities() const
Get the whole quality scores.
SequenceWithQuality(const Sequence &s)
Build a new SequenceWithQuality.
SequenceWithQuality(const std::string &name, const std::string &sequence, const std::vector< int > &quality, std::shared_ptr< const Alphabet > &alpha)
Build a new SequenceWithQuality from a std::string.
virtual void append(const std::vector< std::string > &content, const std::vector< int > &qualities)
Append content with quality.
SequenceWithQuality(const SequenceWithQuality &sequence)
A basic implementation of the Sequence interface.
virtual void addElement(const T &c)=0
Add a character to the end of the list.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.
std::vector< std::string > Comments
Declaration of Comments type.