bpp-seq3  3.0.0
bpp::SequenceContainer Class Referenceabstract

The SequenceContainer interface. More...

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

+ Inheritance diagram for bpp::SequenceContainer:
+ Collaboration diagram for bpp::SequenceContainer:

Public Member Functions

 SequenceContainer ()
 
virtual ~SequenceContainer ()
 
virtual const SequencegetSequence (const std::string &name) const =0
 Retrieve a sequence object from the container. More...
 
virtual void setSequence (const std::string &name, const Sequence &sequence, bool checkName)=0
 Replace a sequence in the container. More...
 
virtual std::shared_ptr< SequenceremoveSequence (const std::string &name)=0
 Extract (and remove) a sequence from the container. More...
 
virtual const AlphabetgetAlphabet () const =0
 Get container's alphabet. More...
 
virtual std::string toString (const std::string &name) const =0
 Convert a particular sequence to a string. More...
 
virtual bool hasSequence (const std::string &name) const =0
 Check if a sequence with a given name is present in the container. More...
 
virtual size_t getNumberOfSequences () const =0
 Get the number of sequences in the container. More...
 
virtual std::vector< std::string > getSequenceNames () const =0
 Get all the names of the sequences in the container. More...
 
virtual void setSequenceNames (const std::vector< std::string > &names, bool checkNames)=0
 Set all sequence names. More...
 
virtual double getStateValueAt (size_t siteIndex, const std::string &sequenceName, int state) const =0
 get value of a state in a position More...
 
virtual double operator() (size_t siteIndex, const std::string &sequenceName, int state) const =0
 
virtual const CommentsgetComments (const std::string &name) const =0
 Get comments of a particular sequence. More...
 
virtual void setComments (const std::string &name, const Comments &comments)=0
 Set the comments of a particular sequence. More...
 
virtual const CommentsgetGeneralComments () const =0
 Get the comments of this container. More...
 
virtual void setGeneralComments (const Comments &comments)=0
 Set the comments of this container. More...
 
virtual void deleteGeneralComments ()=0
 Delete the comments associated to this container. More...
 
virtual void clear ()=0
 Delete all data in the container. More...
 
virtual SequencedValuesContainercreateEmptyContainer () const =0
 Return a copy of this container, but with no data inside. More...
 
virtual Clonableclone () const=0
 
Provide direct access to sequences content.
Warning
These operators allow you to modifiy the content of the sequences. No checking is performed for your modifications, so use with care, or consider using the setContent() methods.
virtual int & valueAt (const std::string &sequenceName, size_t elementIndex)=0
 Element access function. More...
 
virtual const int & valueAt (const std::string &sequenceName, size_t elementIndex) const =0
 Element access function. More...
 
virtual int & operator() (const std::string &sequenceName, size_t elementIndex)=0
 Element access operator. More...
 
virtual const int & operator() (const std::string &sequenceName, size_t elementIndex) const =0
 Element access operator. More...
 
virtual void addSequence (const Sequence &sequence, bool checkName)=0
 Add a sequence to the container. More...
 

Detailed Description

The SequenceContainer interface.

This interface is the most general one in the container hierarchy for sequences. No assumption is made on the sequences in the container (no ordering, no alignment). Sequences may be retrieved using their names, which must be unique.

The container is the only one responsible for the allocation/destruction of sequences it contains. This means that any sequence passed to it will be copied into the container. The container also provides methods that send const pointers towards these sequences (without performing any copy of the underlying objects).

