bpp-seq  2.2.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
bpp::AlignedSequenceContainer Class Reference

Aligned sequences container. More...

#include <Bpp/Seq/Container/AlignedSequenceContainer.h>

+ Inheritance diagram for bpp::AlignedSequenceContainer:
+ Collaboration diagram for bpp::AlignedSequenceContainer:

Public Member Functions

 AlignedSequenceContainer (const Alphabet *alpha)
 Build a new empty container with the specified alphabet. More...
 
 AlignedSequenceContainer (const AlignedSequenceContainer &asc)
 Copy constructor. More...
 
 AlignedSequenceContainer (const SiteContainer &sc)
 Convert any SiteContainer object into a AlignedSequenceContainer object. More...
 
 AlignedSequenceContainer (const OrderedSequenceContainer &osc) throw (SequenceNotAlignedException)
 Try to coerce an OrderedSequenceContainer object into an AlignedSequenceContainer object. More...
 
AlignedSequenceContaineroperator= (const AlignedSequenceContainer &asc)
 
AlignedSequenceContaineroperator= (const SiteContainer &sc)
 
AlignedSequenceContaineroperator= (const OrderedSequenceContainer &osc) throw (SequenceNotAlignedException)
 
virtual ~AlignedSequenceContainer ()
 
The Clonable interface.
AlignedSequenceContainerclone () const
 
The SiteContainer interface implementation:
const SitegetSite (size_t siteIndex) const throw (IndexOutOfBoundsException)
 Get a site from the container. More...
 
void setSite (size_t siteIndex, const Site &site, bool checkPosition=true) throw (Exception)
 Set a site in the container. More...
 
SiteremoveSite (size_t siteIndex) throw (IndexOutOfBoundsException)
 Remove a site from the container. More...
 
void deleteSite (size_t siteIndex) throw (IndexOutOfBoundsException)
 Delete a site in the container. More...
 
void deleteSites (size_t siteIndex, size_t length) throw (IndexOutOfBoundsException, Exception)
 Delete a continuous range of sites in the container. More...
 
void addSite (const Site &site, bool checkPosition=true) throw (Exception)
 Add a site in the container. More...
 
void addSite (const Site &site, int position, bool checkPosition=true) throw (Exception)
 Add a site in the container. More...
 
void addSite (const Site &site, size_t siteIndex, bool checkPosition=true) throw (Exception)
 Add a site in the container. More...
 
void addSite (const Site &site, size_t siteIndex, int position, bool checkPosition=true) throw (Exception)
 Add a site in the container. More...
 
size_t getNumberOfSites () const
 Get the number of sites in the container. More...
 
Vint getSitePositions () const
 Get all position attributes of sites. More...
 
void reindexSites ()
 Set all positions attributes. More...
 
void clear ()
 Delete all sequences in the container. More...
 
AlignedSequenceContainercreateEmptyContainer () const
 Return a copy of this container, but with no sequence inside. More...
 
Redefinition of VectorSequenceContainer methods, to check for sequence lengths.
void setSequence (const std::string &name, const Sequence &sequence, bool checkName=true) throw (Exception)
 Replace a sequence in the container. More...
 
void setSequence (size_t sequenceIndex, const Sequence &sequence, bool checkName=true) throw (Exception)
 Replace a sequence in the container. More...
 
void addSequence (const Sequence &sequence, bool checkName=true) throw (Exception)
 Add a sequence at the end of the container. More...
 
void addSequence (const Sequence &sequence, size_t sequenceIndex, bool checkName=true) throw (Exception)
 Add a sequence to the container at a particular position. More...
 
The SequenceContainer interface.
bool hasSequence (const std::string &name) const
 Check if a sequence with a given name is present in the container. More...
 
const SequencegetSequence (const std::string &name) const throw (SequenceNotFoundException)
 Retrieve a sequence object from the container. More...
 
SequenceremoveSequence (const std::string &name) throw (SequenceNotFoundException)
 Extract (and remove) a sequence from the container. More...
 
void deleteSequence (const std::string &name) throw (SequenceNotFoundException)
 Delete a sequence of the container. More...
 
size_t getNumberOfSequences () const
 Get the number of sequences in the container. More...
 
