bpp-seq  2.4.0
bpp::Site Class Reference

The Site class. More...

#include <Bpp/Seq/Site.h>

+ Inheritance diagram for bpp::Site:
+ Collaboration diagram for bpp::Site:

Public Member Functions

 Site (const Alphabet *alpha)
 Build a new void Site object with the specified alphabet. More...
 
 Site (const Alphabet *alpha, int position)
 Build a new void Site object with the specified alphabet and position. More...
 
 Site (const std::vector< std::string > &site, const Alphabet *alpha)
 Build a new Site object with the specified alphabet. The content of the site is initialized from a vector of characters. More...
 
 Site (const std::vector< std::string > &site, const Alphabet *alpha, int position)
 Build a new Site object with the specified alphabet and position. The content of the site is initialized from a vector of characters. More...
 
 Site (const std::vector< int > &site, const Alphabet *alpha)
 Build a new Site object with the specified alphabet. The content of the site is initialized from a vector of integers. More...
 
 Site (const std::vector< int > &site, const Alphabet *alpha, int position)
 Build a new Site object with the specified alphabet and position. The content of the site is initialized from a vector of integers. More...
 
 Site (const Site &site)
 The copy constructor. More...
 
Siteoperator= (const Site &s)
 The assignment operator. More...
 
virtual ~Site ()
 
virtual const AlphabetgetAlphabet () const
 Get the alphabet associated to the list. More...
 
virtual size_t size () const
 Get the number of elements in the list. More...
 
virtual void setContent (const std::vector< int > &list)
 Set the whole content of the list. More...
 
virtual void setContent (const std::vector< std::string > &list)
 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)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, const std::string &c)
 Add a character at a certain position in the list. More...
 
virtual void addElement (int v)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, int v)
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const std::string &c)
 Set the element at position 'pos' to character 'c'. More...
 
virtual void setElement (size_t pos, int v)
 Set the element at position 'pos' to character 'v'. More...
 
virtual void deleteElement (size_t pos)
 Delete the element at position 'pos'. More...
 
virtual void deleteElements (size_t pos, size_t len)
 Delete the elements at position 'pos'. More...
 
virtual std::string getChar (size_t pos) const
 Get the element at position 'pos' as a character. More...
 
virtual int getValue (size_t pos) const
 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
Siteclone () const
 
Setting/getting the position of the site.
virtual int getPosition () const
 Get the position of this site. More...
 
virtual void setPosition (int position)
 Set the position of this site. More...
 

Protected Attributes

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

Detailed Description

The Site class.

Define specific attributes and methods for sites manipulation. It is very similar to the Sequence object (a site is a vertical sequence!), and characters at each position are coded as integers. Sites have a 'position' attribute. This attribute stands for an indice in a an alignment, and may be used as a unique identifier, in the same manner that names identify sequence objects. But for now, we do not allow to construct a Site directly from a string. This should not be a constraint, since you never read sites directly from a file.

Definition at line 62 of file Site.h.

Constructor & Destructor Documentation

Site::Site ( const Alphabet alpha)

Build a new void Site object with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 54 of file Site.cpp.

Referenced by clone().

Site::Site ( const Alphabet alpha,
int  position 
)

Build a new void Site object with the specified alphabet and position.

Parameters
alphaThe alphabet to use.
positionThe position attribute for this site.

Definition at line 56 of file Site.cpp.

Site::Site ( const std::vector< std::string > &  site,
const Alphabet alpha 
)

Build a new Site object with the specified alphabet. The content of the site is initialized from a vector of characters.

Parameters
siteThe content of the site.
alphaThe alphabet to use.
Exceptions
BadCharExceptionIf the content does not match the specified alphabet.

Definition at line 58 of file Site.cpp.

Site::Site ( const std::vector< std::string > &  site,
const Alphabet alpha,
int  position 
)

Build a new Site object with the specified alphabet and position. The content of the site is initialized from a vector of characters.

Parameters
siteThe content of the site.
alphaThe alphabet to use.
positionThe position attribute for this site.
Exceptions
BadCharExceptionIf the content does not match the specified alphabet.

Definition at line 60 of file Site.cpp.

Site::Site ( const std::vector< int > &  site,
const Alphabet alpha 
)

Build a new Site object with the specified alphabet. The content of the site is initialized from a vector of integers.

Parameters
siteThe content of the site.
alphaThe alphabet to use.
Exceptions
BadIntExceptionIf the content does not match the specified alphabet.

Definition at line 62 of file Site.cpp.

