bpp-seq  2.2.0
bpp::EdSymbolList Class Reference

A event-driven SymbolList object. More...

#include <Bpp/Seq/SymbolList.h>

+ Inheritance diagram for bpp::EdSymbolList:
+ Collaboration diagram for bpp::EdSymbolList:

Public Member Functions

 EdSymbolList (const Alphabet *alpha)
 Build a new void BasicSymbolList object with the specified alphabet. More...
 
 EdSymbolList (const std::vector< std::string > &list, const Alphabet *alpha) throw (BadCharException)
 Build a new BasicSymbolList object with the specified alphabet. The content of the site is initialized from a vector of characters. More...
 
 EdSymbolList (const std::vector< int > &list, const Alphabet *alpha) throw (BadIntException)
 Build a new BasicSymbolList object with the specified alphabet. The content of the site is initialized from a vector of integers. More...
 
 EdSymbolList (const SymbolList &list)
 The generic copy constructor. More...
 
 EdSymbolList (const EdSymbolList &list)
 The copy constructor. More...
 
EdSymbolListoperator= (const SymbolList &list)
 The generic assignment operator. More...
 
EdSymbolListoperator= (const EdSymbolList &list)
 The assignment operator. More...
 
virtual ~EdSymbolList ()
 
virtual const AlphabetgetAlphabet () const
 Get the alphabet associated to the list. More...
 
virtual size_t size () const
 Get the number of elements in the list. More...
 
virtual const std::vector< int > & getContent () const
 Get the whole content of the list as a vector of int. More...
 
virtual void setContent (const std::vector< int > &list) throw (BadIntException)
 Set the whole content of the list. More...
 
virtual void setContent (const std::vector< std::string > &list) throw (BadCharException)
 Set the whole content of the list. More...
 
virtual std::string toString () const
 Convert the list as a string. More...
 
virtual void addElement (const std::string &c) throw (BadCharException)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, const std::string &c) throw (BadCharException, IndexOutOfBoundsException)
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const std::string &c) throw (BadCharException, IndexOutOfBoundsException)
 Set the element at position 'pos' to character 'c'. More...
 
virtual void deleteElement (size_t pos) throw (IndexOutOfBoundsException)
 Delete the element at position 'pos'. More...
 
virtual void deleteElements (size_t pos, size_t len) throw (IndexOutOfBoundsException)
 Delete the elements at position 'pos'. More...
 
virtual std::string getChar (size_t pos) const throw (IndexOutOfBoundsException)
 Get the element at position 'pos' as a character. More...
 
virtual void addElement (int v) throw (BadIntException)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, int v) throw (BadIntException, IndexOutOfBoundsException)
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, int v) throw (BadIntException, IndexOutOfBoundsException)
 Set the element at position 'pos' to character 'v'. More...
 
virtual int getValue (size_t pos) const throw (IndexOutOfBoundsException)
 Get the element at position 'pos' as an int. More...
 
virtual const int & operator[] (size_t i) const
 Operator [] overloaded for quick access to a character in list. More...
 
virtual int & operator[] (size_t i)
 Operator [] overloaded for quick access to a character in list. More...
 
virtual void shuffle ()
 Randomly shuffle the content of the list, with linear complexity. More...
 
The Clonable interface
EdSymbolListclone () const
 

Protected Member Functions

void propagateEvents (bool yn)
 
bool propagateEvents () const
 

Protected Attributes

std::vector< int > content_
 The list content. More...
 
std::vector< SymbolListListener * > listeners_
 Contains the listeners. More...
 

Private Attributes

const Alphabetalphabet_
 The Alphabet attribute must be initialized in constructor and then can never be changed. More...
 
bool propagateEvents_
 

Events handling

virtual size_t getNumberOfListeners () const
 
virtual const SymbolListListenergetListener (size_t i) const
 
virtual SymbolListListenergetListener (size_t i)
 
virtual void addSymbolListListener (SymbolListListener *listener)
 
virtual void removeSymbolListListener (SymbolListListener *listener)
 
virtual void beforeSequenceChanged (const SymbolListEditionEvent &event)
 
virtual void afterSequenceChanged (const SymbolListEditionEvent &event)
 
virtual void beforeSequenceInserted (const SymbolListInsertionEvent &event)
 
