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

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

#include <Bpp/Seq/SymbolList.h>

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

Public Member Functions

 AbstractTemplateSymbolList (std::shared_ptr< const Alphabet > alpha)
 Build a new void SymbolList object with the specified alphabet. More...
 
 AbstractTemplateSymbolList (const std::vector< T > &list, std::shared_ptr< const Alphabet > alpha)
 Build a new SymbolList object with the specified alphabet. The content of the site is initialized from a vector of T objects. More...
 
 AbstractTemplateSymbolList (const AbstractTemplateSymbolList< T > &list)
 The generic copy constructor. More...
 
 AbstractTemplateSymbolList (const TemplateCoreSymbolListInterface< T > &list)
 The copy constructor. More...
 
AbstractTemplateSymbolList< T > & operator= (const TemplateCoreSymbolListInterface< T > &list)
 The generic assignment operator. More...
 
AbstractTemplateSymbolList< T > & operator= (const AbstractTemplateSymbolList< T > &list)
 The assignment operator. More...
 
virtual ~AbstractTemplateSymbolList ()
 
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 void setContent (const std::vector< T > &list) override
 Set the whole content of the list. More...
 
virtual const std::vector< T > & getContent () const override
 
virtual std::string toString () const override
 Convert the list as a string. 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...
 
void addElement (const T &v) override
 Add a character to the end of the list. More...
 
void addElement (size_t pos, const T &v) override
 Add a character at a certain position in the list. More...
 
void setElement (size_t pos, const T &v) override
 Set the element at position 'pos' to character 'c'. 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
 

Protected Attributes

std::vector< T > content_
 The list content. More...
 

Private Attributes

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

Detailed Description

template<class T>
class bpp::AbstractTemplateSymbolList< T >

A partial implementation of a SymbolList 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 32 of file SymbolList.h.

Constructor & Destructor Documentation

◆ AbstractTemplateSymbolList() [1/4]

template<class T >
bpp::AbstractTemplateSymbolList< T >::AbstractTemplateSymbolList ( std::shared_ptr< const Alphabet alpha)
inline

Build a new void SymbolList object with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 55 of file SymbolList.h.

◆ AbstractTemplateSymbolList() [2/4]

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

Build a new SymbolList object with the specified alphabet. The content of the site is initialized from a vector of T objects.

Parameters
listThe content of the site.
alphaThe alphabet to use.

Definition at line 65 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::setContent().

◆ AbstractTemplateSymbolList() [3/4]

template<class T >
bpp::AbstractTemplateSymbolList< T >::AbstractTemplateSymbolList ( const AbstractTemplateSymbolList< T > &  list)
inline

The generic copy constructor.

Definition at line 74 of file SymbolList.h.

◆ AbstractTemplateSymbolList() [4/4]

template<class T >
bpp::AbstractTemplateSymbolList< T >::AbstractTemplateSymbolList ( const TemplateCoreSymbolListInterface< T > &  list)
inline

The copy constructor.

Definition at line 82 of file SymbolList.h.

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

◆ ~AbstractTemplateSymbolList()

template<class T >
virtual bpp::AbstractTemplateSymbolList< T >::~AbstractTemplateSymbolList ( )
inlinevirtual

Definition at line 117 of file SymbolList.h.

Member Function Documentation

◆ addElement() [1/2]

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

Add a character to the end of the list.

Parameters
cThe character to add.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Reimplemented in bpp::AbstractTemplateEventDrivenSymbolList< T >.

Definition at line 152 of file SymbolList.h.

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

Referenced by bpp::AbstractTemplateEventDrivenSymbolList< T >::addElement().

◆ addElement() [2/2]

template<class T >
void bpp::AbstractTemplateSymbolList< 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.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Reimplemented in bpp::AbstractTemplateEventDrivenSymbolList< T >.

Definition at line 157 of file SymbolList.h.

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

◆ alphabet()

◆ clone()

◆ deleteElement()

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

◆ deleteElements()

template<class T >
void bpp::AbstractTemplateSymbolList< 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.

Implements bpp::CruxSymbolListInterface.

Reimplemented in bpp::AbstractTemplateEventDrivenSymbolList< T >, and bpp::AbstractTemplateEventDrivenSymbolList< int >.

Definition at line 145 of file SymbolList.h.

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

Referenced by bpp::AbstractTemplateEventDrivenSymbolList< T >::deleteElements().

◆ getAlphabet()

◆ getContent()

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

◆ getElement()

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

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().

◆ 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
inlineoverridevirtual

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().

◆ 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]

template<class T >
AbstractTemplateSymbolList<T>& bpp::AbstractTemplateSymbolList< T >::operator= ( const AbstractTemplateSymbolList< T > &  list)
inline

The assignment operator.

Definition at line 109 of file SymbolList.h.

References bpp::AbstractTemplateSymbolList< T >::alphabet_, and bpp::AbstractTemplateSymbolList< T >::content_.

◆ operator=() [2/2]

◆ operator[]() [1/2]

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

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)
inlineoverridevirtual

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_.

◆ setContent()

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

◆ setElement()

template<class T >
void bpp::AbstractTemplateSymbolList< 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.

Implements bpp::TemplateCoreSymbolListInterface< T >.

Reimplemented in bpp::AbstractTemplateEventDrivenSymbolList< T >.

Definition at line 165 of file SymbolList.h.

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

Referenced by bpp::AbstractTemplateEventDrivenSymbolList< T >::setElement().

◆ shuffle()

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

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
inlineoverridevirtual

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
inlineoverridevirtual

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

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

◆ content_


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