bpp-seq3  3.0.0
bpp::ProbabilisticSymbolList Class Referenceabstract

ProbabilisticSymbolList object. More...

#include <Bpp/Seq/ProbabilisticSymbolList.h>

+ Inheritance diagram for bpp::ProbabilisticSymbolList:
+ Collaboration diagram for bpp::ProbabilisticSymbolList:

Public Types

typedef std::vector< double > SymbolType
 
typedef Table< double > DTable
 

Public Member Functions

 ProbabilisticSymbolList (std::shared_ptr< const Alphabet > &alpha)
 Build a new void ProbabilisticSymbolList object with the specified alphabet. More...
 
 ProbabilisticSymbolList (const DTable &list, std::shared_ptr< const Alphabet > &alpha)
 Build a new ProbabilisticSymbolList object with the specified alphabet and constant as a DataTable. More...
 
 ProbabilisticSymbolList (const std::vector< std::vector< double >> &list, std::shared_ptr< const Alphabet > &alpha)
 Build a new ProbabilisticSymbolList object with the specified alphabet and constant as a VVdouble. More...
 
 ProbabilisticSymbolList (const ProbabilisticSymbolListInterface &list)
 The generic copy constructor. More...
 
 ProbabilisticSymbolList (const CruxSymbolListInterface &list)
 
 ProbabilisticSymbolList (const ProbabilisticSymbolList &list)
 The copy constructor. More...
 
ProbabilisticSymbolListoperator= (const ProbabilisticSymbolListInterface &list)
 The generic assignment operator. More...
 
ProbabilisticSymbolListoperator= (const ProbabilisticSymbolList &list)
 The assignment operator. More...
 
virtual ~ProbabilisticSymbolList ()
 
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...
 
void setContent (const std::vector< std::vector< double >> &list) override
 
void setContent (const DTable &list) override
 
std::string toString () const override
 Convert the list as a string. More...
 
void addElement (const std::vector< double > &element) override
 
void addElement (size_t pos, const std::vector< double > &element) override
 
void setElement (size_t pos, const std::vector< double > &element) override
 
const std::vector< double > & getElement (size_t pos) const override
 Get the element at position 'pos' as a character. More...
 
virtual void deleteElement (size_t pos) override
 Remove the element at position 'pos'. More...
 
virtual void deleteElements (size_t pos, size_t len) override
 Remove the elements at position 'pos'. More...
 
const std::vector< std::vector< double > > & getContent () const override
 
const DTablegetTable () const override
 
const std::vector< double > & getValue (size_t pos) const override
 checked access to a character in list. More...
 
const std::vector< double > & operator[] (size_t pos) const override
 Operator [] overloaded for quick access to a character in list. More...
 
std::vector< double > & operator[] (size_t pos) override
 Operator [] overloaded for quick access to a character in list. More...
 
double getStateValueAt (size_t siteIndex, int state) const override
 get value of a state at a position More...
 
double operator() (size_t siteIndex, int state) const override
 get value of a state at a position More...
 
void shuffle () override
 Randomly shuffle the content of the list, with linear complexity. More...
 
virtual void setContent (const std::vector< T > &list)=0
 Set the whole content of the list. More...
 
The Clonable interface
ProbabilisticSymbolListclone () const override
 
Acting on the content of the list.
virtual void setContent (const std::vector< T > &list)=0
 Set the whole content of the list. More...
 
Edition methods.
virtual void addElement (const T &c)=0
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, const T &c)=0
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const T &c)=0
 Set the element at position 'pos' to character 'c'. More...
 

Protected Attributes

DTable content_
 The list content. More...
 

Private Attributes

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

Detailed Description

ProbabilisticSymbolList object.

This is a general purpose container, containing an ordered list of elements. The states represented by the elements are defined by an alphabet object, which is passed to the list constructor by a pointer.

See also
Alphabet

Definition at line 61 of file ProbabilisticSymbolList.h.

Member Typedef Documentation

◆ DTable

Definition at line 35 of file ProbabilisticSymbolList.h.

◆ SymbolType

typedef std::vector<double> bpp::ProbabilisticSymbolListInterface::SymbolType
inherited

Definition at line 34 of file ProbabilisticSymbolList.h.

Constructor & Destructor Documentation

