bpp-seq3  3.0.0
bpp::CompressedVectorSiteContainer Class Referenceabstract

A low memory, yet restricted, version of the VectorSiteContainer class. More...

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

+ Inheritance diagram for bpp::CompressedVectorSiteContainer:
+ Collaboration diagram for bpp::CompressedVectorSiteContainer:

Public Member Functions

 CompressedVectorSiteContainer (std::vector< std::unique_ptr< Site >> &vs, std::shared_ptr< const Alphabet > &alphabet)
 Build a new container from a set of sites. More...
 
 CompressedVectorSiteContainer (size_t size, std::shared_ptr< const Alphabet > &alphabet)
 Build a new empty container with specified size. More...
 
 CompressedVectorSiteContainer (const std::vector< std::string > &names, std::shared_ptr< const Alphabet > &alphabet)
 Build a new empty container with specified sequence names. More...
 
 CompressedVectorSiteContainer (std::shared_ptr< const Alphabet > &alphabet)
 Build a new empty container. More...
 
 CompressedVectorSiteContainer (const CompressedVectorSiteContainer &vsc)
 
 CompressedVectorSiteContainer (const SiteContainerInterface &sc)
 
CompressedVectorSiteContaineroperator= (const CompressedVectorSiteContainer &vsc)
 
CompressedVectorSiteContaineroperator= (const SiteContainerInterface &sc)
 
virtual ~CompressedVectorSiteContainer ()
 
size_t getNumberOfUniqueSites () const
 
void setSequence (size_t sequencePosition, std::unique_ptr< Sequence > &sequence, const std::string &sequenceKey) override
 
void setSequence (size_t sequencePosition, std::unique_ptr< Sequence > &sequence) override
 
void setSequence (const std::string &sequenceKey, std::unique_ptr< Sequence > &sequence) override
 
void addSequence (const std::string &sequenceKey, std::unique_ptr< Sequence > &sequence) override
 
void insertSequence (size_t sequencePosition, std::unique_ptr< Sequence > &sequence, const std::string &sequenceKey) override
 
const int & valueAt (const std::string &sequenceKey, size_t sitePosition) const override
 
int & valueAt (const std::string &sequenceKey, size_t sitePosition) override
 
const int & valueAt (size_t sequencePosition, size_t sitePosition) const override
 Get the content of the dataset at a specific position (sequence position, site position). More...
 
int & valueAt (size_t sequencePosition, size_t sitePosition) override
 Get the content of the dataset at a specific position (sequence position, site position). More...
 
const Alphabetalphabet () const override
 Get the container's alphabet. More...
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 Get a pointer toward the container's alphabet. More...
 
virtual const CommentsgetComments () const =0
 Get the comments. More...
 
const CommentsgetComments () const override
 Get the comments. More...
 
virtual void setComments (const Comments &comments)=0
 Set the comments. More...
 
void setComments (const Comments &comments) override
 Set the comments. More...
 
virtual void clearComments ()=0
 
void clearComments () override
 
The Clonable interface.
CompressedVectorSiteContainerclone () const override
 
The SiteContainer interface implementation:
const Sitesite (size_t sitePosition) const override
 Get a site from the container. More...
 
void setSite (size_t sitePosition, std::unique_ptr< Site > &site, bool checkCoordinate=true) override
 Set a site in the container. More...
 
std::unique_ptr< SiteremoveSite (size_t sitePosition) override
 Remove a site from the container. More...
 
void deleteSite (size_t sitePosition) override
 Delete a site from the container. More...
 
void addSite (std::unique_ptr< Site > &site, bool checkCoordinate=false) override
 Add a site in the container. More...
 
void addSite (std::unique_ptr< Site > &site, size_t sitePosition, bool checkCoordinate=false) override
 Add a site in the container. More...
 
void deleteSites (size_t sitePosition, size_t length) override
 Remove a continuous range of sites in the container. More...
 
size_t getNumberOfSites () const override
 Get the number of aligned positions in the container. More...
 
void reindexSites () override
 Set all coordinate attributes. More...
 
Vint getSiteCoordinates () const override
 Get all coordinates of sites. More...
 
void setSiteCoordinates (const Vint &coordinates) override
 Set all coordinates of sites. More...
 
The SequenceContainer interface.
const Sequencesequence (size_t sequenceIndex) const override
 Retrieve a sequence object from the container. More...
 
const Sequencesequence (const std::string &sequenceKey) const override
 Retrieve a sequence object from the container. More...
 