Site::Site ( const std::vector< int > &  site,
const Alphabet alpha,
int  position 
)

Build a new Site object with the specified alphabet and position. The content of the site is initialized from a vector of integers.

Parameters
siteThe content of the site.
alphaThe alphabet to use.
positionThe position attribute for this site.
Exceptions
BadIntExceptionIf the content does not match the specified alphabet.

Definition at line 64 of file Site.cpp.

Site::Site ( const Site site)

The copy constructor.

Definition at line 68 of file Site.cpp.

virtual bpp::Site::~Site ( )
inlinevirtual

Definition at line 136 of file Site.h.

Member Function Documentation

void BasicSymbolList::addElement ( const std::string &  c)
virtualinherited

Add a character to the end of the list.

Parameters
cThe character to add, given as a string.

Implements bpp::SymbolList.

Definition at line 127 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::Alphabet::charToInt(), and bpp::BasicSymbolList::content_.

Referenced by bpp::NucleicAcidsReplication::reverse(), and bpp::NucleicAcidsReplication::translate().

void BasicSymbolList::addElement ( size_t  pos,
const std::string &  c 
)
virtualinherited

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

Definition at line 134 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::Alphabet::charToInt(), bpp::BasicSymbolList::content_, and bpp::BasicSymbolList::size().

void BasicSymbolList::addElement ( int  v)
virtualinherited

Add a character to the end of the list.

Parameters
vThe character to add, given as an int.

Implements bpp::SymbolList.

Definition at line 187 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, and bpp::Alphabet::intToChar().

void BasicSymbolList::addElement ( size_t  pos,
int  v 
)
virtualinherited

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
vThe character to add, given as an int.

Implements bpp::SymbolList.

Definition at line 196 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, bpp::Alphabet::intToChar(), and bpp::BasicSymbolList::size().

void BasicSymbolList::deleteElement ( size_t  pos)
virtualinherited

Delete the element at position 'pos'.

Parameters
posThe position of the element to delete.

Implements bpp::SymbolList.

Definition at line 169 of file SymbolList.cpp.

References bpp::BasicSymbolList::content_, and bpp::BasicSymbolList::size().

void BasicSymbolList::deleteElements ( size_t  pos,
size_t  len 
)
virtualinherited

Delete the elements at position 'pos'.

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

Implements bpp::SymbolList.

Definition at line 178 of file SymbolList.cpp.

References bpp::BasicSymbolList::content_, and bpp::BasicSymbolList::size().

virtual const Alphabet* bpp::BasicSymbolList::getAlphabet ( ) const
inlinevirtualinherited
string BasicSymbolList::getChar ( size_t  pos) const
virtualinherited

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

Parameters
posThe position of the character to retrieve.

Implements bpp::SymbolList.

Definition at line 151 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, bpp::Alphabet::intToChar(), and bpp::BasicSymbolList::size().

Referenced by bpp::SiteContainerTools::resolveDottedAlignment().

int BasicSymbolList::getValue ( size_t  pos) const
virtualinherited

Get the element at position 'pos' as an int.

Parameters
posThe position of the character to retrieve.

Implements bpp::SymbolList.

Definition at line 218 of file SymbolList.cpp.

References bpp::BasicSymbolList::content_, and bpp::BasicSymbolList::size().

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

Site & Site::operator= ( const Site s)

The assignment operator.

Definition at line 70 of file Site.cpp.

References bpp::AbstractCoreSite::operator=(), and bpp::BasicSymbolList::operator=().

virtual const int& bpp::BasicSymbolList::operator[] ( size_t  i) const
inlinevirtualinherited

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

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implements bpp::SymbolList.

Definition at line 364 of file SymbolList.h.

virtual int& bpp::BasicSymbolList::operator[] ( size_t  i)
inlinevirtualinherited

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

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implements bpp::SymbolList.

Definition at line 366 of file SymbolList.h.

void BasicSymbolList::setContent ( const std::vector< int > &  list)
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.

Implements bpp::SymbolList.

Reimplemented in bpp::BasicSequence.

Definition at line 107 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, and bpp::Alphabet::isIntInAlphabet().

Referenced by bpp::BasicSymbolList::BasicSymbolList(), and bpp::BasicSequence::setContent().

void BasicSymbolList::setContent ( const std::vector< std::string > &  list)
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.

Implements bpp::SymbolList.

Reimplemented in bpp::BasicSequence.

Definition at line 91 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::Alphabet::charToInt(), bpp::BasicSymbolList::content_, and bpp::Alphabet::isCharInAlphabet().

