bpp-seq3  3.0.0
bpp::AbstractTemplateEventDrivenSymbolList< T > Class Template Referenceabstract

A partial implementation of a EventDrivenSymbolList object. More...

#include <Bpp/Seq/SymbolList.h>

+ Inheritance diagram for bpp::AbstractTemplateEventDrivenSymbolList< T >:
+ Collaboration diagram for bpp::AbstractTemplateEventDrivenSymbolList< T >:

Public Member Functions

virtual void setContent (const std::vector< T > &list) override
 Set the whole content of the list. More...
 
void deleteElement (size_t pos) override
 Remove the element at position 'pos'. More...
 
void deleteElements (size_t pos, size_t len) override
 Remove the elements at position 'pos'. More...
 
virtual void addElement (const T &v) override
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, const T &v) override
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const T &v) override
 Set the element at position 'pos' to character 'c'. More...
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 Get the alphabet associated to the list. More...
 
const Alphabetalphabet () const override
 Get the alphabet associated to the list. More...
 
size_t size () const override
 Get the number of elements in the list. More...
 
virtual const std::vector< T > & getContent () const override
 
virtual std::string toString () const override
 Convert the list as a string. More...
 
const T & getElement (size_t pos) const override
 Get the element at position 'pos' as a character. More...
 
const T & getValue (size_t pos) const override
 checked access to a character in list. More...
 
const T & operator[] (size_t pos) const override
 Operator [] overloaded for quick access to a character in list. More...
 
T & operator[] (size_t pos) override
 Operator [] overloaded for quick access to a character in list. More...
 
void shuffle () override
 Randomly shuffle the content of the list, with linear complexity. More...
 
virtual double getStateValueAt (size_t position, int state) const =0
 get value of a state at a position More...
 
virtual double operator() (size_t position, int state) const =0
 get value of a state at a position More...
 
The Clonable interface
TemplateCoreSymbolListInterfaceclone () const override=0
 
The Clonable interface
virtual TemplateEventDrivenCoreSymbolListInterfaceclone () const override=0
 

Protected Member Functions

 AbstractTemplateEventDrivenSymbolList (std::shared_ptr< const Alphabet > alpha)
 Build a new void EventDrivenSymbolList object with the specified alphabet. More...
 
 AbstractTemplateEventDrivenSymbolList (const std::vector< T > &list, std::shared_ptr< const Alphabet > alpha)
 Build a new EventDrivenSymbolList object with the specified alphabet. The content of the site is initialized from a vector of integers. More...
 
 AbstractTemplateEventDrivenSymbolList (const TemplateCoreSymbolListInterface< T > &list)
 The generic copy constructor. More...
 
 AbstractTemplateEventDrivenSymbolList (const AbstractTemplateEventDrivenSymbolList< T > &list)
 The copy constructor. More...
 
AbstractTemplateEventDrivenSymbolList< T > & operator= (const TemplateCoreSymbolListInterface< T > &list)
 The generic assignment operator. More...
 
AbstractTemplateEventDrivenSymbolList< T > & operator= (const AbstractTemplateEventDrivenSymbolList &list)
 The assignment operator. More...
 
virtual ~AbstractTemplateEventDrivenSymbolList ()=default
 
void propagateEvents (bool yn) override
 
bool propagateEvents () const override
 

Protected Attributes

std::vector< std::shared_ptr< CoreSymbolListListener< T > > > listeners_
 Contains the listeners. More...
 
std::vector< T > content_
 The list content. More...
 

Private Attributes

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

Events handling

virtual void beforeSequenceChanged (const CoreSymbolListEditionEvent< T > &event) override
 
virtual void afterSequenceChanged (const CoreSymbolListEditionEvent< T > &event) override
 
virtual void beforeSequenceInserted (const CoreSymbolListInsertionEvent< T > &event) override
 
virtual void afterSequenceInserted (const CoreSymbolListInsertionEvent< T > &event) override
 
virtual void beforeSequenceDeleted (const CoreSymbolListDeletionEvent< T > &event) override
 
virtual void afterSequenceDeleted (const CoreSymbolListDeletionEvent< T > &event) override
 
virtual void beforeSequenceSubstituted (const CoreSymbolListSubstitutionEvent< T > &event) override
 
virtual void afterSequenceSubstituted (const CoreSymbolListSubstitutionEvent< T > &event) override
 
void fireBeforeSequenceChanged (const CoreSymbolListEditionEvent< T > &event) override
 
void fireAfterSequenceChanged (const CoreSymbolListEditionEvent< T > &event) override
 
void fireBeforeSequenceInserted (const CoreSymbolListInsertionEvent< T > &event) override
 
void fireAfterSequenceInserted (const CoreSymbolListInsertionEvent< T > &event) override
 