bool hasSequence (const std::string &name) const override
 Check if a certain key is associated to a sequence in the container. More...
 
size_t getSequencePosition (const std::string &sequenceKey) const override
 Get the position of a sequence with a given key in the container. More...
 
std::unique_ptr< SequenceremoveSequence (size_t sequencePosition) override
 Remove a sequence from the container. More...
 
std::unique_ptr< SequenceremoveSequence (const std::string &sequenceKey) override
 
void deleteSequence (size_t sequencePosition) override
 Remove and delete a sequence from the container. More...
 
void deleteSequence (const std::string &sequenceKey) override
 Remove and delete a sequence from the container. More...
 
size_t getNumberOfSequences () const override
 Get the number of sequences in the container. More...
 
std::vector< std::string > getSequenceKeys () const override
 
void setSequenceKeys (const std::vector< std::string > &sequenceKeys) override
 Reset all sequence keys. More...
 
const std::string & sequenceKey (size_t sequencePosition) const override
 Get the key associated to a given sequence. More...
 
std::vector< std::string > getSequenceNames () const override
 
void setSequenceNames (const std::vector< std::string > &names, bool updateKeys) override
 Batch-set all sequence names. More...
 
std::vector< CommentsgetSequenceComments () const override
 
void clear () override
 Delete all data in the container. More...
 
CompressedVectorSiteContainercreateEmptyContainer () const override
 Return a copy of this container, but with no data inside. More...
 
SequenceData methods.
double getStateValueAt (size_t sitePosition, const std::string &sequenceKey, int state) const override
 Get the value of a state at a given position. More...
 
double operator() (size_t sitePosition, const std::string &sequenceKey, int state) const override
 Get the value of a state at a given position. More...
 
double getStateValueAt (size_t sitePosition, size_t sequencePosition, int state) const override
 Get value of a state at a given position. More...
 
double operator() (size_t sitePosition, size_t sequencePosition, int state) const override
 Get the value of a state at a given position. More...
 
Access by key
virtual const SequenceType & sequence (const HashType &sequenceKey) const override=0
 Retrieve a sequence object from the container. More...
 
virtual void setSequence (const HashType &sequenceKey, std::unique_ptr< SequenceType > &sequencePtr)=0
 Replace a sequence in the container. More...
 
virtual void addSequence (const HashType &sequenceKey, std::unique_ptr< SequenceType > &sequencePtr)=0
 Add a sequence to the container. More...
 
virtual std::unique_ptr< SequenceType > removeSequence (const HashType &sequenceKey)=0
 Remove a sequence from the container. More...
 
virtual const SequenceType::ElementType & valueAt (const HashType &sequenceKey, size_t sitePosition) const =0
 Get the content of the dataset at a specific position (sequence key, site position). More...
 
virtual SequenceType::ElementType & valueAt (const HashType &sequenceKey, size_t sitePosition)=0
 Get the content of the dataset at a specific position (sequence key, site position). More...
 
Access by position
virtual void setSequence (size_t sequencePosition, std::unique_ptr< SequenceType > &sequencePtr)=0
 Replace a sequence in the container. More...
 
virtual void setSequence (size_t sequencePosition, std::unique_ptr< SequenceType > &sequencePtr, const HashType &sequenceKey)=0
 Replace a sequence in the container. More...
 
virtual void insertSequence (size_t sequencePosition, std::unique_ptr< SequenceType > &sequencePtr, const HashType &sequenceKey)=0
 Insert a sequence in the container. More...
 

Protected Member Functions

SitegetSite_ (size_t sitePosition)
 
size_t getSiteIndex_ (const Site &site)
 

Protected Attributes

VectorPositionedContainer< SitesiteContainer_
 
VectorMappedContainer< SequencesequenceContainer_
 
std::vector< std::string > sequenceNames_
 
std::vector< CommentssequenceComments_
 
std::vector< size_t > index_
 
std::shared_ptr< const Alphabetalphabet_
 The container's alphabet. More...
 
Comments comments_
 

Detailed Description

A low memory, yet restricted, version of the VectorSiteContainer class.

This implementation is very similar to VectorSiteContainer, but identical sites are stored only once, which significantly reduces memory usage in the case of containers where the number of sites is large compared to the number of sequences. site access is as fast as in the standard VectorSiteContainer class, but site addition takes more time, as the new site must be first compared to the existing set. A major restriction of this container is that you can't add or remove sequences. The number of sequences is fixed after the first site has been added.

