44 #include <Bpp/Text/TextTools.h> 114 comments_(s.getComments())
120 comments_(s.getComments())
146 fireBeforeSequenceChanged(event);
150 fireAfterSequenceChanged(event);
159 if (newSize == seqSize)
return;
161 if (newSize < seqSize)
184 if (newSize == seqSize)
return;
186 if (newSize < seqSize)
209 fireBeforeSequenceInserted(event);
211 for (
unsigned int i = 0; i < content.size(); i++)
212 if(!getAlphabet()->isIntInAlphabet(content[i]))
213 throw BadIntException(content[i],
"SequenceWithAnnotation::append", getAlphabet());
215 for (
unsigned int i = 0; i < content.size(); i++)
216 content_.push_back(content[i]);
218 fireAfterSequenceInserted(event);
224 fireBeforeSequenceInserted(event);
226 for (
unsigned int i = 0; i < content.size(); i++)
227 if(!getAlphabet()->isCharInAlphabet(content[i]))
228 throw BadCharException(content[i],
"SequenceWithAnnotation::append", getAlphabet());
231 for (
unsigned int i = 0; i < content.size(); i++)
232 content_.push_back(getAlphabet()->charToInt(content[i]));
234 fireAfterSequenceInserted(event);
246 vector<string> types;
250 types.push_back(anno->
getType());
261 if ((swa.getAlphabet()->getAlphabetType()) != (getAlphabet()->getAlphabetType()))
262 throw AlphabetMismatchException(
"SequenceWithAnnotation::merge: Sequence's alphabets don't match ", swa.getAlphabet(), getAlphabet());
265 if (swa.getName() != getName())
266 throw Exception (
"SequenceWithAnnotation::merge: Sequence's names don't match");
269 propagateEvents(
false);
270 append(swa.getContent());
271 propagateEvents(
true);
275 vector<string> types = getAnnotationTypes();
276 vector<string> newTypes = swa.getAnnotationTypes();
277 for (
unsigned int i = 0; i < types.size(); ++i) {
278 vector<string>::iterator it = find(newTypes.begin(), newTypes.end(), types[i]);
279 if (it != newTypes.end()) {
281 getAnnotation(types[i]).merge(swa.getAnnotation(types[i]));
286 auto_ptr<SequenceAnnotation> anno(getAnnotation(types[i]).clone());
288 getAnnotation(types[i]).merge(*anno);
292 for (
unsigned int i = 0; i < newTypes.size(); ++i) {
296 anno->
merge(swa.getAnnotation(newTypes[i]));
std::vector< int > content_
The list content.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
std::vector< std::string > Comments
Declaration of Comments type.
virtual void setContent(const std::string &sequence)
Set the whole content of the sequence.
virtual SequenceAnnotation * clone() const =0
virtual const Alphabet * getAlphabet() const
Get the alphabet associated to the list.
const Comments & getComments() const
Get the comments associated to this sequence.
virtual void setToSizeR(size_t newSize)
Set up the size of a sequence from the right side.
virtual std::vector< std::string > getAnnotationTypes() const
virtual size_t getNumberOfListeners() const
This alphabet is used to deal NumericAlphabet.
SequenceWithAnnotation(const Alphabet *alpha)
Empty constructor: build a void Sequence with just an Alphabet.
std::string name_
The sequence name.
virtual const std::string & getType() const =0
virtual int getGapCharacterCode() const =0
virtual const std::string & getName() const =0
Get the name of this sequence.
virtual void merge(const SequenceWithAnnotation &swa)
Merge a sequence with the current one.
virtual bool merge(const SequenceAnnotation &anno)=0
Merge the input annotation with the current one.
virtual const Comments & getComments() const =0
Get the comments associated to this sequence.
Interface for sequence annotations.
An implementation of the Sequence interface that supports annotation.
EdSymbolList & operator=(const SymbolList &list)
The generic assignment operator.
virtual void setToSizeL(size_t newSize)
Set up the size of a sequence from the left side.
SequenceWithAnnotation & operator=(const Sequence &s)
The Sequence generic assignment operator. This does not perform a hard copy of the alphabet object...
void fireBeforeSequenceDeleted(const SymbolListDeletionEvent &event)
Comments comments_
The sequence comments.
void fireBeforeSequenceInserted(const SymbolListInsertionEvent &event)
An alphabet exception thrown when trying to specify a bad int to the alphabet.
A event-driven SymbolList object.
virtual const SymbolListListener & getListener(size_t i) const
const std::string & getName() const
Get the name of this sequence.
Exception thrown when two alphabets do not match.
virtual void init(const Sequence &seq)=0
void fireAfterSequenceDeleted(const SymbolListDeletionEvent &event)
void fireAfterSequenceInserted(const SymbolListInsertionEvent &event)
void append(const std::vector< int > &content)
Append the specified content to the sequence.