void BasicSymbolList::setElement ( size_t  pos,
const std::string &  c 
)
virtualinherited

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

Parameters
posThe position of the character to set.
cThe value of the element, given as a string.

Implements bpp::SymbolList.

Definition at line 142 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::Alphabet::charToInt(), bpp::BasicSymbolList::content_, and bpp::BasicSymbolList::size().

void BasicSymbolList::setElement ( size_t  pos,
int  v 
)
virtualinherited

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

Parameters
posThe position of the character to set.
vThe value of the element, given as an int.

Implements bpp::SymbolList.

Definition at line 207 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, bpp::Alphabet::intToChar(), and bpp::BasicSymbolList::size().

virtual void bpp::Site::setPosition ( int  position)
inlinevirtual

Set the position of this site.

Parameters
positionThe new position of the site.

Reimplemented from bpp::AbstractCoreSite.

Definition at line 166 of file Site.h.

References bpp::operator<(), bpp::operator==(), and bpp::AbstractCoreSite::setPosition().

Referenced by bpp::VectorSiteContainer::addSite().

virtual void bpp::BasicSymbolList::shuffle ( )
inlinevirtualinherited

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

Implements bpp::SymbolList.

Definition at line 368 of file SymbolList.h.

virtual size_t bpp::BasicSymbolList::size ( ) const
inlinevirtualinherited

Get the number of elements in the list.

Returns
The number of sites in the list.

Implements bpp::SymbolList.

Definition at line 336 of file SymbolList.h.

References bpp::SymbolList::addElement(), bpp::SymbolList::deleteElement(), bpp::SymbolList::deleteElements(), bpp::SymbolList::getChar(), bpp::SymbolList::getValue(), bpp::SymbolList::setContent(), bpp::SymbolList::setElement(), and bpp::SymbolList::toString().

Referenced by bpp::BasicSymbolList::addElement(), bpp::VectorSiteContainer::addSite(), bpp::CompressedVectorSiteContainer::addSite(), bpp::AlignedSequenceContainer::addSite(), bpp::SiteTools::areSitesIdentical(), bpp::BasicSymbolList::deleteElement(), bpp::BasicSymbolList::deleteElements(), bpp::CodonSiteTools::fixedDifferences(), bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::BasicSymbolList::getChar(), bpp::SiteTools::getMajorAllele(), bpp::SiteTools::getMajorAlleleFrequency(), bpp::SiteTools::getMinorAllele(), bpp::SiteTools::getMinorAlleleFrequency(), bpp::SiteTools::getNumberOfDistinctCharacters(), bpp::CompressedVectorSiteContainer::getSiteIndex_(), bpp::BasicSymbolList::getValue(), bpp::SiteTools::hasGap(), bpp::CodonSiteTools::hasGapOrStop(), bpp::SiteTools::hasSingleton(), bpp::CodonSiteTools::hasStop(), bpp::SiteTools::hasUnknown(), bpp::SiteTools::heterozygosity(), bpp::SiteTools::isComplete(), bpp::SiteTools::isConstant(), bpp::SiteTools::isDoubleton(), bpp::CodonSiteTools::isFourFoldDegenerated(), bpp::SiteTools::isGapOnly(), bpp::SiteTools::isGapOrUnresolvedOnly(), bpp::CodonSiteTools::isMonoSitePolymorphic(), bpp::SiteTools::isParsimonyInformativeSite(), bpp::CodonSiteTools::isSynonymousPolymorphic(), bpp::SiteTools::isTriplet(), bpp::SiteTools::jointEntropy(), bpp::CodonSiteTools::meanNumberOfSynonymousPositions(), bpp::SiteTools::mutualInformation(), bpp::CodonSiteTools::numberOfNonSynonymousSubstitutions(), bpp::CodonSiteTools::numberOfSubstitutions(), bpp::operator==(), bpp::CodonSiteTools::piNonSynonymous(), bpp::CodonSiteTools::piSynonymous(), bpp::BasicSymbolList::setElement(), bpp::VectorSiteContainer::setSite(), bpp::CompressedVectorSiteContainer::setSite(), bpp::AlignedSequenceContainer::setSite(), bpp::SiteTools::variabilityFactorial(), and bpp::SiteTools::variabilityShannon().

string BasicSymbolList::toString ( ) const
virtualinherited

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

Definition at line 120 of file SymbolList.cpp.

References bpp::BasicSymbolList::alphabet_, bpp::BasicSymbolList::content_, and bpp::StringSequenceTools::decodeSequence().

Member Data Documentation


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