virtual void afterSequenceInserted (const SymbolListInsertionEvent &event)
 
virtual void beforeSequenceDeleted (const SymbolListDeletionEvent &event)
 
virtual void afterSequenceDeleted (const SymbolListDeletionEvent &event)
 
virtual void beforeSequenceSubstituted (const SymbolListSubstitutionEvent &event)
 
virtual void afterSequenceSubstituted (const SymbolListSubstitutionEvent &event)
 
void fireBeforeSequenceChanged (const SymbolListEditionEvent &event)
 
void fireAfterSequenceChanged (const SymbolListEditionEvent &event)
 
void fireBeforeSequenceInserted (const SymbolListInsertionEvent &event)
 
void fireAfterSequenceInserted (const SymbolListInsertionEvent &event)
 
void fireBeforeSequenceDeleted (const SymbolListDeletionEvent &event)
 
void fireAfterSequenceDeleted (const SymbolListDeletionEvent &event)
 
void fireBeforeSequenceSubstituted (const SymbolListSubstitutionEvent &event)
 
void fireAfterSequenceSubstituted (const SymbolListSubstitutionEvent &event)
 

Detailed Description

A event-driven SymbolList object.

This is a general purpose container, containing an ordered list of states(= letters). The states that allowed to be present in the list are defined by an alphabet object, which is passed to the list constructor by a pointer.

For programming convenience, the states are stored as integers, but the translation toward and from a char description is easily performed with the Alphabet classes.

See also
Alphabet

Definition at line 500 of file SymbolList.h.

Constructor & Destructor Documentation

◆ EdSymbolList() [1/5]

bpp::EdSymbolList::EdSymbolList ( const Alphabet alpha)
inline

Build a new void BasicSymbolList object with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 532 of file SymbolList.h.

Referenced by clone().

◆ EdSymbolList() [2/5]

EdSymbolList::EdSymbolList ( const std::vector< std::string > &  list,
const Alphabet alpha 
)
throw (BadCharException
)

Build a new BasicSymbolList object with the specified alphabet. The content of the site is initialized from a vector of characters.

Parameters
listThe content of the site.
alphaThe alphabet to use.
Exceptions
BadCharExceptionIf the content does not match the specified alphabet.

Definition at line 224 of file SymbolList.cpp.

◆ EdSymbolList() [3/5]

EdSymbolList::EdSymbolList ( const std::vector< int > &  list,
const Alphabet alpha 
)
throw (BadIntException
)

Build a new BasicSymbolList object with the specified alphabet. The content of the site is initialized from a vector of integers.

Parameters
listThe content of the site.
alphaThe alphabet to use.
Exceptions
BadIntExceptionIf the content does not match the specified alphabet.

Definition at line 230 of file SymbolList.cpp.

◆ EdSymbolList() [4/5]

EdSymbolList::EdSymbolList ( const SymbolList list)

The generic copy constructor.

Definition at line 238 of file SymbolList.cpp.

◆ EdSymbolList() [5/5]

EdSymbolList::EdSymbolList ( const EdSymbolList list)

The copy constructor.

Definition at line 241 of file SymbolList.cpp.

References listeners_.

◆ ~EdSymbolList()

virtual bpp::EdSymbolList::~EdSymbolList ( )
inlinevirtual

Definition at line 588 of file SymbolList.h.

References listeners_.

Member Function Documentation

◆ addElement() [1/4]

void EdSymbolList::addElement ( const std::string &  c)
throw (BadCharException
)
virtual

Add a character to the end of the list.

Parameters
cThe character to add, given as a string.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithQuality.

Definition at line 321 of file SymbolList.cpp.

Referenced by bpp::SequenceWithQuality::addElement().

◆ addElement() [2/4]

void EdSymbolList::addElement ( size_t  pos,
const std::string &  c 
)
throw (BadCharException,
IndexOutOfBoundsException
)
virtual

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
cThe character to add, given as a string.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithQuality.

Definition at line 331 of file SymbolList.cpp.

◆ addElement() [3/4]

void EdSymbolList::addElement ( int  v)
throw (BadIntException
)
virtual

Add a character to the end of the list.

Parameters
vThe character to add, given as an int.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithQuality.

Definition at line 394 of file SymbolList.cpp.