void fireBeforeSequenceDeleted (const CoreSymbolListDeletionEvent< T > &event) override
 
void fireAfterSequenceDeleted (const CoreSymbolListDeletionEvent< T > &event) override
 
void fireBeforeSequenceSubstituted (const CoreSymbolListSubstitutionEvent< T > &event) override
 
void fireAfterSequenceSubstituted (const CoreSymbolListSubstitutionEvent< T > &event) override
 
virtual size_t getNumberOfListeners () const override
 
virtual const CoreSymbolListListener< T > & listener (size_t i) const override
 
virtual std::shared_ptr< const CoreSymbolListListener< T > > getListener (size_t i) const override
 
virtual CoreSymbolListListener< T > & listener (size_t i) override
 
virtual std::shared_ptr< CoreSymbolListListener< T > > getListener (size_t i) override
 
virtual void addCoreSymbolListListener (std::shared_ptr< CoreSymbolListListener< T >> listener) override
 
virtual void removeCoreSymbolListListener (std::shared_ptr< CoreSymbolListListener< T >> listener) override
 

Detailed Description

template<class T>
class bpp::AbstractTemplateEventDrivenSymbolList< T >

A partial implementation of a EventDrivenSymbolList object.

This class implements most of the CoreSymbolList interface, with the exception of the getStateValueAt function, which depend on the template type.

See also
Alphabet

Definition at line 206 of file SymbolList.h.

Constructor & Destructor Documentation

◆ AbstractTemplateEventDrivenSymbolList() [1/4]

template<class T >
bpp::AbstractTemplateEventDrivenSymbolList< T >::AbstractTemplateEventDrivenSymbolList ( std::shared_ptr< const Alphabet alpha)
inlineprotected

Build a new void EventDrivenSymbolList object with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 225 of file SymbolList.h.

◆ AbstractTemplateEventDrivenSymbolList() [2/4]

template<class T >
bpp::AbstractTemplateEventDrivenSymbolList< T >::AbstractTemplateEventDrivenSymbolList ( const std::vector< T > &  list,
std::shared_ptr< const Alphabet alpha 
)
inlineprotected

Build a new EventDrivenSymbolList 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 236 of file SymbolList.h.

◆ AbstractTemplateEventDrivenSymbolList() [3/4]

The generic copy constructor.

Definition at line 243 of file SymbolList.h.

◆ AbstractTemplateEventDrivenSymbolList() [4/4]

The copy constructor.

Definition at line 253 of file SymbolList.h.

References bpp::AbstractTemplateEventDrivenSymbolList< T >::listeners_.

◆ ~AbstractTemplateEventDrivenSymbolList()

template<class T >
virtual bpp::AbstractTemplateEventDrivenSymbolList< T >::~AbstractTemplateEventDrivenSymbolList ( )
protectedvirtualdefault

Member Function Documentation

◆ addCoreSymbolListListener()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::addCoreSymbolListListener ( std::shared_ptr< CoreSymbolListListener< T >>  listener)
inlineoverridevirtual

◆ addElement() [1/2]

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::addElement ( const T &  c)
inlineoverridevirtual

◆ addElement() [2/2]

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::addElement ( size_t  pos,
const T &  c 
)
inlineoverridevirtual

Add a character at a certain position in the list.

Parameters
posThe position where to insert the element.
cThe character to add.

Reimplemented from bpp::AbstractTemplateSymbolList< T >.

Definition at line 344 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::addElement(), bpp::AbstractTemplateEventDrivenSymbolList< T >::fireAfterSequenceInserted(), and bpp::AbstractTemplateEventDrivenSymbolList< T >::fireBeforeSequenceInserted().