std::vector< std::string > getSequencesNames () const
 Get all the names of the sequences in the container. More...
 
void setSequencesNames (const std::vector< std::string > &names, bool checkNames=true) throw (Exception)
 Set all sequence names. More...
 
int & valueAt (const std::string &sequenceName, size_t elementIndex) throw (SequenceNotFoundException, IndexOutOfBoundsException)
 Element access function. More...
 
const int & valueAt (const std::string &sequenceName, size_t elementIndex) const throw (SequenceNotFoundException, IndexOutOfBoundsException)
 Element access function. More...
 
int & valueAt (size_t sequenceIndex, size_t elementIndex) throw (IndexOutOfBoundsException)
 Element access operator. More...
 
const int & valueAt (size_t sequenceIndex, size_t elementIndex) const throw (IndexOutOfBoundsException)
 Element access operator. More...
 
int & operator() (const std::string &sequenceName, size_t elementIndex)
 Element access operator. More...
 
const int & operator() (const std::string &sequenceName, size_t elementIndex) const
 Element access operator. More...
 
int & operator() (size_t sequenceIndex, size_t elementIndex)
 Element access operator. More...
 
const int & operator() (size_t sequenceIndex, size_t elementIndex) const
 Element access operator. More...
 
The OrderedSequenceContainer interface.
const SequencegetSequence (size_t sequenceIndex) const throw (IndexOutOfBoundsException)
 Retrieve a sequence object from the container. More...
 
SequenceremoveSequence (size_t sequenceIndex) throw (IndexOutOfBoundsException)
 Extract (and remove) a sequence from the container. More...
 
void deleteSequence (size_t sequenceIndex) throw (IndexOutOfBoundsException)
 Delete a sequence of the container. More...
 
void setComments (const std::string &name, const Comments &comments) throw (SequenceNotFoundException)
 Set the comments of a particular sequence. More...
 
void setComments (size_t sequenceIndex, const Comments &comments) throw (IndexOutOfBoundsException)
 Set the comments of a particular sequence. More...
 
size_t getSequencePosition (const std::string &name) const throw (SequenceNotFoundException)
 Get the position of a sequence in sequence container from its name. More...
 
From the SequenceContainer interface
const AlphabetgetAlphabet () const
 Get sequence container's alphabet. More...
 
const std::vector< int > & getContent (const std::string &name) const throw (SequenceNotFoundException)
 Get the content of a sequence. More...
 
std::string toString (const std::string &name) const throw (SequenceNotFoundException)
 Convert a particular sequence to a string. More...
 
const Comments & getComments (const std::string &name) const throw (SequenceNotFoundException)
 Get comments of a particular sequence. More...
 
const Comments & getGeneralComments () const
 Get the comments of this container. More...
 
void setGeneralComments (const Comments &comments)
 Set the comments of this container. More...
 
void deleteGeneralComments ()
 Delete the comments associated to this container. More...
 
From the OrderedSequenceContainer interface
virtual const std::vector< int > & getContent (size_t sequenceIndex) const throw (IndexOutOfBoundsException)
 Get the content of a sequence. More...
 
virtual std::string toString (size_t sequenceIndex) const throw (IndexOutOfBoundsException)
 Convert a particular sequence to a string. More...
 
virtual const Comments & getComments (size_t sequenceIndex) const throw (IndexOutOfBoundsException)
 Get comments of a particular sequence. More...
 
virtual const std::string & getName (size_t sequenceIndex) const throw (IndexOutOfBoundsException)
 Get the name of a particular sequence. More...
 

Protected Member Functions

bool checkSize_ (const Sequence &sequence)
 Check sequence's size before insertion in sequence container. More...
 
AbstractSequenceContainer methods.
SequencegetSequence_ (size_t i) throw (IndexOutOfBoundsException)
 
SequencegetSequence_ (const std::string &name) throw (SequenceNotFoundException)
 

Private Attributes

std::vector< int > positions_
 
size_t length_
 
std::vector< Site * > sites_
 

Detailed Description

Aligned sequences container.

This class inherits from the VectorSequenceContainer and add site access. Sequence addition methods are re-defined to check for sequence lengths. Sequence access is in $O(1)$, and site access in $O(n)$, where $n$ is the number of sequences in the container.