◆ addElement() [4/4]

void EdSymbolList::addElement ( size_t  pos,
int  v 
)
throw (BadIntException,
IndexOutOfBoundsException
)
virtual

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
vThe character to add, given as an int.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithQuality.

Definition at line 406 of file SymbolList.cpp.

◆ addSymbolListListener()

virtual void bpp::EdSymbolList::addSymbolListListener ( SymbolListListener listener)
inlinevirtual

Definition at line 657 of file SymbolList.h.

References listeners_.

Referenced by bpp::SequenceWithAnnotation::addAnnotation().

◆ afterSequenceChanged()

virtual void bpp::EdSymbolList::afterSequenceChanged ( const SymbolListEditionEvent event)
inlineprotectedvirtual

Definition at line 670 of file SymbolList.h.

Referenced by fireAfterSequenceChanged().

◆ afterSequenceDeleted()

virtual void bpp::EdSymbolList::afterSequenceDeleted ( const SymbolListDeletionEvent event)
inlineprotectedvirtual

Definition at line 674 of file SymbolList.h.

Referenced by fireAfterSequenceDeleted().

◆ afterSequenceInserted()

virtual void bpp::EdSymbolList::afterSequenceInserted ( const SymbolListInsertionEvent event)
inlineprotectedvirtual

Definition at line 672 of file SymbolList.h.

Referenced by fireAfterSequenceInserted().

◆ afterSequenceSubstituted()

virtual void bpp::EdSymbolList::afterSequenceSubstituted ( const SymbolListSubstitutionEvent event)
inlineprotectedvirtual

Definition at line 676 of file SymbolList.h.

Referenced by fireAfterSequenceSubstituted().

◆ beforeSequenceChanged()

virtual void bpp::EdSymbolList::beforeSequenceChanged ( const SymbolListEditionEvent event)
inlineprotectedvirtual

Definition at line 669 of file SymbolList.h.

Referenced by fireBeforeSequenceChanged().

◆ beforeSequenceDeleted()

virtual void bpp::EdSymbolList::beforeSequenceDeleted ( const SymbolListDeletionEvent event)
inlineprotectedvirtual

Definition at line 673 of file SymbolList.h.

Referenced by fireBeforeSequenceDeleted().

◆ beforeSequenceInserted()

virtual void bpp::EdSymbolList::beforeSequenceInserted ( const SymbolListInsertionEvent event)
inlineprotectedvirtual

Definition at line 671 of file SymbolList.h.

Referenced by fireBeforeSequenceInserted().

◆ beforeSequenceSubstituted()

virtual void bpp::EdSymbolList::beforeSequenceSubstituted ( const SymbolListSubstitutionEvent event)
inlineprotectedvirtual

Definition at line 675 of file SymbolList.h.

Referenced by fireBeforeSequenceSubstituted().

◆ clone()

EdSymbolList* bpp::EdSymbolList::clone ( ) const
inlinevirtual

Implements bpp::SymbolList.

Definition at line 584 of file SymbolList.h.

References EdSymbolList().

◆ deleteElement()

void EdSymbolList::deleteElement ( size_t  pos)
throw (IndexOutOfBoundsException
)
virtual

Delete the element at position 'pos'.

Parameters
posThe position of the element to delete.

Implements bpp::SymbolList.

Definition at line 369 of file SymbolList.cpp.

◆ deleteElements()

void EdSymbolList::deleteElements ( size_t  pos,
size_t  len 
)
throw (IndexOutOfBoundsException
)
virtual

Delete the elements at position 'pos'.

Parameters
posThe position of the first element to delete.
lenThe length of the region to delete.

Implements bpp::SymbolList.

Definition at line 381 of file SymbolList.cpp.

◆ fireAfterSequenceChanged()

void bpp::EdSymbolList::fireAfterSequenceChanged ( const SymbolListEditionEvent event)
inlineprotected

Definition at line 685 of file SymbolList.h.

References afterSequenceChanged(), listeners_, and propagateEvents_.

◆ fireAfterSequenceDeleted()

void bpp::EdSymbolList::fireAfterSequenceDeleted ( const SymbolListDeletionEvent event)
inlineprotected

◆ fireAfterSequenceInserted()

