23 fireBeforeSequenceChanged(event);
25 auto alphaPtr = getAlphabet();
28 fireAfterSequenceChanged(event);
36 size_t seqSize = content_.size();
37 if (newSize == seqSize)
40 if (newSize < seqSize)
43 fireBeforeSequenceDeleted(event);
44 content_.resize(newSize);
45 fireAfterSequenceDeleted(event);
51 fireBeforeSequenceInserted(event);
52 int gap = getAlphabet()->getGapCharacterCode();
53 while (content_.size() < newSize)
54 content_.push_back(gap);
55 fireAfterSequenceInserted(event);
63 size_t seqSize = content_.size();
64 if (newSize == seqSize)
67 if (newSize < seqSize)
71 fireBeforeSequenceDeleted(event);
72 content_.erase(content_.begin(), content_.begin() +
static_cast<ptrdiff_t
>(seqSize - newSize));
73 fireAfterSequenceDeleted(event);
79 fireBeforeSequenceInserted(event);
80 int gap = getAlphabet()->getGapCharacterCode();
81 content_.insert(content_.begin(), newSize - seqSize, gap);
82 fireAfterSequenceInserted(event);
89 if (seq.
getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
92 fireBeforeSequenceInserted(event);
93 for (
size_t i = 0; i < seq.
size(); ++i)
95 content_.push_back(seq[i]);
98 fireAfterSequenceInserted(event);
104 fireBeforeSequenceInserted(event);
106 for (
auto i : content)
108 if (!getAlphabet()->isIntInAlphabet(i))
109 throw BadIntException(i,
"SequenceWithAnnotation::append", getAlphabet());
112 for (
auto i : content)
114 content_.push_back(i);
117 fireAfterSequenceInserted(event);
123 fireBeforeSequenceInserted(event);
125 for (
auto i : content)
127 if (!getAlphabet()->isCharInAlphabet(i))
132 for (
auto i : content)
134 content_.push_back(getAlphabet()->charToInt(i));
137 fireAfterSequenceInserted(event);
142 auto alphaPtr = getAlphabet();
150 vector<string> types;
151 for (
unsigned int i = 0; i < getNumberOfListeners(); ++i)
156 types.push_back(anno.
getType());
169 if ((swa.
getAlphabet()->getAlphabetType()) != (getAlphabet()->getAlphabetType()))
173 if (swa.
getName() != getName())
174 throw Exception (
"SequenceWithAnnotation::merge: Sequence's names don't match");
177 propagateEvents(
false);
179 propagateEvents(
true);
183 vector<string> types = getAnnotationTypes();
185 for (
unsigned int i = 0; i < types.size(); ++i)
187 vector<string>::iterator it = find(newTypes.begin(), newTypes.end(), types[i]);
188 if (it != newTypes.end())
191 annotation(types[i]).merge(swa.
annotation(types[i]));
198 unique_ptr<SequenceAnnotation> anno(annotation(types[i]).clone());
200 annotation(types[i]).merge(*anno);
204 for (
unsigned int i = 0; i < newTypes.size(); ++i)
207 shared_ptr<SequenceAnnotation> anno(swa.
annotation(newTypes[i]).
clone());
const std::string & getName() const override
Get the name of this sequence.
Exception thrown when two alphabets do not match.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
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 setContent(const std::vector< T > &list)=0
Set the whole content of the list.
Interface for sequence annotations.
virtual const std::string & getType() const =0
virtual SequenceAnnotation * clone() const override=0
An implementation of the Sequence interface that supports annotation.
void setToSizeL(size_t newSize) override
Set up the size of a sequence from the left side.
void append(const SequenceInterface &seq) override
Append the content of a sequence to the current one.
virtual const SequenceAnnotation & annotation(const std::string &type) const
virtual std::vector< std::string > getAnnotationTypes() const
void setToSizeR(size_t newSize) override
Set up the size of a sequence from the right side.
virtual void merge(const SequenceWithAnnotation &swa)
Merge a sequence with the current one.
virtual const std::vector< T > & getContent() const =0
std::string removeWhiteSpaces(const std::string &s)
This alphabet is used to deal NumericAlphabet.