Warning
Since the data is compressed, the sites given as input are modified. The major practical consequence is that the 'position' attribute of sites will be lost. Instead, the position will correspond to the position in the compressed container. In addition, this container may lead to unexpected behavior if used with derived classes of Site.
See also
Sequence, Site, VectorSiteContainer

Definition at line 41 of file CompressedVectorSiteContainer.h.

Constructor & Destructor Documentation

◆ CompressedVectorSiteContainer() [1/6]

CompressedVectorSiteContainer::CompressedVectorSiteContainer ( std::vector< std::unique_ptr< Site >> &  vs,
std::shared_ptr< const Alphabet > &  alphabet 
)

Build a new container from a set of sites.

Parameters
vsA std::vector of sites.
alphabetThe common alphabet for all sites.
Exceptions
ExceptionIf sites differ in size or in alphabet.

Class constructors:

Definition at line 16 of file CompressedVectorSiteContainer.cpp.

References addSite(), sequenceContainer_, sequenceNames_, site(), and bpp::TextTools::toString().

Referenced by clone(), and createEmptyContainer().

◆ CompressedVectorSiteContainer() [2/6]

CompressedVectorSiteContainer::CompressedVectorSiteContainer ( size_t  size,
std::shared_ptr< const Alphabet > &  alphabet 
)

Build a new empty container with specified size.

Parameters
sizeNumber of sequences in the container.
alphabetThe alphabet for this container.

Definition at line 45 of file CompressedVectorSiteContainer.cpp.

References sequenceContainer_, sequenceNames_, and bpp::TextTools::toString().

◆ CompressedVectorSiteContainer() [3/6]

CompressedVectorSiteContainer::CompressedVectorSiteContainer ( const std::vector< std::string > &  names,
std::shared_ptr< const Alphabet > &  alphabet 
)

Build a new empty container with specified sequence names.

Parameters
namesSequence names. This will set the number of sequences in the container.
alphabetThe alphabet for this container.

Definition at line 65 of file CompressedVectorSiteContainer.cpp.

References sequenceContainer_, sequenceNames_, and bpp::TextTools::toString().

◆ CompressedVectorSiteContainer() [4/6]

CompressedVectorSiteContainer::CompressedVectorSiteContainer ( std::shared_ptr< const Alphabet > &  alphabet)

Build a new empty container.

Parameters
alphabetThe alphabet for this container.

Definition at line 86 of file CompressedVectorSiteContainer.cpp.

◆ CompressedVectorSiteContainer() [5/6]

CompressedVectorSiteContainer::CompressedVectorSiteContainer ( const CompressedVectorSiteContainer vsc)

◆ CompressedVectorSiteContainer() [6/6]

◆ ~CompressedVectorSiteContainer()

virtual bpp::CompressedVectorSiteContainer::~CompressedVectorSiteContainer ( )
inlinevirtual

Definition at line 97 of file CompressedVectorSiteContainer.h.

References clear().

Member Function Documentation

◆ addSequence() [1/2]

template<class SequenceType , class HashType = std::string>
virtual void bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::addSequence ( const HashType &  sequenceKey,
std::unique_ptr< SequenceType > &  sequencePtr 
)
pure virtualinherited

◆ addSequence() [2/2]

void bpp::CompressedVectorSiteContainer::addSequence ( const std::string &  sequenceKey,
std::unique_ptr< Sequence > &  sequence 
)
inlineoverride

Definition at line 285 of file CompressedVectorSiteContainer.h.

◆ addSite() [1/2]

void CompressedVectorSiteContainer::addSite ( std::unique_ptr< Site > &  site,
bool  checkCoordinate = false 
)
overridevirtual

Add a site in the container.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 331 of file CompressedVectorSiteContainer.cpp.

References bpp::AbstractTemplateSequenceContainer< Sequence, std::string >::getAlphabet(), bpp::AbstractTemplateSymbolList< T >::getAlphabet(), getNumberOfSequences(), getNumberOfUniqueSites(), getSiteIndex_(), index_, sequenceComments_, sequenceContainer_, sequenceNames_, site(), siteContainer_, bpp::AbstractTemplateSymbolList< T >::size(), and bpp::TextTools::toString().

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

◆ addSite() [2/2]

void CompressedVectorSiteContainer::addSite ( std::unique_ptr< Site > &  site,
size_t  sitePosition,
bool  checkCoordinate = false 
)
overridevirtual

Add a site in the container.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 374 of file CompressedVectorSiteContainer.cpp.