void bpp::EdSymbolList::fireAfterSequenceInserted ( const SymbolListInsertionEvent event)
inlineprotected

◆ fireAfterSequenceSubstituted()

void bpp::EdSymbolList::fireAfterSequenceSubstituted ( const SymbolListSubstitutionEvent event)
inlineprotected

Definition at line 727 of file SymbolList.h.

References afterSequenceSubstituted(), listeners_, and propagateEvents_.

◆ fireBeforeSequenceChanged()

void bpp::EdSymbolList::fireBeforeSequenceChanged ( const SymbolListEditionEvent event)
inlineprotected

Definition at line 678 of file SymbolList.h.

References beforeSequenceChanged(), listeners_, and propagateEvents_.

◆ fireBeforeSequenceDeleted()

void bpp::EdSymbolList::fireBeforeSequenceDeleted ( const SymbolListDeletionEvent event)
inlineprotected

◆ fireBeforeSequenceInserted()

void bpp::EdSymbolList::fireBeforeSequenceInserted ( const SymbolListInsertionEvent event)
inlineprotected

◆ fireBeforeSequenceSubstituted()

void bpp::EdSymbolList::fireBeforeSequenceSubstituted ( const SymbolListSubstitutionEvent event)
inlineprotected

Definition at line 720 of file SymbolList.h.

References beforeSequenceSubstituted(), listeners_, and propagateEvents_.

◆ getAlphabet()

virtual const Alphabet* bpp::EdSymbolList::getAlphabet ( ) const
inlinevirtual

Get the alphabet associated to the list.

Returns
A const pointer to the alphabet.
See also
Alphabet class.

Implements bpp::SymbolList.

Definition at line 599 of file SymbolList.h.

References alphabet_.

Referenced by bpp::SequenceWithQuality::append(), operator=(), bpp::SequenceWithQualityTools::removeGaps(), bpp::SequenceWithAnnotation::setToSizeL(), and bpp::SequenceWithAnnotation::setToSizeR().

◆ getChar()

string EdSymbolList::getChar ( size_t  pos) const
throw (IndexOutOfBoundsException
)
virtual

Get the element at position 'pos' as a character.

Parameters
posThe position of the character to retrieve.

Implements bpp::SymbolList.

Definition at line 354 of file SymbolList.cpp.

◆ getContent()

virtual const std::vector<int>& bpp::EdSymbolList::getContent ( ) const
inlinevirtual

Get the whole content of the list as a vector of int.

Returns
A reference to the content of the list.

Implements bpp::SymbolList.

Definition at line 603 of file SymbolList.h.

References content_.

Referenced by bpp::SequenceWithQualityTools::invert(), and operator=().

◆ getListener() [1/2]

virtual const SymbolListListener& bpp::EdSymbolList::getListener ( size_t  i) const
inlinevirtual

◆ getListener() [2/2]

virtual SymbolListListener& bpp::EdSymbolList::getListener ( size_t  i)
inlinevirtual

Definition at line 652 of file SymbolList.h.

References listeners_.

◆ getNumberOfListeners()

virtual size_t bpp::EdSymbolList::getNumberOfListeners ( ) const
inlinevirtual

◆ getValue()

int EdSymbolList::getValue ( size_t  pos) const
throw (IndexOutOfBoundsException
)
virtual

Get the element at position 'pos' as an int.

Parameters
posThe position of the character to retrieve.

Implements bpp::SymbolList.

Definition at line 434 of file SymbolList.cpp.

◆ operator=() [1/2]

EdSymbolList & EdSymbolList::operator= ( const SymbolList list)

The generic assignment operator.

Definition at line 249 of file SymbolList.cpp.

References alphabet_, content_, bpp::SymbolList::getAlphabet(), bpp::SymbolList::getContent(), listeners_, and propagateEvents_.

Referenced by bpp::SequenceWithAnnotation::operator=().

◆ operator=() [2/2]

EdSymbolList & EdSymbolList::operator= ( const EdSymbolList list)

The assignment operator.

Definition at line 261 of file SymbolList.cpp.

References alphabet_, content_, getAlphabet(), getContent(), listeners_, and propagateEvents_.

◆ operator[]() [1/2]

virtual const int& bpp::EdSymbolList::operator[] ( size_t  i) const
inlinevirtual