Notes :

  1. methods for adding sequences to the container are not declared here (so they can't be used throught this interface), because these methods take sequence container's type specific parameters (i.e. a key for map sequence containers);
  2. to delete a sequence from a container, one must use the appropriate method (removeSequence()). These methods performs a few check, and properly update pointers. You should never delete a sequence from a container by yourself.
See also
Sequence

Definition at line 82 of file SequenceContainer.h.

Constructor & Destructor Documentation

◆ SequenceContainer()

bpp::SequenceContainer::SequenceContainer ( )
inline

Definition at line 86 of file SequenceContainer.h.

◆ ~SequenceContainer()

virtual bpp::SequenceContainer::~SequenceContainer ( )
inlinevirtual

Definition at line 87 of file SequenceContainer.h.

Member Function Documentation

◆ addSequence()

virtual void bpp::SequenceContainer::addSequence ( const Sequence sequence,
bool  checkName 
)
pure virtual

◆ clear()

virtual void bpp::SequencedValuesContainer::clear ( )
pure virtualinherited

◆ createEmptyContainer()

virtual SequencedValuesContainer* bpp::SequencedValuesContainer::createEmptyContainer ( ) const
pure virtualinherited

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

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

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

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, bpp::CompressedVectorSiteContainer, and bpp::AlignedSequenceContainer.

◆ deleteGeneralComments()

virtual void bpp::SequencedValuesContainer::deleteGeneralComments ( )
pure virtualinherited

Delete the comments associated to this container.

Implemented in bpp::AbstractValuesContainer, and bpp::AbstractProbabilisticSequenceContainer.

◆ getAlphabet()

virtual const Alphabet* bpp::SequencedValuesContainer::getAlphabet ( ) const
pure virtualinherited

Get container's alphabet.

Returns
The alphabet associated to this container.

Implemented in bpp::AbstractValuesContainer.

Referenced by bpp::Clustal::appendAlignmentFromStream(), bpp::DCSE::appendAlignmentFromStream(), bpp::NexusIOSequence::appendAlignmentFromStream(), bpp::Fasta::appendSequencesFromStream(), bpp::GenBank::appendSequencesFromStream(), bpp::Mase::appendSequencesFromStream(), bpp::SiteContainerTools::changeGapsToUnknownCharacters(), bpp::SiteContainerTools::changeUnresolvedCharactersToGaps(), bpp::SequenceContainerTools::convertAlphabet(), bpp::SequenceContainerTools::getCodonPosition(), bpp::SiteContainerTools::getCompleteSites(), bpp::SiteContainerTools::getConsensus(), bpp::SequenceContainerTools::getFrequencies(), bpp::SiteContainerTools::getSelectedPositions(), bpp::MaseTools::getSelectedSequences(), bpp::SiteContainerTools::getSelectedSites(), bpp::SiteContainerTools::getSequencePositions(), bpp::SequenceApplicationTools::getSitesToAnalyse(), bpp::SiteContainerTools::getSitesWithoutGaps(), bpp::SequenceContainerTools::merge(), bpp::SiteContainerTools::merge(), bpp::AbstractSequenceContainer::operator=(), bpp::Phylip::readInterleaved(), bpp::Phylip::readSequential(), bpp::SiteContainerTools::removeGapOnlySites(), bpp::SiteContainerTools::removeGapOrUnresolvedOnlySites(), bpp::SiteContainerTools::removeGapSites(), bpp::SiteContainerTools::removeStopCodonSites(), bpp::SiteContainerTools::resolveDottedAlignment(), bpp::SiteContainerTools::sampleSites(), bpp::Phylip::writeInterleaved(), and bpp::Phylip::writeSequential().

◆ getComments()

virtual const Comments& bpp::SequencedValuesContainer::getComments ( const std::string &  name) const
pure virtualinherited

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.

Implemented in bpp::VectorProbabilisticSequenceContainer, bpp::AbstractSequenceContainer, and bpp::AbstractProbabilisticSequenceContainer.

Referenced by bpp::SequenceContainerTools::getCodonPosition(), and bpp::Mase::writeSequences().

◆ getGeneralComments()

◆ getNumberOfSequences()

virtual size_t bpp::SequencedValuesContainer::getNumberOfSequences ( ) const
pure virtualinherited

Get the number of sequences in the container.

Returns
The number of sequences in the container.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, and bpp::CompressedVectorSiteContainer.

Referenced by bpp::AlignedSequenceContainer::AlignedSequenceContainer(), bpp::SequenceContainerTools::append(), bpp::NexusIOSequence::appendAlignmentFromStream(), bpp::SiteContainerTools::changeGapsToUnknownCharacters(), bpp::SiteContainerTools::changeUnresolvedCharactersToGaps(), bpp::SiteContainerTools::computeSimilarityMatrix(), bpp::SequenceContainerTools::convertAlphabet(), bpp::SequenceContainerTools::getSelectedSequences(), bpp::SiteContainerTools::getSequencePositions(), bpp::SequenceApplicationTools::getSitesToAnalyse(), bpp::SimpleSequenceContainerIterator::hasMoreSequences(), bpp::VectorSequenceContainer::operator=(), bpp::VectorSiteContainer::operator=(), bpp::SiteContainerTools::removeGapOnlySites(), bpp::SiteContainerTools::removeGapOrUnresolvedOnlySites(), bpp::SiteContainerTools::removeGapSites(), bpp::SiteContainerTools::removeStopCodonSites(), bpp::SiteContainerTools::resolveDottedAlignment(), bpp::VectorProbabilisticSiteContainer::VectorProbabilisticSiteContainer(), bpp::VectorSequenceContainer::VectorSequenceContainer(), bpp::VectorSiteContainer::VectorSiteContainer(), bpp::Clustal::writeAlignment(), bpp::Phylip::writeAlignment(), bpp::Stockholm::writeAlignment(), bpp::Phylip::writeInterleaved(), and bpp::Phylip::writeSequential().

◆ getSequence()

◆ getSequenceNames()

virtual std::vector<std::string> bpp::SequencedValuesContainer::getSequenceNames ( ) const
pure virtualinherited

Get all the names of the sequences in the container.

Returns
A vector of strings with all sequence names.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, and bpp::CompressedVectorSiteContainer.

Referenced by bpp::SequenceContainerTools::append(), bpp::CompressedVectorSiteContainer::CompressedVectorSiteContainer(), bpp::SiteContainerTools::computeSimilarityMatrix(), bpp::SequenceContainerTools::convertAlphabet(), bpp::SequenceContainerTools::getCodonPosition(), bpp::SiteContainerTools::getCompleteSites(), bpp::SequenceContainerTools::getCounts(), bpp::SequenceContainerTools::getFrequencies(), bpp::SiteContainerTools::getSelectedSites(), bpp::SiteContainerTools::getSitesWithoutGaps(), bpp::SequenceContainerTools::keepOnlySelectedSequences(), bpp::SequenceContainerTools::merge(), bpp::SiteContainerTools::merge(), bpp::VectorSequenceContainer::operator=(), bpp::CompressedVectorSiteContainer::operator=(), bpp::VectorSiteContainer::operator=(), bpp::SiteContainerTools::removeGapOnlySites(), bpp::SiteContainerTools::removeGapOrUnresolvedOnlySites(), bpp::SiteContainerTools::removeGapSites(), bpp::SiteContainerTools::removeStopCodonSites(), bpp::SiteContainerTools::resolveDottedAlignment(), bpp::SequenceApplicationTools::restrictSelectedSequencesByName(), bpp::SiteContainerTools::sampleSites(), bpp::SequenceContainerTools::sequencesHaveTheSameLength(), bpp::VectorProbabilisticSiteContainer::VectorProbabilisticSiteContainer(), bpp::VectorSequenceContainer::VectorSequenceContainer(), bpp::VectorSiteContainer::VectorSiteContainer(), bpp::Pasta::writeAlignedValues(), bpp::Stockholm::writeAlignment(), bpp::Phylip::writeInterleaved(), bpp::Fasta::writeSequences(), bpp::Mase::writeSequences(), and bpp::Phylip::writeSequential().

◆ getStateValueAt()

virtual double bpp::SequencedValuesContainer::getStateValueAt ( size_t  siteIndex,
const std::string &  sequenceName,
int  state 
) const
pure virtualinherited

get value of a state in a position

Parameters
siteIndexindex of the site
sequenceNamename of the sequence in the container
statestate in the alphabet

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, and bpp::CompressedVectorSiteContainer.

◆ hasSequence()

virtual bool bpp::SequencedValuesContainer::hasSequence ( const std::string &  name) const
pure 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.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, and bpp::CompressedVectorSiteContainer.

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

◆ operator()() [1/3]

virtual const int& bpp::SequenceContainer::operator() ( const std::string &  sequenceName,
size_t  elementIndex 
) const
pure virtual

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.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, and bpp::CompressedVectorSiteContainer.

◆ operator()() [2/3]

virtual int& bpp::SequenceContainer::operator() ( const std::string &  sequenceName,
size_t  elementIndex 
)
pure virtual

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.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, and bpp::CompressedVectorSiteContainer.

◆ operator()() [3/3]

virtual double bpp::SequencedValuesContainer::operator() ( size_t  siteIndex,
const std::string &  sequenceName,
int  state 
) const
pure virtualinherited

◆ removeSequence()

virtual std::shared_ptr<Sequence> bpp::SequenceContainer::removeSequence ( const std::string &  name)
pure virtual

Extract (and remove) a sequence from the container.

Parameters
nameThe name of the sequence.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, and bpp::CompressedVectorSiteContainer.

Referenced by bpp::SequenceApplicationTools::restrictSelectedSequencesByName().

◆ setComments()

virtual void bpp::SequencedValuesContainer::setComments ( const std::string &  name,
const Comments comments 
)
pure virtualinherited

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.

Implemented in bpp::VectorProbabilisticSequenceContainer, bpp::AbstractValuesContainer, bpp::AbstractSequenceContainer, and bpp::AbstractProbabilisticSequenceContainer.

◆ setGeneralComments()

virtual void bpp::SequencedValuesContainer::setGeneralComments ( const Comments comments)
pure virtualinherited

Set the comments of this container.

Parameters
commentsThe comments to be associated to this container.

Implemented in bpp::AbstractValuesContainer, and bpp::AbstractProbabilisticSequenceContainer.

Referenced by bpp::Clustal::appendAlignmentFromStream(), bpp::Fasta::appendSequencesFromStream(), and bpp::Mase::appendSequencesFromStream().

◆ setSequence()

virtual void bpp::SequenceContainer::setSequence ( const std::string &  name,
const Sequence sequence,
bool  checkName 
)
pure 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.

Implemented in bpp::VectorSequenceContainer, bpp::AlignedSequenceContainer, bpp::VectorSiteContainer, and bpp::CompressedVectorSiteContainer.

◆ setSequenceNames()

virtual void bpp::SequencedValuesContainer::setSequenceNames ( const std::vector< std::string > &  names,
bool  checkNames 
)
pure 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.

Implemented in bpp::VectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorProbabilisticSiteContainer, bpp::VectorProbabilisticSequenceContainer, and bpp::CompressedVectorSiteContainer.

Referenced by bpp::SequenceContainerTools::createContainerWithSequenceNames(), bpp::SiteContainerTools::getCompleteSites(), and bpp::SiteContainerTools::getSitesWithoutGaps().

◆ toString()

virtual std::string bpp::SequencedValuesContainer::toString ( const std::string &  name) const
pure virtualinherited

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.

Implemented in bpp::VectorProbabilisticSequenceContainer, bpp::AbstractSequenceContainer, and bpp::AbstractProbabilisticSequenceContainer.

Referenced by bpp::SequenceContainerTools::convertAlphabet(), bpp::Phylip::writeInterleaved(), bpp::Mase::writeSequences(), and bpp::Phylip::writeSequential().

◆ valueAt() [1/2]

virtual const int& bpp::SequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
) const
pure virtual

Element access function.

Allows direct access to the data stored in the container.

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

Implemented in bpp::OrderedSequenceContainer, bpp::VectorSiteContainer, bpp::CompressedVectorSiteContainer, and bpp::VectorSequenceContainer.

◆ valueAt() [2/2]

virtual int& bpp::SequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
)
pure virtual

Element access function.

Allows direct access to the data stored in the container.

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

Implemented in bpp::OrderedSequenceContainer, bpp::VectorSiteContainer, bpp::VectorSequenceContainer, and bpp::CompressedVectorSiteContainer.


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