◆ ProbabilisticSymbolList() [1/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( std::shared_ptr< const Alphabet > &  alpha)

Build a new void ProbabilisticSymbolList object with the specified alphabet.

Parameters
alphathe alphabet to use.

Definition at line 15 of file ProbabilisticSymbolList.cpp.

References alphabet_, content_, and bpp::Table< class >::setRowNames().

Referenced by clone().

◆ ProbabilisticSymbolList() [2/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( const DTable list,
std::shared_ptr< const Alphabet > &  alpha 
)

Build a new ProbabilisticSymbolList object with the specified alphabet and constant as a DataTable.

Parameters
listThe content of the site.
alphaThe alphabet to use.
Exceptions
Ifthe content is internally inconsistent, or is inconsistent with the specified alphabet.

Definition at line 21 of file ProbabilisticSymbolList.cpp.

References content_, bpp::ProbabilisticSymbolListInterface::setContent(), and bpp::Table< class >::setRowNames().

◆ ProbabilisticSymbolList() [3/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( const std::vector< std::vector< double >> &  list,
std::shared_ptr< const Alphabet > &  alpha 
)

Build a new ProbabilisticSymbolList object with the specified alphabet and constant as a VVdouble.

Parameters
listThe content of the site.
alphaThe alphabet to use.
Exceptions
Ifthe content is internally inconsistent, or is inconsistent with the specified alphabet.

Definition at line 28 of file ProbabilisticSymbolList.cpp.

References content_, bpp::ProbabilisticSymbolListInterface::setContent(), and bpp::Table< class >::setRowNames().

◆ ProbabilisticSymbolList() [4/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( const ProbabilisticSymbolListInterface list)

The generic copy constructor.

Definition at line 37 of file ProbabilisticSymbolList.cpp.

◆ ProbabilisticSymbolList() [5/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( const CruxSymbolListInterface list)

◆ ProbabilisticSymbolList() [6/6]

ProbabilisticSymbolList::ProbabilisticSymbolList ( const ProbabilisticSymbolList list)

The copy constructor.

Definition at line 41 of file ProbabilisticSymbolList.cpp.

◆ ~ProbabilisticSymbolList()

virtual bpp::ProbabilisticSymbolList::~ProbabilisticSymbolList ( )
inlinevirtual

Definition at line 139 of file ProbabilisticSymbolList.h.

Member Function Documentation

◆ addElement() [1/4]

void ProbabilisticSymbolList::addElement ( const std::vector< double > &  element)
override

◆ addElement() [2/4]

template<class T >
virtual void bpp::TemplateCoreSymbolListInterface< T >::addElement ( const T &  c)
pure virtualinherited

Add a character to the end of the list.

Parameters
cThe character to add.

Implemented in bpp::AbstractTemplateEventDrivenSymbolList< T >, and bpp::AbstractTemplateSymbolList< T >.

◆ addElement() [3/4]

void ProbabilisticSymbolList::addElement ( size_t  pos,
const std::vector< double > &  element 
)
override

◆ addElement() [4/4]

template<class T >
virtual void bpp::TemplateCoreSymbolListInterface< T >::addElement ( size_t  pos,
const T &  c 
)
pure virtualinherited

Add a character at a certain position in the list.

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

Implemented in bpp::AbstractTemplateEventDrivenSymbolList< T >, and bpp::AbstractTemplateSymbolList< T >.

◆ alphabet()

const Alphabet& bpp::ProbabilisticSymbolList::alphabet ( ) const
inlineoverridevirtual

Get the alphabet associated to the list.

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

Implements bpp::CruxSymbolListInterface.

Definition at line 144 of file ProbabilisticSymbolList.h.

References alphabet_.

◆ clone()

ProbabilisticSymbolList* bpp::ProbabilisticSymbolList::clone ( ) const
inlineoverridevirtual

◆ deleteElement()

virtual void bpp::ProbabilisticSymbolList::deleteElement ( size_t  pos)
inlineoverridevirtual

Remove the element at position 'pos'.

Parameters
posThe position of the element to remove.

Implements bpp::CruxSymbolListInterface.

Definition at line 172 of file ProbabilisticSymbolList.h.

References content_, and bpp::Table< class >::deleteColumn().

◆ deleteElements()

virtual void bpp::ProbabilisticSymbolList::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.

Definition at line 177 of file ProbabilisticSymbolList.h.

References content_, and bpp::Table< class >::deleteColumns().

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::ProbabilisticSymbolList::getAlphabet ( ) const
inlineoverridevirtual

Get the alphabet associated to the list.

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

Implements bpp::CruxSymbolListInterface.

Definition at line 142 of file ProbabilisticSymbolList.h.

References alphabet_.

Referenced by getStateValueAt(), bpp::Pasta::nextSequence(), operator()(), ProbabilisticSymbolList(), and bpp::Pasta::writeSequence().

◆ getContent()

const std::vector<std::vector<double> >& bpp::ProbabilisticSymbolList::getContent ( ) const
inlineoverridevirtual

◆ getElement()

const std::vector<double>& bpp::ProbabilisticSymbolList::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 167 of file ProbabilisticSymbolList.h.

References content_, and bpp::Table< class >::getColumn().

Referenced by getValue().

◆ getStateValueAt()

double bpp::ProbabilisticSymbolList::getStateValueAt ( size_t  position,
int  state 
) const
inlineoverridevirtual

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.

Implements bpp::CruxSymbolListInterface.

Definition at line 207 of file ProbabilisticSymbolList.h.

References content_, getAlphabet(), bpp::Table< class >::getColumn(), and bpp::Table< class >::getNumberOfColumns().

◆ getTable()

const DTable& bpp::ProbabilisticSymbolList::getTable ( ) const
inlineoverridevirtual

Implements bpp::ProbabilisticSymbolListInterface.

Definition at line 187 of file ProbabilisticSymbolList.h.

References content_.

◆ getValue()

const std::vector<double>& bpp::ProbabilisticSymbolList::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 192 of file ProbabilisticSymbolList.h.

References getElement().

◆ operator()()

double bpp::ProbabilisticSymbolList::operator() ( size_t  position,
int  state 
) const
inlineoverridevirtual

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.

Implements bpp::CruxSymbolListInterface.

Definition at line 214 of file ProbabilisticSymbolList.h.

References content_, getAlphabet(), and bpp::Table< class >::getColumn().

◆ operator=() [1/2]

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

The assignment operator.

Definition at line 67 of file ProbabilisticSymbolList.cpp.

References alphabet_, and content_.

◆ operator=() [2/2]

◆ operator[]() [1/2]

const std::vector<double>& bpp::ProbabilisticSymbolList::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 197 of file ProbabilisticSymbolList.h.

References content_, and bpp::Table< class >::getColumn().

◆ operator[]() [2/2]

std::vector<double>& bpp::ProbabilisticSymbolList::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 202 of file ProbabilisticSymbolList.h.

References content_, and bpp::Table< class >::getColumn().

◆ setContent() [1/4]

◆ setContent() [2/4]

void ProbabilisticSymbolList::setContent ( const std::vector< std::vector< double >> &  list)
override

◆ setContent() [3/4]

template<class T >
virtual void bpp::TemplateCoreSymbolListInterface< T >::setContent ( const std::vector< T > &  list)
pure virtualinherited

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.

Implemented in bpp::AbstractTemplateEventDrivenSymbolList< T >, and bpp::AbstractTemplateSymbolList< T >.

◆ setContent() [4/4]

virtual void bpp::TemplateCoreSymbolListInterface< T >::setContent
inherited

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.

Referenced by operator=(), and ProbabilisticSymbolList().

◆ setElement() [1/2]

void ProbabilisticSymbolList::setElement ( size_t  pos,
const std::vector< double > &  element 
)
override

◆ setElement() [2/2]

template<class T >
virtual void bpp::TemplateCoreSymbolListInterface< T >::setElement ( size_t  pos,
const T &  c 
)
pure virtualinherited

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

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

Implemented in bpp::AbstractTemplateEventDrivenSymbolList< T >, and bpp::AbstractTemplateSymbolList< T >.

◆ shuffle()

void bpp::ProbabilisticSymbolList::shuffle ( )
inlineoverridevirtual

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

Implements bpp::CruxSymbolListInterface.

Definition at line 219 of file ProbabilisticSymbolList.h.

◆ size()

size_t bpp::ProbabilisticSymbolList::size ( ) const
inlineoverridevirtual

◆ toString()

string ProbabilisticSymbolList::toString ( ) const
overridevirtual

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.

Definition at line 108 of file ProbabilisticSymbolList.cpp.

References content_, bpp::Table< class >::getNumberOfColumns(), bpp::Table< class >::getNumberOfRows(), and bpp::Table< class >::getRowName().

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::ProbabilisticSymbolList::alphabet_
private

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

To apply another alphabet to the list requires creating another list.

Definition at line 71 of file ProbabilisticSymbolList.h.

Referenced by alphabet(), getAlphabet(), operator=(), ProbabilisticSymbolList(), and setContent().

◆ content_


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