5 #ifndef BPP_SEQ_SEQUENCEWITHANNOTATIONTOOLS_H
6 #define BPP_SEQ_SEQUENCEWITHANNOTATIONTOOLS_H
24 static const std::string
MASK;
54 SequenceMask(
const std::vector<bool>& mask,
bool removable =
true) :
86 if (throwException &&
mask_.size() != sequence.
size())
throw Exception(
"SequenceMask. The mask size must match the sequence size.");
91 bool isShared()
const override {
return false; }
107 if (mask.size() !=
mask_.size())
108 throw DimensionException(
"SequenceMask::setMask. Trying to replace mask by a vector with different length.", mask.size(),
mask_.size());
119 if (pos >=
mask_.size())
124 void setMask(
size_t pos,
const std::vector<bool>& mask)
126 if (pos + mask.size() >
mask_.size())
128 std::copy(mask.begin(), mask.end(),
mask_.begin() +
static_cast<ptrdiff_t
>(pos));
139 catch (std::exception& e)
147 return std::unique_ptr<SequenceAnnotation>(
new SequenceMask(std::vector<bool>(
mask_.begin() +
static_cast<ptrdiff_t
>(pos),
mask_.begin() +
static_cast<ptrdiff_t
>(pos + len)),
removable_));
size_t size() const override
Get the number of elements in the list.
virtual size_t size() const =0
Get the number of elements in the list.
Interface for sequence annotations.
SequenceMask(const std::vector< bool > &mask, bool removable=true)
Build a new SequenceMask object.
void beforeSequenceSubstituted(const IntSymbolListSubstitutionEvent &event) override
void setMask(size_t pos, bool mask)
void beforeSequenceChanged(const IntSymbolListEditionEvent &event) override
SequenceMask * clone() const override
void setMask(size_t pos, const std::vector< bool > &mask)
bool isShared() const override
std::vector< bool > mask_
std::unique_ptr< SequenceAnnotation > getPartAnnotation(size_t pos, size_t len) const override
void afterSequenceChanged(const IntSymbolListEditionEvent &event) override
const std::vector< bool > & getMask() const
void init(const Sequence &seq) override
void afterSequenceInserted(const IntSymbolListInsertionEvent &event) override
const std::string & getType() const override
static const std::string MASK
void afterSequenceSubstituted(const IntSymbolListSubstitutionEvent &event) override
bool merge(const SequenceAnnotation &anno) override
Merge the input annotation with the current one.
void afterSequenceDeleted(const IntSymbolListDeletionEvent &event) override
SequenceMask(size_t size=0, bool removable=true)
Build a new SequenceMask object.
bool isRemovable() const override
bool isValidWith(const SequenceWithAnnotation &sequence, bool throwException=true) const override
Test is the annotation is valid for a given sequence.
void beforeSequenceDeleted(const IntSymbolListDeletionEvent &event) override
const bool operator[](size_t i) const
void setMask(const std::vector< bool > &mask)
void beforeSequenceInserted(const IntSymbolListInsertionEvent &event) override
An implementation of the Sequence interface that supports annotation.
A basic implementation of the Sequence interface.
std::string toString(T t)
This alphabet is used to deal NumericAlphabet.