40 #ifndef _SEQUENCEWITHANNOTATIONTOOLS_H_ 41 #define _SEQUENCEWITHANNOTATIONTOOLS_H_ 45 #include <Bpp/Numeric/VectorTools.h> 59 static const std::string
MASK;
90 SequenceMask(
const std::vector<bool>& mask,
bool removable =
true) :
108 #ifdef NO_VIRTUAL_COV 127 if (throwException &&
mask_.size() != sequence.
size())
throw Exception(
"SequenceMask. The mask size must match the sequence size.");
128 return (
mask_.size() == sequence.
size());
147 if (mask.size() !=
mask_.size())
148 throw DimensionException(
"SequenceMask::setMask. Trying to replace mask by a vector with different length.", mask.size(),
mask_.size());
158 if (pos >=
mask_.size())
159 throw Exception(
"SequenceMask::setMask. Vector overflow. Scores number: " + TextTools::toString(
mask_.size()) +
", but trying to insert mask at position " + TextTools::toString(pos) +
".");
163 void setMask(
size_t pos,
const std::vector<bool>& mask) {
164 if (pos + mask.size() >
mask_.size())
165 throw Exception(
"SequenceMask::setMask. Vector overflow. Scores number: " + TextTools::toString(
mask_.size()) +
", but trying to insert " + TextTools::toString(mask.size()) +
" scores at position " + TextTools::toString(pos) +
".");
166 std::copy(mask.begin(), mask.end(),
mask_.begin() +
static_cast<ptrdiff_t
>(pos));
174 }
catch (std::exception& e) {
207 #endif // _SEQUENCEWITHANNOTATIONTOOLS_H_ void beforeSequenceInserted(const SymbolListInsertionEvent &event)
const std::vector< bool > & getMask() const
This alphabet is used to deal NumericAlphabet.
SequenceAnnotation * getPartAnnotation(size_t pos, size_t len) const
void setMask(size_t pos, bool mask)
bool merge(const SequenceAnnotation &anno)
Merge the input annotation with the current one.
SequenceMask(const std::vector< bool > &mask, bool removable=true)
Build a new SequenceMask object.
const std::string & getType() const
void afterSequenceInserted(const SymbolListInsertionEvent &event)
SequenceMask(size_t size=0, bool removable=true)
Build a new SequenceMask object.
const bool operator[](size_t i) const
void afterSequenceDeleted(const SymbolListDeletionEvent &event)
void beforeSequenceDeleted(const SymbolListDeletionEvent &event)
void setMask(size_t pos, const std::vector< bool > &mask)
The alphabet exception base class.
Interface for sequence annotations.
An implementation of the Sequence interface that supports annotation.
void beforeSequenceSubstituted(const SymbolListSubstitutionEvent &event)
void afterSequenceSubstituted(const SymbolListSubstitutionEvent &event)
void afterSequenceChanged(const SymbolListEditionEvent &event)
bool isValidWith(const SequenceWithAnnotation &sequence, bool throwException=true) const
Test is the annotation is valid for a given sequence.
virtual size_t size() const =0
Get the number of elements in the list.
SequenceMask * clone() const
static const std::string MASK
void setMask(const std::vector< bool > &mask)
virtual size_t size() const
Get the number of elements in the list.
void init(const Sequence &seq)
void beforeSequenceChanged(const SymbolListEditionEvent &event)
std::vector< bool > mask_