bpp-seq3  3.0.0
bpp::BasicIntSymbolList Class Referenceabstract

A basic IntSymbolList object. More...

#include <Bpp/Seq/IntSymbolList.h>

+ Inheritance diagram for bpp::BasicIntSymbolList:
+ Collaboration diagram for bpp::BasicIntSymbolList:

Public Member Functions

 BasicIntSymbolList (const Alphabet *alpha)
 
 BasicIntSymbolList (const std::vector< std::string > &list, const Alphabet *alpha)
 Build a new BasicIntSymbolList object with the specified alphabet. The content of the site is initialized from a vector of characters. More...
 
 BasicIntSymbolList (const std::vector< int > &list, const Alphabet *alpha)
 Build a new BasicIntSymbolList object with the specified alphabet. The content of the site is initialized from a vector of integers. More...
 
 BasicIntSymbolList (const BasicIntSymbolList &list)
 The copy constructor. More...
 
BasicIntSymbolListoperator= (const IntSymbolList &list)
 The generic assignment operator. More...
 
BasicIntSymbolListoperator= (const BasicIntSymbolList &list)
 The assignment operator. More...
 
virtual ~BasicIntSymbolList ()
 
void setContent (const std::vector< int > &list)
 
void setContent (const std::vector< std::string > &list)
 
std::string toString () const
 Convert the list as a string. More...
 
virtual void addElement (const std::string &c)
 
virtual void addElement (size_t pos, const std::string &c)
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const std::string &c)
 
virtual std::string getChar (size_t pos) const
 Get the element at position 'pos' as a character. More...
 
virtual double getStateValueAt (size_t siteIndex, int state) const
 
virtual double operator() (size_t siteIndex, int state) const
 
void addElement (const int &v)
 Add a character to the end of the list. More...
 
void addElement (size_t pos, const int &v)
 Add a character at a certain position in the list. More...
 
void setElement (size_t pos, const int &v)
 Set the element at position 'pos' to character 'c'. More...
 
const AlphabetgetAlphabet () const
 Get the alphabet associated to the list. More...
 
size_t size () const
 Get the number of elements in the list. More...
 
virtual const std::vector< int > & getContent () const
 
void deleteElement (size_t pos)
 Remove the element at position 'pos'. More...
 
void deleteElements (size_t pos, size_t len)
 Remove the elements at position 'pos'. More...
 
virtual const int & getElement (size_t pos) const
 Get the element at position 'pos' as a character. More...
 
virtual const int & getValue (size_t pos) const
 checked access to a character in list. More...
 
virtual const int & operator[] (size_t pos) const
 Operator [] overloaded for quick access to a character in list. More...
 
virtual int & operator[] (size_t pos)
 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
BasicIntSymbolListclone () const
 
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

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

Private Attributes

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

Detailed Description

A basic IntSymbolList 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 150 of file IntSymbolList.h.

Constructor & Destructor Documentation

◆ BasicIntSymbolList() [1/4]

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

Definition at line 154 of file IntSymbolList.h.

Referenced by clone().

◆ BasicIntSymbolList() [2/4]

BasicIntSymbolList::BasicIntSymbolList ( const std::vector< std::string > &  list,
const Alphabet alpha 
)

Build a new BasicIntSymbolList 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.

Definition at line 51 of file IntSymbolList.cpp.

References setContent().

◆ BasicIntSymbolList() [3/4]

BasicIntSymbolList::BasicIntSymbolList ( const std::vector< int > &  list,
const Alphabet alpha 
)

Build a new BasicIntSymbolList 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.

Definition at line 57 of file IntSymbolList.cpp.

References setContent().

◆ BasicIntSymbolList() [4/4]

BasicIntSymbolList::BasicIntSymbolList ( const BasicIntSymbolList list)

The copy constructor.

Definition at line 72 of file IntSymbolList.cpp.

◆ ~BasicIntSymbolList()

virtual bpp::BasicIntSymbolList::~BasicIntSymbolList ( )
inlinevirtual

Definition at line 200 of file IntSymbolList.h.

Member Function Documentation

◆ addElement() [1/6]

void bpp::SymbolList< int >::addElement ( const T &  c)
inlineinherited

Add a character to the end of the list.

Parameters
cThe character to add.

Definition at line 199 of file SymbolList.h.

◆ addElement() [2/6]

void BasicIntSymbolList::addElement ( const std::string &  c)
virtual

◆ addElement() [3/6]

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

◆ addElement() [4/6]

void bpp::SymbolList< int >::addElement ( size_t  pos,
const T &  c 
)
inlineinherited

Add a character at a certain position in the list.

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

Definition at line 204 of file SymbolList.h.

◆ addElement() [5/6]

void BasicIntSymbolList::addElement ( size_t  pos,
const std::string &  c 
)
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::IntSymbolList.

Definition at line 142 of file IntSymbolList.cpp.

References bpp::SymbolList< int >::content_, bpp::SymbolList< int >::getAlphabet(), and bpp::SymbolList< int >::size().

◆ addElement() [6/6]

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

Add a character at a certain position in the list.

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

Implemented in bpp::EdSymbolList< T >, bpp::SymbolList< T >, and bpp::BasicProbabilisticSymbolList.

◆ clone()

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

Implements bpp::SymbolList< int >.

Reimplemented in bpp::Site, and bpp::BasicSequence.

Definition at line 196 of file IntSymbolList.h.

References BasicIntSymbolList().

◆ deleteElement()

void bpp::SymbolList< int >::deleteElement ( size_t  pos)
inlinevirtualinherited

Remove the element at position 'pos'.

Parameters
posThe position of the element to remove.

Implements bpp::CruxSymbolList.

Reimplemented in bpp::EdSymbolList< int >.

Definition at line 185 of file SymbolList.h.

◆ deleteElements()

void bpp::SymbolList< int >::deleteElements ( size_t  pos,
size_t  len 
)
inlinevirtualinherited

Remove the elements at position 'pos'.

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

Implements bpp::CruxSymbolList.

Reimplemented in bpp::EdSymbolList< int >.

Definition at line 192 of file SymbolList.h.

◆ getAlphabet()

const Alphabet* bpp::SymbolList< int >::getAlphabet ( ) const
inlinevirtualinherited

Get the alphabet associated to the list.

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

Implements bpp::CruxSymbolList.

Definition at line 169 of file SymbolList.h.

◆ getChar()

string BasicIntSymbolList::getChar ( size_t  pos) const
virtual

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

Parameters
posThe position of the character to retrieve.

Implements bpp::IntSymbolList.

Reimplemented in bpp::BasicSequence.

Definition at line 160 of file IntSymbolList.cpp.

References bpp::SymbolList< int >::content_, bpp::SymbolList< int >::getAlphabet(), bpp::Alphabet::intToChar(), and bpp::SymbolList< int >::size().

Referenced by bpp::BasicSequence::getChar(), and bpp::SiteContainerTools::resolveDottedAlignment().

◆ getContent()

virtual const std::vector<int >& bpp::SymbolList< int >::getContent ( ) const
inlinevirtualinherited

Implements bpp::CoreSymbolList< T >.

Definition at line 178 of file SymbolList.h.

◆ getElement()

virtual const int & bpp::SymbolList< int >::getElement ( size_t  pos) const
inlinevirtualinherited

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

Parameters
posThe position of the character to retrieve.

Implements bpp::CoreSymbolList< T >.

Definition at line 220 of file SymbolList.h.

◆ getStateValueAt()

virtual double bpp::BasicIntSymbolList::getStateValueAt ( size_t  siteIndex,
int  state 
) const
inlinevirtual

◆ getValue()

virtual const int & bpp::SymbolList< int >::getValue ( size_t  pos) const
inlinevirtualinherited

checked access to a character in list.

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

Implements bpp::CoreSymbolList< T >.

Definition at line 227 of file SymbolList.h.

◆ operator()()

virtual double bpp::BasicIntSymbolList::operator() ( size_t  siteIndex,
int  state 
) const
inlinevirtual

◆ operator=() [1/2]

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

The assignment operator.

Definition at line 84 of file IntSymbolList.cpp.

References bpp::SymbolList< T >::operator=().

◆ operator=() [2/2]

BasicIntSymbolList& bpp::BasicIntSymbolList::operator= ( const IntSymbolList list)

The generic assignment operator.

Referenced by bpp::BasicSequence::operator=(), and bpp::Site::operator=().

◆ operator[]() [1/2]

virtual int & bpp::SymbolList< int >::operator[] ( size_t  pos)
inlinevirtualinherited

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::CoreSymbolList< T >.

Definition at line 236 of file SymbolList.h.

◆ operator[]() [2/2]

virtual const int & bpp::SymbolList< int >::operator[] ( size_t  pos) const
inlinevirtualinherited

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::CoreSymbolList< T >.

Definition at line 234 of file SymbolList.h.

◆ setContent() [1/3]

void BasicIntSymbolList::setContent ( const std::vector< int > &  list)
virtual

◆ setContent() [2/3]

void BasicIntSymbolList::setContent ( const std::vector< std::string > &  list)
virtual

◆ setContent() [3/3]

template<class T >
virtual void bpp::CoreSymbolList< 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 internaly stored.

Implemented in bpp::EdSymbolList< T >, bpp::SymbolList< T >, and bpp::BasicProbabilisticSymbolList.

Referenced by bpp::Pasta::nextSequence().

◆ setElement() [1/3]

void bpp::SymbolList< int >::setElement ( size_t  pos,
const T &  c 
)
inlineinherited

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

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

Definition at line 212 of file SymbolList.h.

◆ setElement() [2/3]

void BasicIntSymbolList::setElement ( size_t  pos,
const std::string &  c 
)
virtual

◆ setElement() [3/3]

template<class T >
virtual void bpp::CoreSymbolList< 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::EdSymbolList< T >, bpp::SymbolList< T >, and bpp::BasicProbabilisticSymbolList.

Referenced by bpp::SequenceTools::complement(), bpp::SequenceTools::invert(), bpp::SequenceTools::invertComplement(), bpp::SequenceTools::replaceStopsWithGaps(), and bpp::AlignedSequenceContainer::setSite().

◆ shuffle()

virtual void bpp::SymbolList< int >::shuffle ( )
inlinevirtualinherited

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

Implements bpp::CruxSymbolList.

Definition at line 238 of file SymbolList.h.

◆ size()

size_t bpp::SymbolList< int >::size ( ) const
inlinevirtualinherited

Get the number of elements in the list.

Returns
The number of sites in the list.

Implements bpp::CruxSymbolList.

Definition at line 171 of file SymbolList.h.

◆ toString()

string BasicIntSymbolList::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.

Reimplemented from bpp::SymbolList< int >.

Reimplemented in bpp::BasicSequence.

Definition at line 128 of file IntSymbolList.cpp.

References bpp::SymbolList< int >::content_, bpp::StringSequenceTools::decodeSequence(), and bpp::SymbolList< int >::getAlphabet().

Referenced by bpp::BasicSequence::toString().

Member Data Documentation

◆ alphabet_

const Alphabet* bpp::SymbolList< int >::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 79 of file SymbolList.h.

◆ content_

std::vector<int > bpp::SymbolList< int >::content_
protectedinherited

The list content.

Definition at line 85 of file SymbolList.h.


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