References bpp::AbstractTemplateSequenceContainer< Sequence, std::string >::getAlphabet(), bpp::AbstractTemplateSymbolList< T >::getAlphabet(), getNumberOfSequences(), getNumberOfSites(), getNumberOfUniqueSites(), getSiteIndex_(), index_, sequenceComments_, sequenceContainer_, sequenceNames_, site(), siteContainer_, bpp::AbstractTemplateSymbolList< T >::size(), and bpp::TextTools::toString().

◆ alphabet()

const Alphabet& bpp::AbstractTemplateSequenceContainer< Sequence , std::string >::alphabet ( ) const
inlineoverridevirtualinherited

Get the container's alphabet.

Returns
The alphabet associated to this container.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 95 of file AbstractSequenceContainer.h.

◆ clear()

void bpp::CompressedVectorSiteContainer::clear ( )
inlineoverridevirtual

◆ clearComments() [1/2]

void bpp::SimpleCommentable::clearComments ( )
inlineoverridevirtualinherited

Implements bpp::Commentable.

Definition at line 88 of file Commentable.h.

References bpp::SimpleCommentable::comments_.

◆ clearComments() [2/2]

virtual void bpp::Commentable::clearComments ( )
pure virtualinherited

Implemented in bpp::SimpleCommentable.

◆ clone()

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

◆ createEmptyContainer()

CompressedVectorSiteContainer* bpp::CompressedVectorSiteContainer::createEmptyContainer ( ) const
inlineoverridevirtual

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

This method creates a new SequencedContainer object. The class of this container depends on the class implementing this interface.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 257 of file CompressedVectorSiteContainer.h.

References CompressedVectorSiteContainer(), bpp::AbstractTemplateSequenceContainer< Sequence, std::string >::getAlphabet(), bpp::SimpleCommentable::getComments(), and bpp::SimpleCommentable::setComments().

◆ deleteSequence() [1/2]

void bpp::CompressedVectorSiteContainer::deleteSequence ( const std::string &  sequenceKey)
inlineoverridevirtual

Remove and delete a sequence from the container.

Parameters
sequenceKeyThe key to which the sequence is associated.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 200 of file CompressedVectorSiteContainer.h.

◆ deleteSequence() [2/2]

void bpp::CompressedVectorSiteContainer::deleteSequence ( size_t  sequencePosition)
inlineoverridevirtual

Remove and delete a sequence from the container.

Parameters
sequencePositionThe position of the sequence.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 194 of file CompressedVectorSiteContainer.h.

◆ deleteSite()

void CompressedVectorSiteContainer::deleteSite ( size_t  sitePosition)
overridevirtual

Delete a site from the container.

The site is deleted (ie the container is shortened).

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 309 of file CompressedVectorSiteContainer.cpp.

References getNumberOfSites(), and removeSite().

Referenced by deleteSites().

◆ deleteSites()

void CompressedVectorSiteContainer::deleteSites ( size_t  sitePosition,
size_t  length 
)
overridevirtual

Remove a continuous range of sites in the container.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 320 of file CompressedVectorSiteContainer.cpp.

References deleteSite().

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::AbstractTemplateSequenceContainer< Sequence , std::string >::getAlphabet ( ) const
inlineoverridevirtualinherited

Get a pointer toward the container's alphabet.

Returns
A pointer toward the alphabet associated to this container.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 101 of file AbstractSequenceContainer.h.

◆ getComments() [1/2]

◆ getComments() [2/2]

◆ getNumberOfSequences()

size_t bpp::CompressedVectorSiteContainer::getNumberOfSequences ( ) const
inlineoverridevirtual

Get the number of sequences in the container.

Returns
The number of sequences in the container.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 206 of file CompressedVectorSiteContainer.h.

References sequenceContainer_.

Referenced by addSite(), sequence(), setSequenceNames(), and setSite().

◆ getNumberOfSites()

size_t bpp::CompressedVectorSiteContainer::getNumberOfSites ( ) const
inlineoverridevirtual

Get the number of aligned positions in the container.

Returns
The number of sites in the container.

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 133 of file CompressedVectorSiteContainer.h.

References index_.

Referenced by addSite(), deleteSite(), getSiteCoordinates(), removeSite(), sequence(), setSite(), and setSiteCoordinates().

◆ getNumberOfUniqueSites()

size_t bpp::CompressedVectorSiteContainer::getNumberOfUniqueSites ( ) const
inline
Returns
The number of site instances

Definition at line 148 of file CompressedVectorSiteContainer.h.

References siteContainer_.

Referenced by addSite(), getSiteIndex_(), and setSite().

◆ getSequenceComments()