See VectorSiteContainer for an alternative implementation.

See Also
VectorSequenceContainer, Sequence, Site, VectorSiteContainer

Definition at line 68 of file AlignedSequenceContainer.h.

Constructor & Destructor Documentation

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

Build a new empty container with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 95 of file AlignedSequenceContainer.h.

References reindexSites().

Referenced by clone().

bpp::AlignedSequenceContainer::AlignedSequenceContainer ( const AlignedSequenceContainer asc)
inline

Copy constructor.

Parameters
ascThe container to copy.

Definition at line 109 of file AlignedSequenceContainer.h.

bpp::AlignedSequenceContainer::AlignedSequenceContainer ( const SiteContainer sc)
inline

Convert any SiteContainer object into a AlignedSequenceContainer object.

Parameters
scThe container to copy.

Definition at line 121 of file AlignedSequenceContainer.h.

AlignedSequenceContainer::AlignedSequenceContainer ( const OrderedSequenceContainer osc)
throw (SequenceNotAlignedException
)

Try to coerce an OrderedSequenceContainer object into an AlignedSequenceContainer object.

Sequences in osc will be considered alligned, and have the same number of sites.

Parameters
oscThe ordered container to coerce.
Exceptions
SequenceNotAlignedExceptionIf sequences in osc do not have the same length.

Definition at line 54 of file AlignedSequenceContainer.cpp.

AlignedSequenceContainer::~AlignedSequenceContainer ( )
virtual

Class destructor:

Definition at line 121 of file AlignedSequenceContainer.cpp.

Member Function Documentation

void AlignedSequenceContainer::addSequence ( const Sequence sequence,
bool  checkName = true 
)
throw (Exception
)
virtual

Add a sequence at the end of the container.

The sequence is copied into the container. If checkNames is set to true, the method check if the name of the sequence is already used in the container, and sends an exception if it is the case. Otherwise, do not check the name: the method is hence faster, but use it at your own risks!

Parameters
sequenceThe sequence to add.
checkNameTell if the method must check the name of the sequence before adding it.
Exceptions
ExceptionIf the sequence couldn't be added to the container.

Reimplemented from bpp::VectorSequenceContainer.

Definition at line 474 of file AlignedSequenceContainer.cpp.

References bpp::VectorSequenceContainer::addSequence().

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

void AlignedSequenceContainer::addSequence ( const Sequence sequence,
size_t  sequenceIndex,
bool  checkName = true 
)
throw (Exception
)
virtual

Add a sequence to the container at a particular position.

The sequence is copied into the container. If checkName is set to true, the method check if the name of the sequence is already used in the container, and sends an exception if it is the case. Otherwise, do not check the name: the method is hence faster, but use it at your own risks!

Parameters
sequenceThe sequence to add.
sequenceIndexThe position where to insert the new sequence. All the following sequences will be pushed.
checkNameTell if the method must check the name of the sequence before adding it.
Exceptions
ExceptionIf the sequence couldn't be added to the container.

Reimplemented from bpp::VectorSequenceContainer.

Definition at line 491 of file AlignedSequenceContainer.cpp.

References bpp::VectorSequenceContainer::addSequence().

void AlignedSequenceContainer::addSite ( const Site site,
bool  checkPosition = true 
)
throw (Exception
)
virtual

Add a site in the container.

Parameters
siteThe site to add.
checkPositionLook if the position of the new site match a position attribute in the container.
Exceptions
ExceptionIf the specified site does not exists or is not correct.

Implements bpp::SiteContainer.

Definition at line 271 of file AlignedSequenceContainer.cpp.

void AlignedSequenceContainer::addSite ( const Site site,
int  position,
bool  checkPosition = true 
)
throw (Exception
)
virtual

Add a site in the container.

Parameters
siteThe site to add.
positionThe new position of the site, to superseed the one in 'site'.
checkPositionLook if the position of the new site match a position attribute in the container.
Exceptions
ExceptionIf the specified site does not exists or is not correct.

Implements bpp::SiteContainer.

Definition at line 312 of file AlignedSequenceContainer.cpp.

void AlignedSequenceContainer::addSite ( const Site site,
size_t  siteIndex,
bool  checkPosition = true 
)
throw (Exception
)
virtual