Operator [] overloaded for quick access to a character in list.

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implements bpp::SymbolList.

Definition at line 631 of file SymbolList.h.

References content_.

◆ operator[]() [2/2]

virtual int& bpp::EdSymbolList::operator[] ( size_t  i)
inlinevirtual

Operator [] overloaded for quick access to a character in list.

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implements bpp::SymbolList.

Definition at line 633 of file SymbolList.h.

References content_.

◆ propagateEvents() [1/2]

void bpp::EdSymbolList::propagateEvents ( bool  yn)
inlineprotected

Definition at line 736 of file SymbolList.h.

References propagateEvents_.

◆ propagateEvents() [2/2]

bool bpp::EdSymbolList::propagateEvents ( ) const
inlineprotected

Definition at line 737 of file SymbolList.h.

References propagateEvents_.

◆ removeSymbolListListener()

virtual void bpp::EdSymbolList::removeSymbolListListener ( SymbolListListener listener)
inlinevirtual

Definition at line 661 of file SymbolList.h.

References bpp::SymbolListListener::isRemovable(), and listeners_.

◆ setContent() [1/2]

void EdSymbolList::setContent ( const std::vector< int > &  list)
throw (BadIntException
)
virtual

Set the whole content of the list.

Parameters
listThe new content of the list.
See also
The list constructor for information about the way lists are internaly stored.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithAnnotation.

Definition at line 297 of file SymbolList.cpp.

Referenced by bpp::SequenceWithAnnotation::setContent().

◆ setContent() [2/2]

void EdSymbolList::setContent ( const std::vector< std::string > &  list)
throw (BadCharException
)
virtual

Set the whole content of the list.

Parameters
listThe new content of the list.
See also
The list constructor for information about the way lists are internaly stored.

Implements bpp::SymbolList.

Reimplemented in bpp::SequenceWithAnnotation.

Definition at line 277 of file SymbolList.cpp.

◆ setElement() [1/2]

void EdSymbolList::setElement ( size_t  pos,
const std::string &  c 
)
throw (BadCharException,
IndexOutOfBoundsException
)
virtual

Set the element at position 'pos' to character 'c'.

Parameters
posThe position of the character to set.
cThe value of the element, given as a string.

Implements bpp::SymbolList.

Definition at line 342 of file SymbolList.cpp.

◆ setElement() [2/2]

void EdSymbolList::setElement ( size_t  pos,
int  v 
)
throw (BadIntException,
IndexOutOfBoundsException
)
virtual

Set the element at position 'pos' to character 'v'.

Parameters
posThe position of the character to set.
vThe value of the element, given as an int.

Implements bpp::SymbolList.

Definition at line 420 of file SymbolList.cpp.

◆ shuffle()

virtual void bpp::EdSymbolList::shuffle ( )
inlinevirtual

Randomly shuffle the content of the list, with linear complexity.

Implements bpp::SymbolList.

Definition at line 635 of file SymbolList.h.

References content_.

◆ size()

virtual size_t bpp::EdSymbolList::size ( ) const
inlinevirtual

Get the number of elements in the list.

Returns
The number of sites in the list.

Implements bpp::SymbolList.

Definition at line 601 of file SymbolList.h.

References content_.

Referenced by bpp::SequenceWithQuality::addElement(), bpp::SequenceMask::isValidWith(), bpp::SequenceQuality::isValidWith(), and bpp::SequenceWithQualityTools::removeGaps().

◆ toString()

string EdSymbolList::toString ( ) const
virtual

Convert the list as a string.

This method is useful for dumping a list to a file or to the screen for display.

Returns
The whole list as a string.

Implements bpp::SymbolList.

Definition at line 314 of file SymbolList.cpp.

References alphabet_, content_, and bpp::StringSequenceTools::decodeSequence().

Member Data Documentation

◆ alphabet_

const Alphabet* bpp::EdSymbolList::alphabet_
private

The Alphabet attribute must be initialized in constructor and then can never be changed.

To apply another alphabet to a list you'll have to create a new list.

Definition at line 510 of file SymbolList.h.

Referenced by getAlphabet(), operator=(), and toString().

◆ content_

std::vector<int> bpp::EdSymbolList::content_
protected

◆ listeners_

◆ propagateEvents_


The documentation for this class was generated from the following files: