bpp-seq
2.2.0
|
A basic SymbolList object. More...
#include <Bpp/Seq/SymbolList.h>
Public Member Functions | |
BasicSymbolList (const Alphabet *alpha) | |
Build a new void BasicSymbolList object with the specified alphabet. More... | |
BasicSymbolList (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... | |
BasicSymbolList (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... | |
BasicSymbolList (const SymbolList &list) | |
The generic copy constructor. More... | |
BasicSymbolList (const BasicSymbolList &list) | |
The copy constructor. More... | |
BasicSymbolList & | operator= (const SymbolList &list) |
The generic assignment operator. More... | |
BasicSymbolList & | operator= (const BasicSymbolList &list) |
The assignment operator. More... | |
virtual | ~BasicSymbolList () |
virtual const Alphabet * | getAlphabet () 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 | |
BasicSymbolList * | clone () const |
Protected Attributes | |
std::vector< int > | content_ |
The list content. More... | |
Private Attributes | |
const Alphabet * | alphabet_ |
The Alphabet attribute must be initialized in constructor and then can never be changed. More... | |
A basic 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.
Definition at line 264 of file SymbolList.h.
|
inline |
Build a new void BasicSymbolList object with the specified alphabet.
alpha | The alphabet to use. |
Definition at line 288 of file SymbolList.h.
Referenced by clone().
BasicSymbolList::BasicSymbolList | ( | 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.
list | The content of the site. |
alpha | The alphabet to use. |
BadCharException | If the content does not match the specified alphabet. |
Definition at line 49 of file SymbolList.cpp.
BasicSymbolList::BasicSymbolList | ( | 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.
list | The content of the site. |
alpha | The alphabet to use. |
BadIntException | If the content does not match the specified alphabet. |
Definition at line 55 of file SymbolList.cpp.
BasicSymbolList::BasicSymbolList | ( | const SymbolList & | list | ) |
The generic copy constructor.
Definition at line 63 of file SymbolList.cpp.
BasicSymbolList::BasicSymbolList | ( | const BasicSymbolList & | list | ) |
The copy constructor.
Definition at line 66 of file SymbolList.cpp.
|
inlinevirtual |
Definition at line 344 of file SymbolList.h.
|
virtual |
Add a character to the end of the list.
c | The character to add, given as a string. |
Implements bpp::SymbolList.
Definition at line 121 of file SymbolList.cpp.
Referenced by bpp::NucleicAcidsReplication::reverse(), and bpp::NucleicAcidsReplication::translate().
|
virtual |
Add a character at a certain position in the list.
pos | The postion where to insert the element. |
c | The character to add, given as a string. |
Implements bpp::SymbolList.
Definition at line 128 of file SymbolList.cpp.
|
virtual |
Add a character to the end of the list.
v | The character to add, given as an int. |
Implements bpp::SymbolList.
Definition at line 181 of file SymbolList.cpp.
|
virtual |
Add a character at a certain position in the list.
pos | The postion where to insert the element. |
v | The character to add, given as an int. |
Implements bpp::SymbolList.
Definition at line 190 of file SymbolList.cpp.
|
inlinevirtual |
Implements bpp::SymbolList.
Definition at line 340 of file SymbolList.h.
References BasicSymbolList().
|
virtual |
Delete the element at position 'pos'.
pos | The position of the element to delete. |
Implements bpp::SymbolList.
Definition at line 163 of file SymbolList.cpp.
Referenced by bpp::AlignedSequenceContainer::removeSite().
|
virtual |
Delete the elements at position 'pos'.
pos | The position of the first element to delete. |
len | The length of the region to delete. |
Implements bpp::SymbolList.
Definition at line 172 of file SymbolList.cpp.
|
inlinevirtual |
Get the alphabet associated to the list.
Implements bpp::SymbolList.
Definition at line 348 of file SymbolList.h.
References alphabet_.
Referenced by bpp::SiteTools::areSitesIdentical(), bpp::SiteTools::hasGap(), bpp::SiteTools::hasUnknown(), bpp::SiteTools::isComplete(), bpp::SiteTools::isGapOnly(), bpp::SiteTools::isGapOrUnresolvedOnly(), operator=(), bpp::BasicSequence::setToSizeL(), bpp::BasicSequence::setToSizeR(), and bpp::AbstractTransliterator::translate().
|
virtual |
Get the element at position 'pos' as a character.
pos | The position of the character to retrieve. |
Implements bpp::SymbolList.
Definition at line 145 of file SymbolList.cpp.
Referenced by bpp::SiteContainerTools::resolveDottedAlignment().
|
inlinevirtual |
Get the whole content of the list as a vector of int.
Implements bpp::SymbolList.
Definition at line 352 of file SymbolList.h.
References content_.
Referenced by bpp::Site::operator=(), and operator=().
|
virtual |
Get the element at position 'pos' as an int.
pos | The position of the character to retrieve. |
Implements bpp::SymbolList.
Definition at line 212 of file SymbolList.cpp.
Referenced by bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::CodonSiteTools::isFourFoldDegenerated(), and bpp::CodonSiteTools::numberOfSubsitutions().
BasicSymbolList & BasicSymbolList::operator= | ( | const SymbolList & | list | ) |
The generic assignment operator.
Definition at line 69 of file SymbolList.cpp.
References alphabet_, content_, bpp::SymbolList::getAlphabet(), and bpp::SymbolList::getContent().
Referenced by bpp::BasicSequence::operator=().
BasicSymbolList & BasicSymbolList::operator= | ( | const BasicSymbolList & | list | ) |
The assignment operator.
Definition at line 76 of file SymbolList.cpp.
References alphabet_, content_, getAlphabet(), and getContent().
|
inlinevirtual |
Operator [] overloaded for quick access to a character in list.
i | The position to retrieve. |
Implements bpp::SymbolList.
Definition at line 380 of file SymbolList.h.
References content_.
|
inlinevirtual |
Operator [] overloaded for quick access to a character in list.
i | The position to retrieve. |
Implements bpp::SymbolList.
Definition at line 382 of file SymbolList.h.
References content_.
|
virtual |
Set the whole content of the list.
list | The new content of the list. |
Implements bpp::SymbolList.
Reimplemented in bpp::BasicSequence.
Definition at line 101 of file SymbolList.cpp.
Referenced by bpp::BasicSequence::setContent().
|
virtual |
Set the whole content of the list.
list | The new content of the list. |
Implements bpp::SymbolList.
Reimplemented in bpp::BasicSequence.
Definition at line 85 of file SymbolList.cpp.
|
virtual |
Set the element at position 'pos' to character 'c'.
pos | The position of the character to set. |
c | The value of the element, given as a string. |
Implements bpp::SymbolList.
Definition at line 136 of file SymbolList.cpp.
|
virtual |
Set the element at position 'pos' to character 'v'.
pos | The position of the character to set. |
v | The value of the element, given as an int. |
Implements bpp::SymbolList.
Definition at line 201 of file SymbolList.cpp.
|
inlinevirtual |
Randomly shuffle the content of the list, with linear complexity.
Implements bpp::SymbolList.
Definition at line 384 of file SymbolList.h.
References content_.
|
inlinevirtual |
Get the number of elements in the list.
Implements bpp::SymbolList.
Definition at line 350 of file SymbolList.h.
References content_.
Referenced by bpp::SiteTools::areSitesIdentical(), bpp::CompressedVectorSiteContainer::getSiteIndex_(), bpp::SiteTools::hasGap(), bpp::SiteTools::hasUnknown(), bpp::SiteTools::isComplete(), bpp::CodonSiteTools::isFourFoldDegenerated(), bpp::SiteTools::isGapOnly(), bpp::SiteTools::isGapOrUnresolvedOnly(), bpp::CodonSiteTools::numberOfSubsitutions(), bpp::operator==(), and bpp::WordAlphabet::reverse().
|
virtual |
Convert the list as a string.
This method is useful for dumping a list to a file or to the screen for display.
Implements bpp::SymbolList.
Definition at line 114 of file SymbolList.cpp.
References alphabet_, content_, and bpp::StringSequenceTools::decodeSequence().
|
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 274 of file SymbolList.h.
Referenced by getAlphabet(), operator=(), and toString().
|
protected |
The list content.
Definition at line 280 of file SymbolList.h.
Referenced by getContent(), bpp::Site::operator=(), operator=(), operator[](), bpp::BasicSequence::setToSizeL(), bpp::BasicSequence::setToSizeR(), shuffle(), size(), and toString().