std::vector<Comments> bpp::CompressedVectorSiteContainer::getSequenceComments ( ) const
inlineoverridevirtual
Returns
a vector with all sequence comments.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 243 of file CompressedVectorSiteContainer.h.

References sequenceComments_.

◆ getSequenceKeys()

std::vector<std::string> bpp::CompressedVectorSiteContainer::getSequenceKeys ( ) const
inlineoverridevirtual
Returns
a vector with all sequence keys.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 211 of file CompressedVectorSiteContainer.h.

References sequenceContainer_.

◆ getSequenceNames()

std::vector<std::string> bpp::CompressedVectorSiteContainer::getSequenceNames ( ) const
inlineoverridevirtual
Returns
a vector with all sequence names.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 226 of file CompressedVectorSiteContainer.h.

References sequenceNames_.

Referenced by operator=().

◆ getSequencePosition()

size_t bpp::CompressedVectorSiteContainer::getSequencePosition ( const std::string &  sequenceKey) const
inlineoverridevirtual

Get the position of a sequence with a given key in the container.

Parameters
sequenceKeyThe key to which the sequence is associated.
Returns
The position of the sequence with name 'name', if it exists.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 176 of file CompressedVectorSiteContainer.h.

References sequenceContainer_, and sequenceKey().

Referenced by getStateValueAt(), operator()(), sequence(), and valueAt().

◆ getSite_()

Site& bpp::CompressedVectorSiteContainer::getSite_ ( size_t  sitePosition)
inlineprotected

Get a non-const reference to a site in the container. It is a convenient short-cut for use within the class only, as this can potentially mess up the data.

Parameters
sitePositionthe index of the site to retrieve.
Returns
A reference to the selected site.

Definition at line 354 of file CompressedVectorSiteContainer.h.

References index_, and siteContainer_.

Referenced by reindexSites(), and setSiteCoordinates().

◆ getSiteCoordinates()

Vint CompressedVectorSiteContainer::getSiteCoordinates ( ) const
overridevirtual

Get all coordinates of sites.

Returns
A vector with all site coordinates.

Implements bpp::TemplateAlignmentDataInterface< HashType >.

Definition at line 443 of file CompressedVectorSiteContainer.cpp.

References getNumberOfSites(), index_, and siteContainer_.

◆ getSiteIndex_()

size_t CompressedVectorSiteContainer::getSiteIndex_ ( const Site site)
protected
Returns
The position of the site in the compressed set. If the site is not found, this will return the number of sites in the compressed set.

Definition at line 488 of file CompressedVectorSiteContainer.cpp.

References getNumberOfUniqueSites(), site(), siteContainer_, and bpp::AbstractTemplateSymbolList< T >::size().

Referenced by addSite(), and setSite().

◆ getStateValueAt() [1/2]

double bpp::CompressedVectorSiteContainer::getStateValueAt ( size_t  sitePosition,
const std::string &  sequenceKey,
int  state 
) const
inlineoverridevirtual

Get the value of a state at a given position.

Parameters
sitePositionindex of the site
sequenceKeykey of the sequence in the container
statestate in the alphabet

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 324 of file CompressedVectorSiteContainer.h.

References getSequencePosition(), bpp::Site::getStateValueAt(), sequenceKey(), and site().

◆ getStateValueAt() [2/2]

double bpp::CompressedVectorSiteContainer::getStateValueAt ( size_t  sitePosition,
size_t  sequencePosition,
int  state 
) const
inlineoverridevirtual

Get value of a state at a given position.

Parameters
sitePositionindex of the site
sequencePositionindex of the sequence in the container
statestate in the alphabet

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 334 of file CompressedVectorSiteContainer.h.

References bpp::Site::getStateValueAt(), and site().

◆ hasSequence()

bool bpp::CompressedVectorSiteContainer::hasSequence ( const std::string &  sequenceKey) const
inlineoverridevirtual

Check if a certain key is associated to a sequence in the container.

Parameters
sequenceKeyThe key to which the sequence is associated.
Returns
True if the key was found in the contained.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 170 of file CompressedVectorSiteContainer.h.

References sequenceContainer_.

◆ insertSequence() [1/2]

void bpp::CompressedVectorSiteContainer::insertSequence ( size_t  sequencePosition,
std::unique_ptr< Sequence > &  sequence,
const std::string &  sequenceKey 
)
inlineoverride

Definition at line 291 of file CompressedVectorSiteContainer.h.

◆ insertSequence() [2/2]

template<class SequenceType , class HashType = std::string>
virtual void bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::insertSequence ( size_t  sequencePosition,
std::unique_ptr< SequenceType > &  sequencePtr,
const HashType &  sequenceKey 
)
pure virtualinherited

Insert a sequence in the container.

Parameters
sequencePositionThe position of the sequence.
sequencePtrThe sequence to add.
sequenceKeyThe new key of the sequence.

Implemented in bpp::TemplateVectorSequenceContainer< SequenceType >, bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >, and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >.

◆ operator()() [1/2]

double bpp::CompressedVectorSiteContainer::operator() ( size_t  sitePosition,
const std::string &  sequenceKey,
int  state 
) const
inlineoverridevirtual

Get the value of a state at a given position.

Same as getValueAt.

Parameters
sitePositionindex of the site
sequenceKeykey of the sequence in the container
statestate in the alphabet

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 329 of file CompressedVectorSiteContainer.h.

References getSequencePosition(), bpp::Site::getStateValueAt(), sequenceKey(), and site().

◆ operator()() [2/2]

double bpp::CompressedVectorSiteContainer::operator() ( size_t  sitePosition,
size_t  sequencePosition,
int  state 
) const
inlineoverridevirtual

Get the value of a state at a given position.

Same as getValueAt.

Parameters
sitePositionindex of the site
sequencePositionindex of the sequence in the container
statestate in the alphabet

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 339 of file CompressedVectorSiteContainer.h.

References bpp::Site::getStateValueAt(), and site().

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ reindexSites()

void CompressedVectorSiteContainer::reindexSites ( )
overridevirtual

◆ removeSequence() [1/3]

template<class SequenceType , class HashType = std::string>
virtual std::unique_ptr<SequenceType> bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::removeSequence ( const HashType &  sequenceKey)
pure virtualinherited

◆ removeSequence() [2/3]

std::unique_ptr<Sequence> bpp::CompressedVectorSiteContainer::removeSequence ( const std::string &  sequenceKey)
inlineoverride

Definition at line 188 of file CompressedVectorSiteContainer.h.

◆ removeSequence() [3/3]

std::unique_ptr<Sequence> bpp::CompressedVectorSiteContainer::removeSequence ( size_t  sequencePosition)
inlineoverridevirtual

Remove a sequence from the container.

Parameters
sequencePositionThe position of the sequence.

Implements bpp::TemplateSequenceContainerInterface< SequenceType, HashType >.

Definition at line 182 of file CompressedVectorSiteContainer.h.

◆ removeSite()

std::unique_ptr< Site > CompressedVectorSiteContainer::removeSite ( size_t  sitePosition)
overridevirtual

Remove a site from the container.

The site is deleted (ie the container is shortened) and a pointer toward it is returned.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 268 of file CompressedVectorSiteContainer.cpp.

References getNumberOfSites(), index_, sequenceContainer_, and siteContainer_.

Referenced by deleteSite().

◆ sequence() [1/3]

template<class SequenceType , class HashType = std::string>
virtual const SequenceType& bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::sequence ( const HashType &  sequenceKey) const
overridepure virtualinherited

◆ sequence() [2/3]

const Sequence& bpp::CompressedVectorSiteContainer::sequence ( const std::string &  sequenceKey) const
inlineoverridevirtual

Retrieve a sequence object from the container.

Parameters
sequenceKeyThe key to which the sequence is associated.
Returns
A reference toward the Sequence with corresponding name.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 163 of file CompressedVectorSiteContainer.h.

References getSequencePosition(), sequence(), and sequenceKey().

◆ sequence() [3/3]

const Sequence & CompressedVectorSiteContainer::sequence ( size_t  sequencePosition) const
overridevirtual

Retrieve a sequence object from the container.

Parameters
sequencePositionThe position of the sequence.
Returns
A reference toward the Sequence object with corresponding name.

Implements bpp::TemplateSequenceContainerInterface< SequenceType, HashType >.

Definition at line 456 of file CompressedVectorSiteContainer.cpp.

References bpp::AbstractTemplateSequenceContainer< Sequence, std::string >::getAlphabet(), getNumberOfSequences(), getNumberOfSites(), index_, sequenceComments_, sequenceContainer_, sequenceKey(), sequenceNames_, and siteContainer_.

Referenced by sequence().

◆ sequenceKey()

const std::string& bpp::CompressedVectorSiteContainer::sequenceKey ( size_t  sequencePosition) const
inlineoverridevirtual

Get the key associated to a given sequence.