◆ afterSequenceChanged()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::afterSequenceChanged ( const CoreSymbolListEditionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ afterSequenceDeleted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::afterSequenceDeleted ( const CoreSymbolListDeletionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ afterSequenceInserted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::afterSequenceInserted ( const CoreSymbolListInsertionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ afterSequenceSubstituted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::afterSequenceSubstituted ( const CoreSymbolListSubstitutionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ alphabet()

◆ beforeSequenceChanged()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::beforeSequenceChanged ( const CoreSymbolListEditionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ beforeSequenceDeleted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::beforeSequenceDeleted ( const CoreSymbolListDeletionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ beforeSequenceInserted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::beforeSequenceInserted ( const CoreSymbolListInsertionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ beforeSequenceSubstituted()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::beforeSequenceSubstituted ( const CoreSymbolListSubstitutionEvent< T > &  event)
inlineoverrideprotectedvirtual

◆ clone() [1/2]

◆ clone() [2/2]

◆ deleteElement()

template<class T >
void bpp::AbstractTemplateEventDrivenSymbolList< T >::deleteElement ( size_t  pos)
inlineoverridevirtual

◆ deleteElements()

template<class T >
void bpp::AbstractTemplateEventDrivenSymbolList< T >::deleteElements ( size_t  pos,
size_t  len 
)
inlineoverridevirtual

Remove the elements at position 'pos'.

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

Reimplemented from bpp::AbstractTemplateSymbolList< T >.

Definition at line 328 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::deleteElements(), bpp::AbstractTemplateEventDrivenSymbolList< T >::fireAfterSequenceDeleted(), and bpp::AbstractTemplateEventDrivenSymbolList< T >::fireBeforeSequenceDeleted().

◆ fireAfterSequenceChanged()

◆ fireAfterSequenceDeleted()

◆ fireAfterSequenceInserted()

◆ fireAfterSequenceSubstituted()

◆ fireBeforeSequenceChanged()

◆ fireBeforeSequenceDeleted()

◆ fireBeforeSequenceInserted()

◆ fireBeforeSequenceSubstituted()

◆ getAlphabet()

◆ getContent()

template<class T >
virtual const std::vector<T>& bpp::AbstractTemplateSymbolList< T >::getContent ( ) const
inlineoverridevirtualinherited

◆ getElement()

template<class T >
const T& bpp::AbstractTemplateSymbolList< T >::getElement ( size_t  pos) const
inlineoverridevirtualinherited

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

Parameters
posThe position of the character to retrieve.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Definition at line 173 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_, and bpp::AbstractTemplateSymbolList< T >::size().

◆ getListener() [1/2]

template<class T >
virtual std::shared_ptr<const CoreSymbolListListener<T> > bpp::AbstractTemplateEventDrivenSymbolList< T >::getListener ( size_t  i) const
inlineoverridevirtual

◆ getListener() [2/2]

template<class T >
virtual std::shared_ptr<CoreSymbolListListener<T> > bpp::AbstractTemplateEventDrivenSymbolList< T >::getListener ( size_t  i)
inlineoverridevirtual

◆ getNumberOfListeners()

template<class T >
virtual size_t bpp::AbstractTemplateEventDrivenSymbolList< T >::getNumberOfListeners ( ) const
inlineoverridevirtual

◆ getStateValueAt()

virtual double bpp::CruxSymbolListInterface::getStateValueAt ( size_t  position,
int  state 
) const
pure virtualinherited

get value of a state at a position

Parameters
positionposition in the list
statestate in the alphabet
Returns
The state value at the given position.

Implemented in bpp::Sequence, bpp::ProbabilisticSequence, bpp::ProbabilisticSymbolList, bpp::IntSymbolList, bpp::CoreSiteInterface, bpp::Site, and bpp::ProbabilisticSite.

Referenced by bpp::ProbabilisticSymbolList::ProbabilisticSymbolList().

◆ getValue()

template<class T >
const T& bpp::AbstractTemplateSymbolList< T >::getValue ( size_t  pos) const
inlineoverridevirtualinherited

checked access to a character in list.

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Definition at line 180 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_, and bpp::AbstractTemplateSymbolList< T >::size().

Referenced by bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), and bpp::CodonSiteTools::isFourFoldDegenerated().

◆ listener() [1/2]

◆ listener() [2/2]

template<class T >
virtual CoreSymbolListListener<T>& bpp::AbstractTemplateEventDrivenSymbolList< T >::listener ( size_t  i)
inlineoverridevirtual

◆ operator()()

virtual double bpp::CruxSymbolListInterface::operator() ( size_t  position,
int  state 
) const
pure virtualinherited

get value of a state at a position

Short-cut for getStateValueAt.

Parameters
positionposition in the list
statestate in the alphabet
Returns
The state value at the given position.

Implemented in bpp::ProbabilisticSymbolList, and bpp::IntSymbolList.

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ operator[]() [1/2]

template<class T >
const T& bpp::AbstractTemplateSymbolList< T >::operator[] ( size_t  pos) const
inlineoverridevirtualinherited

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

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Definition at line 187 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_.

◆ operator[]() [2/2]

template<class T >
T& bpp::AbstractTemplateSymbolList< T >::operator[] ( size_t  pos)
inlineoverridevirtualinherited

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

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Definition at line 189 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_.

◆ propagateEvents() [1/2]

template<class T >
bool bpp::AbstractTemplateEventDrivenSymbolList< T >::propagateEvents ( ) const
inlineoverrideprotectedvirtual

◆ propagateEvents() [2/2]

template<class T >
void bpp::AbstractTemplateEventDrivenSymbolList< T >::propagateEvents ( bool  yn)
inlineoverrideprotectedvirtual

◆ removeCoreSymbolListListener()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::removeCoreSymbolListListener ( std::shared_ptr< CoreSymbolListListener< T >>  listener)
inlineoverridevirtual

◆ setContent()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::setContent ( const std::vector< T > &  list)
inlineoverridevirtual

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 internally stored.

Reimplemented from bpp::AbstractTemplateSymbolList< T >.

Reimplemented in bpp::SequenceWithAnnotation, and bpp::EventDrivenIntSymbolList.

Definition at line 309 of file SymbolList.h.

References bpp::AbstractTemplateEventDrivenSymbolList< T >::fireAfterSequenceChanged(), bpp::AbstractTemplateEventDrivenSymbolList< T >::fireBeforeSequenceChanged(), and bpp::AbstractTemplateSymbolList< T >::setContent().

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

◆ setElement()

template<class T >
virtual void bpp::AbstractTemplateEventDrivenSymbolList< T >::setElement ( size_t  pos,
const T &  c 
)
inlineoverridevirtual

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

Parameters
posThe position of the character to set.
cThe value of the element.

Reimplemented from bpp::AbstractTemplateSymbolList< T >.

Definition at line 352 of file SymbolList.h.

References bpp::AbstractTemplateEventDrivenSymbolList< T >::fireAfterSequenceSubstituted(), bpp::AbstractTemplateEventDrivenSymbolList< T >::fireBeforeSequenceSubstituted(), and bpp::AbstractTemplateSymbolList< T >::setElement().

Referenced by bpp::EventDrivenIntSymbolList::setElement().

◆ shuffle()

template<class T >
void bpp::AbstractTemplateSymbolList< T >::shuffle ( )
inlineoverridevirtualinherited

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

Implements bpp::CruxSymbolListInterface.

Definition at line 191 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_, and bpp::RandomTools::DEFAULT_GENERATOR.

◆ size()

template<class T >
size_t bpp::AbstractTemplateSymbolList< T >::size ( ) const
inlineoverridevirtualinherited

Get the number of elements in the list.

Returns
The number of sites in the list.

Implements bpp::CruxSymbolListInterface.

Definition at line 124 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::content_.

Referenced by bpp::AbstractTemplateSymbolList< T >::addElement(), bpp::CompressedVectorSiteContainer::addSite(), bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >::checkSize_(), bpp::SequenceWithAnnotationTools::createMaskAnnotation(), bpp::AbstractTemplateSymbolList< T >::deleteElement(), bpp::AbstractTemplateSymbolList< T >::deleteElements(), bpp::CodonSiteTools::fixedDifferences(), bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::SiteContainerTools::getAlignmentPositions(), bpp::SequenceContainerTools::getCounts(), bpp::AbstractTemplateSymbolList< T >::getElement(), bpp::SequenceContainerTools::getFrequencies(), bpp::SiteContainerTools::getSequencePositions(), bpp::CompressedVectorSiteContainer::getSiteIndex_(), bpp::AbstractTemplateSymbolList< T >::getValue(), bpp::CodonAlphabet::getWord(), bpp::WordAlphabet::getWord(), bpp::CodonSiteTools::hasGapOrStop(), bpp::SimpleSequencePositionIterator::hasMorePositions(), bpp::CodonSiteTools::hasStop(), bpp::SequenceMask::init(), bpp::SequenceQuality::init(), bpp::CodonSiteTools::isFourFoldDegenerated(), bpp::CodonSiteTools::isMonoSitePolymorphic(), bpp::CodonSiteTools::isSynonymousPolymorphic(), bpp::CodonSiteTools::meanNumberOfSynonymousPositions(), bpp::CodonSiteTools::numberOfNonSynonymousSubstitutions(), bpp::CodonSiteTools::numberOfSubstitutions(), bpp::CodonSiteTools::piNonSynonymous(), bpp::CodonSiteTools::piSynonymous(), bpp::SiteContainerTools::resolveDottedAlignment(), bpp::AbstractTemplateSymbolList< T >::setElement(), bpp::CompressedVectorSiteContainer::setSite(), bpp::SiteContainerTools::translateAlignment(), bpp::Fasta::writeSequence(), and bpp::Pasta::writeSequence().

◆ toString()

template<class T >
virtual std::string bpp::AbstractTemplateSymbolList< T >::toString ( ) const
inlineoverridevirtualinherited

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::CruxSymbolListInterface.

Reimplemented in bpp::Sequence, bpp::EventDrivenIntSymbolList, and bpp::IntSymbolList.

Definition at line 133 of file SymbolList.h.

Member Data Documentation

◆ alphabet_

template<class T >
std::shared_ptr<const Alphabet> bpp::AbstractTemplateSymbolList< T >::alphabet_
privateinherited

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 41 of file SymbolList.h.

Referenced by bpp::AbstractTemplateSymbolList< T >::alphabet(), bpp::AbstractTemplateSymbolList< T >::getAlphabet(), and bpp::AbstractTemplateSymbolList< T >::operator=().

◆ content_

◆ listeners_

◆ propagateEvents_


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