Add a site in the container.

Parameters
siteThe site to add.
siteIndexThe position where to insert the site.
checkPositionLook if the position of the new site match a position attribute in the container.
Exceptions
ExceptionIf the specified site does not exists or is not correct.

Implements bpp::SiteContainer.

Definition at line 352 of file AlignedSequenceContainer.cpp.

void AlignedSequenceContainer::addSite ( const Site site,
size_t  siteIndex,
int  position,
bool  checkPosition = true 
)
throw (Exception
)
virtual

Add a site in the container.

Parameters
siteThe site to add.
siteIndexThe position where to insert the site.
positionThe new position of the site, to superseed the one in 'site'.
checkPositionLook if the position of the new site match a position attribute in the container.
Exceptions
ExceptionIf the specified site does not exists or is not correct.

Implements bpp::SiteContainer.

Definition at line 394 of file AlignedSequenceContainer.cpp.

bool bpp::AlignedSequenceContainer::checkSize_ ( const Sequence sequence)
inlineprotected

Check sequence's size before insertion in sequence container.

Parameters
sequenceThe sequence to check.
Returns
True if sequence length = number of sites in container.

Definition at line 195 of file AlignedSequenceContainer.h.

References length_.

void AlignedSequenceContainer::clear ( )
virtual

Delete all sequences in the container.

Implements bpp::SequenceContainer.

Definition at line 506 of file AlignedSequenceContainer.cpp.

References bpp::VectorSequenceContainer::clear().

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

Implements bpp::SiteContainer.

Definition at line 151 of file AlignedSequenceContainer.h.

References AlignedSequenceContainer().

AlignedSequenceContainer * AlignedSequenceContainer::createEmptyContainer ( ) const
virtual

Return a copy of this container, but with no sequence inside.

This method creates a new SequenceContainer objet. The class of this container depends on the derivative class.

Returns
A new empty container, with the same alphabet as this one.

Implements bpp::SequenceContainer.

Definition at line 514 of file AlignedSequenceContainer.cpp.

References bpp::AbstractSequenceContainer::setGeneralComments().

void bpp::AbstractSequenceContainer::deleteGeneralComments ( )
inlinevirtualinherited

Delete the comments associated to this container.

Implements bpp::SequenceContainer.

Definition at line 150 of file AbstractSequenceContainer.h.

References bpp::AbstractSequenceContainer::comments_.

void bpp::VectorSequenceContainer::deleteSequence ( const std::string &  name)
throw (SequenceNotFoundException
)
inlinevirtualinherited

Delete a sequence of the container.

Parameters
nameThe name of the sequence.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 180 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequencePosition().

void VectorSequenceContainer::deleteSequence ( size_t  sequenceIndex)
throw (IndexOutOfBoundsException
)
virtualinherited

Delete a sequence of the container.

Parameters
sequenceIndexThe position of the sequence.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 272 of file VectorSequenceContainer.cpp.

void AlignedSequenceContainer::deleteSite ( size_t  siteIndex)
throw (IndexOutOfBoundsException
)
virtual

Delete a site in the container.

Parameters
siteIndexThe position of the site in the container.
Exceptions
IndexOutOfBoundsExceptionIf the specified site does not exists.

Implements bpp::SiteContainer.

Definition at line 220 of file AlignedSequenceContainer.cpp.

void AlignedSequenceContainer::deleteSites ( size_t  siteIndex,
size_t  length 
)
throw (IndexOutOfBoundsException,
Exception
)
virtual

Delete a continuous range of sites in the container.

Parameters
siteIndexThe position of the first site in the container.
lengthThe length of the region to delete, starting at pposition siteIndex.
Exceptions
IndexOutOfBoundsExceptionIf the specified range is not valid.

Implements bpp::SiteContainer.

Definition at line 243 of file AlignedSequenceContainer.cpp.

const Alphabet* bpp::AbstractSequenceContainer::getAlphabet ( ) const
inlinevirtualinherited
const Comments& bpp::AbstractSequenceContainer::getComments ( const std::string &  name) const
throw (SequenceNotFoundException
)
inlinevirtualinherited

Get comments of a particular sequence.