Parameters
sequencePositionThe position of the sequence in the container.
Returns
The key to which the sequence is associated.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 221 of file CompressedVectorSiteContainer.h.

References sequenceContainer_.

Referenced by getSequencePosition(), getStateValueAt(), operator()(), sequence(), and valueAt().

◆ setComments() [1/2]

◆ setComments() [2/2]

virtual void bpp::Commentable::setComments ( const Comments comments)
pure virtualinherited

◆ setSequence() [1/6]

template<class SequenceType , class HashType = std::string>
virtual void bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::setSequence ( const HashType &  sequenceKey,
std::unique_ptr< SequenceType > &  sequencePtr 
)
pure virtualinherited

Replace a sequence in the container.

If a sequence is found with the given key, it will be updated with the new one. If no sequence with the given key is found, the new sequence will be added to the container.

Parameters
sequenceKeyThe key to which the sequence is associated.
sequencePtrThe sequence to set.

Implemented in bpp::TemplateVectorSequenceContainer< SequenceType >, bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >, and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >.

◆ setSequence() [2/6]

void bpp::CompressedVectorSiteContainer::setSequence ( const std::string &  sequenceKey,
std::unique_ptr< Sequence > &  sequence 
)
inlineoverride

Definition at line 279 of file CompressedVectorSiteContainer.h.

◆ setSequence() [3/6]

void bpp::CompressedVectorSiteContainer::setSequence ( size_t  sequencePosition,
std::unique_ptr< Sequence > &  sequence 
)
inlineoverride

Definition at line 273 of file CompressedVectorSiteContainer.h.

◆ setSequence() [4/6]

void bpp::CompressedVectorSiteContainer::setSequence ( size_t  sequencePosition,
std::unique_ptr< Sequence > &  sequence,
const std::string &  sequenceKey 
)
inlineoverride

Definition at line 267 of file CompressedVectorSiteContainer.h.

◆ setSequence() [5/6]

template<class SequenceType , class HashType = std::string>
virtual void bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::setSequence ( size_t  sequencePosition,
std::unique_ptr< SequenceType > &  sequencePtr 
)
pure virtualinherited

Replace a sequence in the container.

The original key associated to the sequence will be kept.

Parameters
sequencePositionThe position of the sequence.
sequencePtrThe sequence to add.

Implemented in bpp::TemplateVectorSequenceContainer< SequenceType >, bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >, and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >.

◆ setSequence() [6/6]

template<class SequenceType , class HashType = std::string>
virtual void bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::setSequence ( size_t  sequencePosition,
std::unique_ptr< SequenceType > &  sequencePtr,
const HashType &  sequenceKey 
)
pure virtualinherited

Replace a sequence in the container.

The original key associated to the sequence will be kept.

Parameters
sequencePositionThe position of the sequence.
sequencePtrThe sequence to add.
sequenceKeyThe new key of the sequence.

Implemented in bpp::TemplateVectorSequenceContainer< SequenceType >, bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >, and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >.

◆ setSequenceKeys()

void bpp::CompressedVectorSiteContainer::setSequenceKeys ( const std::vector< std::string > &  sequenceKeys)
inlineoverridevirtual

Reset all sequence keys.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 216 of file CompressedVectorSiteContainer.h.

References sequenceContainer_.

Referenced by setSequenceNames().

◆ setSequenceNames()

void bpp::CompressedVectorSiteContainer::setSequenceNames ( const std::vector< std::string > &  names,
bool  updateKeys 
)
inlineoverridevirtual

Batch-set all sequence names.

Parameters
namesA vector of sequence names. Must be the same size as the number of sequences in the container, otherwise a DimensionException is thrown.
updateKeysTell whether the keys of the sequences should be updated with the new sequence names.

Implements bpp::TemplateSequenceDataInterface< std::string >.

Definition at line 231 of file CompressedVectorSiteContainer.h.

References getNumberOfSequences(), sequenceContainer_, sequenceNames_, and setSequenceKeys().

◆ setSite()

void CompressedVectorSiteContainer::setSite ( size_t  sitePosition,
std::unique_ptr< Site > &  site,
bool  checkCoordinate = true 
)
overridevirtual

Set a site in the container.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 189 of file CompressedVectorSiteContainer.cpp.

References bpp::AbstractTemplateSequenceContainer< Sequence, std::string >::getAlphabet(), bpp::AbstractTemplateSymbolList< T >::getAlphabet(), getNumberOfSequences(), getNumberOfSites(), getNumberOfUniqueSites(), getSiteIndex_(), index_, sequenceContainer_, site(), siteContainer_, and bpp::AbstractTemplateSymbolList< T >::size().

◆ setSiteCoordinates()

void CompressedVectorSiteContainer::setSiteCoordinates ( const Vint vCoordinates)
overridevirtual

Set all coordinates of sites.

Parameters
vCoordinatesA vector with all site coordinates.

Implements bpp::TemplateAlignmentDataInterface< HashType >.

Definition at line 430 of file CompressedVectorSiteContainer.cpp.

References getNumberOfSites(), getSite_(), and bpp::AbstractCoreSite::setCoordinate().

◆ site()

const Site& bpp::CompressedVectorSiteContainer::site ( size_t  sitePosition) const
inlineoverridevirtual

Get a site from the container.

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

Implements bpp::TemplateSiteContainerInterface< Site, Sequence, std::string >.

Definition at line 116 of file CompressedVectorSiteContainer.h.

References index_, and siteContainer_.

Referenced by addSite(), CompressedVectorSiteContainer(), getSiteIndex_(), getStateValueAt(), operator()(), setSite(), and valueAt().

◆ valueAt() [1/6]

template<class SequenceType , class HashType = std::string>
virtual const SequenceType::ElementType& bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::valueAt ( const HashType &  sequenceKey,
size_t  sitePosition 
) const
pure virtualinherited

Get the content of the dataset at a specific position (sequence key, site position).

Parameters
sequenceKeykey of the sequence in the container
sitePositionindex of the site
Returns
The element at the given position.

Implemented in bpp::TemplateVectorSiteContainer< SiteType, SequenceType >, and bpp::TemplateVectorSequenceContainer< SequenceType >.

◆ valueAt() [2/6]

template<class SequenceType , class HashType = std::string>
virtual SequenceType::ElementType& bpp::TemplateSequenceContainerInterface< SequenceType, HashType >::valueAt ( const HashType &  sequenceKey,
size_t  sitePosition 
)
pure virtualinherited

Get the content of the dataset at a specific position (sequence key, site position).

Parameters
sequenceKeykey of the sequence in the container
sitePositionindex of the site
Returns
The element at the given position.

Implemented in bpp::TemplateVectorSiteContainer< SiteType, SequenceType >, bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >, and bpp::TemplateVectorSequenceContainer< SequenceType >.

◆ valueAt() [3/6]

const int& bpp::CompressedVectorSiteContainer::valueAt ( const std::string &  sequenceKey,
size_t  sitePosition 
) const
inlineoverride

Definition at line 297 of file CompressedVectorSiteContainer.h.

References getSequencePosition(), sequenceKey(), and site().

◆ valueAt() [4/6]

int& bpp::CompressedVectorSiteContainer::valueAt ( const std::string &  sequenceKey,
size_t  sitePosition 
)
inlineoverride

Definition at line 302 of file CompressedVectorSiteContainer.h.

◆ valueAt() [5/6]

const int& bpp::CompressedVectorSiteContainer::valueAt ( size_t  sequencePosition,
size_t  sitePosition 
) const
inlineoverridevirtual

Get the content of the dataset at a specific position (sequence position, site position).

Parameters
sequencePositionindex of the sequence in the container
sitePositionindex of the site
Returns
The element at the given position.

Implements bpp::TemplateSequenceContainerInterface< SequenceType, HashType >.

Definition at line 308 of file CompressedVectorSiteContainer.h.

References site().

◆ valueAt() [6/6]

int& bpp::CompressedVectorSiteContainer::valueAt ( size_t  sequencePosition,
size_t  sitePosition 
)
inlineoverridevirtual

Get the content of the dataset at a specific position (sequence position, site position).

Parameters
sequencePositionindex of the sequence in the container
sitePositionindex of the site
Returns
The element at the given position.

Implements bpp::TemplateSequenceContainerInterface< SequenceType, HashType >.

Definition at line 313 of file CompressedVectorSiteContainer.h.

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::AbstractTemplateSequenceContainer< Sequence , std::string >::alphabet_
protectedinherited

The container's alphabet.

Definition at line 31 of file AbstractSequenceContainer.h.

◆ comments_

◆ index_

std::vector<size_t> bpp::CompressedVectorSiteContainer::index_
protected

◆ sequenceComments_

std::vector<Comments> bpp::CompressedVectorSiteContainer::sequenceComments_
protected

◆ sequenceContainer_

◆ sequenceNames_

std::vector<std::string> bpp::CompressedVectorSiteContainer::sequenceNames_
protected

◆ siteContainer_


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