Parameters
nameThe name of the sequence.
Returns
The comments associated to sequence with name 'name'.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 134 of file AbstractSequenceContainer.h.

References bpp::Sequence::getComments(), and bpp::OrderedSequenceContainer::getSequence().

Referenced by bpp::CompressedVectorSiteContainer::CompressedVectorSiteContainer(), bpp::VectorSiteContainer::operator=(), bpp::CompressedVectorSiteContainer::operator=(), and bpp::VectorSiteContainer::VectorSiteContainer().

virtual const Comments& bpp::AbstractSequenceContainer::getComments ( size_t  sequenceIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Get comments of a particular sequence.

Parameters
sequenceIndexThe position of the sequence.
Returns
The comments associated to sequence at position 'sequenceIndex'.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 177 of file AbstractSequenceContainer.h.

References bpp::Sequence::getComments(), and bpp::OrderedSequenceContainer::getSequence().

const std::vector<int>& bpp::AbstractSequenceContainer::getContent ( const std::string &  name) const
throw (SequenceNotFoundException
)
inlinevirtualinherited

Get the content of a sequence.

Parameters
nameThe name of the sequence.
Returns
The content of the sequence as a vector of integers.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 124 of file AbstractSequenceContainer.h.

References bpp::SymbolList::getContent(), and bpp::OrderedSequenceContainer::getSequence().

Referenced by bpp::SequenceContainerTools::getCodonPosition().

virtual const std::vector<int>& bpp::AbstractSequenceContainer::getContent ( size_t  sequenceIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Get the content of a sequence.

Parameters
sequenceIndexThe position of the sequence.
Returns
The content of the sequence as a vector of integers.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 167 of file AbstractSequenceContainer.h.

References bpp::SymbolList::getContent(), and bpp::OrderedSequenceContainer::getSequence().

const Comments& bpp::AbstractSequenceContainer::getGeneralComments ( ) const
inlinevirtualinherited
virtual const std::string& bpp::AbstractSequenceContainer::getName ( size_t  sequenceIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Get the name of a particular sequence.

Parameters
sequenceIndexThe position of the sequence.
Returns
The name of the sequence at position 'sequenceIndex'.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 162 of file AbstractSequenceContainer.h.

References bpp::Sequence::getName(), and bpp::OrderedSequenceContainer::getSequence().

Referenced by bpp::VectorSequenceContainer::getSequencesNames(), and bpp::VectorSequenceContainer::hasSequence().

size_t bpp::VectorSequenceContainer::getNumberOfSequences ( ) const
inlinevirtualinherited

Get the number of sequences in the container.

Returns
The number of sequences in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 185 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::sequences_.

Referenced by bpp::VectorSequenceContainer::operator=(), and bpp::VectorSequenceContainer::VectorSequenceContainer().

size_t bpp::AlignedSequenceContainer::getNumberOfSites ( ) const
inlinevirtual

Get the number of sites in the container.

Returns
The number of sites in the container.

Implements bpp::SiteContainer.

Definition at line 168 of file AlignedSequenceContainer.h.

References length_.

Referenced by operator=().

const Sequence & VectorSequenceContainer::getSequence ( const std::string &  name) const
throw (SequenceNotFoundException
)
virtualinherited

Retrieve a sequence object from the container.

Parameters
nameThe name of the sequence.
Returns
A reference toward the Sequence with corresponding name.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 181 of file VectorSequenceContainer.cpp.

Referenced by bpp::VectorSequenceContainer::operator()(), bpp::VectorSequenceContainer::operator=(), bpp::VectorSequenceContainer::valueAt(), and bpp::VectorSequenceContainer::VectorSequenceContainer().

const Sequence & VectorSequenceContainer::getSequence ( size_t  sequenceIndex) const
throw (IndexOutOfBoundsException
)
virtualinherited

Retrieve a sequence object from the container.

Parameters
sequenceIndexThe position of the sequence.
Returns
A reference toward the Sequence object with corresponding name.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 158 of file VectorSequenceContainer.cpp.

Sequence & VectorSequenceContainer::getSequence_ ( size_t  i)
throw (IndexOutOfBoundsException
)
protectedinherited
Sequence & VectorSequenceContainer::getSequence_ ( const std::string &  name)
throw (SequenceNotFoundException
)
protectedinherited

Definition at line 204 of file VectorSequenceContainer.cpp.

size_t VectorSequenceContainer::getSequencePosition ( const std::string &  name) const
throw (SequenceNotFoundException
)
virtualinherited

Get the position of a sequence in sequence container from its name.

Parameters
nameThe name of the sequence.
Returns
The position of the sequence with name 'name', if it exists.
Exceptions
SequenceNotFoundExceptionIf no sequence with name 'name' could be found.

Implements bpp::OrderedSequenceContainer.

Definition at line 217 of file VectorSequenceContainer.cpp.

Referenced by bpp::VectorSequenceContainer::deleteSequence(), bpp::VectorSequenceContainer::removeSequence(), and bpp::VectorSequenceContainer::setSequence().

std::vector< std::string > VectorSequenceContainer::getSequencesNames ( ) const
virtualinherited

Get all the names of the sequences in the container.

Returns
A vector of strings with all sequence names.

Implements bpp::OrderedSequenceContainer.

Definition at line 332 of file VectorSequenceContainer.cpp.

References bpp::AbstractSequenceContainer::getName(), and bpp::VectorSequenceContainer::sequences_.

const Site & AlignedSequenceContainer::getSite ( size_t  siteIndex) const
throw (IndexOutOfBoundsException
)
virtual

Get a site from the container.

Parameters
siteIndexThe position of the site in the container.
Returns
A site objet corresponding to site i in the alignment.
Exceptions
IndexOutOfBoundsExceptionIf the specified site does not exists.

Implements bpp::SiteContainer.

Definition at line 133 of file AlignedSequenceContainer.cpp.

Vint bpp::AlignedSequenceContainer::getSitePositions ( ) const
inlinevirtual

Get all position attributes of sites.

Returns
A vector with all site positions.

Implements bpp::SiteContainer.

Definition at line 169 of file AlignedSequenceContainer.h.

References positions_.

Referenced by operator=().

bool VectorSequenceContainer::hasSequence ( const std::string &  name) const
virtualinherited

Check if a sequence with a given name is present in the container.

Parameters
nameThe name of the sequence.
Returns
True if a sequence with the given name is present in the container.

Implements bpp::SequenceContainer.

Definition at line 168 of file VectorSequenceContainer.cpp.

References bpp::AbstractSequenceContainer::getName(), and bpp::VectorSequenceContainer::sequences_.

int& bpp::VectorSequenceContainer::operator() ( const std::string &  sequenceName,
size_t  elementIndex 
)
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container. This method is faster then the valueAt function, but input parameters are not checked!

Parameters
sequenceNameThe sequence name.
elementIndexThe element position within the sequence.

Implements bpp::SequenceContainer.

Definition at line 202 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence_().

const int& bpp::VectorSequenceContainer::operator() ( const std::string &  sequenceName,
size_t  elementIndex 
) const
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container. This method is faster then the valueAt function, but input parameters are not checked!

Parameters
sequenceNameThe sequence name.
elementIndexThe element position within the sequence.

Implements bpp::SequenceContainer.

Definition at line 207 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence().

int& bpp::VectorSequenceContainer::operator() ( size_t  sequenceIndex,
size_t  elementIndex 
)
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container. This method is faster then the valueAt function, but input parameters are not checked!

Parameters
sequenceIndexThe sequence position.
elementIndexThe element position within the sequence.

Implements bpp::OrderedSequenceContainer.

Definition at line 222 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence_().

const int& bpp::VectorSequenceContainer::operator() ( size_t  sequenceIndex,
size_t  elementIndex 
) const
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container. This method is faster then the valueAt function, but input parameters are not checked!

Parameters
sequenceIndexThe sequence position.
elementIndexThe element position within the sequence.

Implements bpp::OrderedSequenceContainer.

Definition at line 226 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence().

AlignedSequenceContainer & AlignedSequenceContainer::operator= ( const AlignedSequenceContainer asc)
AlignedSequenceContainer & AlignedSequenceContainer::operator= ( const OrderedSequenceContainer osc)
throw (SequenceNotAlignedException
)
void AlignedSequenceContainer::reindexSites ( )
virtual

Set all positions attributes.

Implements bpp::SiteContainer.

Definition at line 435 of file AlignedSequenceContainer.cpp.

Referenced by AlignedSequenceContainer().

Sequence* bpp::VectorSequenceContainer::removeSequence ( const std::string &  name)
throw (SequenceNotFoundException
)
inlinevirtualinherited

Extract (and remove) a sequence from the container.

Parameters
nameThe name of the sequence.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 175 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequencePosition().

Sequence * VectorSequenceContainer::removeSequence ( size_t  sequenceIndex)
throw (IndexOutOfBoundsException
)
virtualinherited

Extract (and remove) a sequence from the container.

Parameters
sequenceIndexThe position of the sequence.
Exceptions
IndexOutOfBoundsExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 258 of file VectorSequenceContainer.cpp.

Site * AlignedSequenceContainer::removeSite ( size_t  siteIndex)
throw (IndexOutOfBoundsException
)
virtual

Remove a site from the container.

The site is not deleted, a pointer toward it is returned.

Parameters
siteIndexThe position of the site in the container.
Returns
A pointer toward site i in the alignment.
Exceptions
IndexOutOfBoundsExceptionIf the specified site does not exists.

Implements bpp::SiteContainer.

Definition at line 190 of file AlignedSequenceContainer.cpp.

References bpp::BasicSymbolList::deleteElement().

void bpp::VectorSequenceContainer::setComments ( const std::string &  name,
const Comments &  comments 
)
throw (SequenceNotFoundException
)
inlinevirtualinherited

Set the comments of a particular sequence.

Parameters
nameThe name of the sequence.
commentsThe comments to set to sequence with name 'name'.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Reimplemented from bpp::AbstractSequenceContainer.

Definition at line 238 of file VectorSequenceContainer.h.

References bpp::AbstractSequenceContainer::setComments().

void VectorSequenceContainer::setComments ( size_t  sequenceIndex,
const Comments &  comments 
)
throw (IndexOutOfBoundsException
)
virtualinherited

Set the comments of a particular sequence.

Parameters
sequenceIndexThe position of the sequence.
commentsThe comments to set to sequence with position 'i'.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::AbstractSequenceContainer.

Definition at line 384 of file VectorSequenceContainer.cpp.

void bpp::AbstractSequenceContainer::setGeneralComments ( const Comments &  comments)
inlinevirtualinherited
void AlignedSequenceContainer::setSequence ( const std::string &  name,
const Sequence sequence,
bool  checkName = true 
)
throw (Exception
)
virtual

Replace a sequence in the container.

Parameters
nameThe name of the sequence.
sequenceThe sequence to add.
checkNameTell if the container must check if the name of the sequence is already used in the container before adding it.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.
ExceptionAny other kind of exception, if the name of the sequence is already used, are whatever else depending on the implementation.

Implements bpp::OrderedSequenceContainer.

Definition at line 461 of file AlignedSequenceContainer.cpp.

References bpp::VectorSequenceContainer::setSequence().

void AlignedSequenceContainer::setSequence ( size_t  sequenceIndex,
const Sequence sequence,
bool  checkName = true 
)
throw (Exception
)
virtual

Replace a sequence in the container.

Parameters
sequenceIndexThe position of the sequence.
sequenceThe sequence to add.
checkNameTell if the container must check if the name of the sequence is already used in the container before adding it.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.
ExceptionAny other kind of exception.

Implements bpp::OrderedSequenceContainer.

Definition at line 446 of file AlignedSequenceContainer.cpp.

References bpp::VectorSequenceContainer::setSequence().

void VectorSequenceContainer::setSequencesNames ( const std::vector< std::string > &  names,
bool  checkNames = true 
)
throw (Exception
)
virtualinherited

Set all sequence names.

Parameters
namesA vector of strings with all sequence names. Its size must be strictly equal to the the size of the container (the number of sequences).
checkNamesTell if the container must check if the name of the sequence is already used in the container before adding it.
Exceptions
ExceptionIf there are redundant names in the input vector.

Implements bpp::OrderedSequenceContainer.

Definition at line 344 of file VectorSequenceContainer.cpp.

void AlignedSequenceContainer::setSite ( size_t  siteIndex,
const Site site,
bool  checkPosition = true 
)
throw (Exception
)
virtual

Set a site in the container.

Parameters
siteIndexThe position of the site in the container.
siteThe site to set.
checkPositionLook if the position of the new site match a position attribute in the container.
Exceptions
ExceptionIf the specified site does not exists or is not correct.

Implements bpp::SiteContainer.

Definition at line 154 of file AlignedSequenceContainer.cpp.

std::string bpp::AbstractSequenceContainer::toString ( const std::string &  name) const
throw (SequenceNotFoundException
)
inlinevirtualinherited

Convert a particular sequence to a string.

Parameters
nameThe name of the sequence.
Returns
A string describing the content of the sequence.
Exceptions
SequenceNotFoundExceptionIf the name does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 129 of file AbstractSequenceContainer.h.

References bpp::OrderedSequenceContainer::getSequence(), and bpp::SymbolList::toString().

virtual std::string bpp::AbstractSequenceContainer::toString ( size_t  sequenceIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Convert a particular sequence to a string.

Parameters
sequenceIndexThe position of the sequence.
Returns
A string describing the content of the sequence.
Exceptions
IndexOutOfBoundsExceptionIf the position does not match any sequence in the container.

Implements bpp::OrderedSequenceContainer.

Definition at line 172 of file AbstractSequenceContainer.h.

References bpp::OrderedSequenceContainer::getSequence(), and bpp::SymbolList::toString().

int& bpp::VectorSequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
)
throw (SequenceNotFoundException,
IndexOutOfBoundsException
)
inlinevirtualinherited

Element access function.

Allows direct access to the data stored in the container.

Parameters
sequenceNameThe sequence name.
elementIndexThe element position within the sequence.
Exceptions
SequenceNotFoundExceptionIf no corresponding sequence is found in the container.
IndexOutOfBoundsExceptionIf the element position is not valid.

Implements bpp::OrderedSequenceContainer.

Definition at line 192 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence_().

const int& bpp::VectorSequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
) const
throw (SequenceNotFoundException,
IndexOutOfBoundsException
)
inlinevirtualinherited

Element access function.

Allows direct access to the data stored in the container.

Parameters
sequenceNameThe sequence name.
elementIndexThe element position within the sequence.
Exceptions
SequenceNotFoundExceptionIf no corresponding sequence is found in the container.
IndexOutOfBoundsExceptionIf the element position is not valid.

Implements bpp::OrderedSequenceContainer.

Definition at line 197 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence().

int& bpp::VectorSequenceContainer::valueAt ( size_t  sequenceIndex,
size_t  elementIndex 
)
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container.

Parameters
sequenceIndexThe sequence position.
elementIndexThe element position within the sequence.
Exceptions
IndexOutOfBoundsExceptionIf a position is not valid.

Implements bpp::OrderedSequenceContainer.

Definition at line 212 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence_().

const int& bpp::VectorSequenceContainer::valueAt ( size_t  sequenceIndex,
size_t  elementIndex 
) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited

Element access operator.

Allows direct access to the data stored in the container.

Parameters
sequenceIndexThe sequence position.
elementIndexThe element position within the sequence.
Exceptions
IndexOutOfBoundsExceptionIf a position is not valid.

Implements bpp::OrderedSequenceContainer.

Definition at line 217 of file VectorSequenceContainer.h.

References bpp::VectorSequenceContainer::getSequence().

Member Data Documentation

size_t bpp::AlignedSequenceContainer::length_
private

Definition at line 76 of file AlignedSequenceContainer.h.

Referenced by checkSize_(), and getNumberOfSites().

std::vector<int> bpp::AlignedSequenceContainer::positions_
private

Definition at line 74 of file AlignedSequenceContainer.h.

Referenced by getSitePositions().

std::vector<Site*> bpp::AlignedSequenceContainer::sites_
mutableprivate

This is used in order to implement the SiteContainer interface. A SiteContainer is expected to work on Site objects, but this class – since it is a VectorSequenceContainer – has its data sored as Sequence object. When the SiteContainer method getSite() is invoked it creates a new Site object and send the address of it. To avoid memory leaks, this object is put into a std::vector so that it can be destroyed when the container is destroyed.

Definition at line 87 of file AlignedSequenceContainer.h.


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