bpp-seq  2.2.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 AlphabetgetAlphabet () const =0
 Get sequence container's alphabet. More...
 
virtual const std::vector< int > & getContent (const std::string &name) const =0 throw (SequenceNotFoundException)
 Get the content of a sequence. More...
 
virtual std::string toString (const std::string &name) const =0 throw (SequenceNotFoundException)
 Convert a particular sequence to a string. More...
 
virtual const SequencegetSequence (const std::string &name) const =0 throw (SequenceNotFoundException)
 Retrieve a sequence object from the container. 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 void addSequence (const Sequence &sequence, bool checkName)=0 throw (Exception)
 Add a sequence to the container. More...
 
virtual void setSequence (const std::string &name, const Sequence &sequence, bool checkName)=0 throw (Exception)
 Replace a sequence in the container. More...
 
virtual SequenceremoveSequence (const std::string &name)=0 throw (SequenceNotFoundException, Exception)
 Extract (and remove) a sequence from the container. More...
 
virtual void deleteSequence (const std::string &name)=0 throw (SequenceNotFoundException, Exception)
 Delete a sequence of the container. More...
 
virtual size_t getNumberOfSequences () const =0
 Get the number of sequences in the container. More...
 
virtual std::vector< std::string > getSequencesNames () const =0
 Get all the names of the sequences in the container. More...
 
virtual void setSequencesNames (const std::vector< std::string > &names, bool checkNames)=0 throw (Exception)
 Set all sequence names. More...
 
virtual const CommentsgetComments (const std::string &name) const =0 throw (SequenceNotFoundException)
 Get comments of a particular sequence. More...
 
virtual void setComments (const std::string &name, const Comments &comments)=0 throw (SequenceNotFoundException)
 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 sequences in the container. More...
 
virtual SequenceContainercreateEmptyContainer () const =0
 Return a copy of this container, but with no sequence inside. More...
 
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 throw (SequenceNotFoundException, IndexOutOfBoundsException)
 Element access function. More...
 
virtual const int & valueAt (const std::string &sequenceName, size_t elementIndex) const =0 throw (SequenceNotFoundException, IndexOutOfBoundsException)
 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...
 

Detailed Description

The SequenceContainer interface.

This interface is the most general one in the container hierarchy. 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() and deleteSequence()). 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 80 of file SequenceContainer.h.

Constructor & Destructor Documentation

◆ SequenceContainer()

bpp::SequenceContainer::SequenceContainer ( )
inline

Definition at line 84 of file SequenceContainer.h.

◆ ~SequenceContainer()

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

Definition at line 85 of file SequenceContainer.h.

Member Function Documentation

◆ addSequence()

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

Add a sequence to the container.

Parameters
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
ExceptionAny other kind of exception, if the name of the sequence is already used, are whatever else depending on the implementation.

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

Referenced by bpp::SequenceContainerTools::append(), and bpp::NexusIOSequence::appendAlignmentFromStream().

◆ clear()

virtual void bpp::SequenceContainer::clear ( )
pure virtual

◆ createEmptyContainer()

virtual SequenceContainer* bpp::SequenceContainer::createEmptyContainer ( ) const
pure 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.

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

◆ deleteGeneralComments()

virtual void bpp::SequenceContainer::deleteGeneralComments ( )
pure virtual

Delete the comments associated to this container.

Implemented in bpp::AbstractSequenceContainer.

◆ deleteSequence()

virtual void bpp::SequenceContainer::deleteSequence ( const std::string &  name)
throw (SequenceNotFoundException,
Exception
)
pure virtual

Delete a sequence of the container.

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

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

◆ getAlphabet()

◆ getComments()

virtual const Comments& bpp::SequenceContainer::getComments ( const std::string &  name) const
throw (SequenceNotFoundException
)
pure virtual

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::OrderedSequenceContainer, and bpp::AbstractSequenceContainer.

◆ getContent()

virtual const std::vector<int>& bpp::SequenceContainer::getContent ( const std::string &  name) const
throw (SequenceNotFoundException
)
pure virtual

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.

Implemented in bpp::OrderedSequenceContainer, and bpp::AbstractSequenceContainer.

Referenced by bpp::SequenceContainerTools::getCounts(), and bpp::SequenceContainerTools::getFrequencies().

◆ getGeneralComments()

virtual const Comments& bpp::SequenceContainer::getGeneralComments ( ) const
pure virtual

Get the comments of this container.

Returns
The comments associated to this container.

Implemented in bpp::AbstractSequenceContainer.

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

◆ getNumberOfSequences()

virtual size_t bpp::SequenceContainer::getNumberOfSequences ( ) const
pure virtual

Get the number of sequences in the container.

Returns
The number of sequences in the container.

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

Referenced by bpp::Phylip::writeInterleaved(), and bpp::Phylip::writeSequential().

◆ getSequence()

virtual const Sequence& bpp::SequenceContainer::getSequence ( const std::string &  name) const
throw (SequenceNotFoundException
)
pure virtual

◆ getSequencesNames()

◆ hasSequence()

virtual bool bpp::SequenceContainer::hasSequence ( const std::string &  name) const
pure virtual

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::CompressedVectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorSiteContainer, and bpp::MapSequenceContainer.

◆ operator()() [1/2]

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::CompressedVectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorSiteContainer, and bpp::MapSequenceContainer.

◆ operator()() [2/2]

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::CompressedVectorSiteContainer, bpp::VectorSequenceContainer, bpp::VectorSiteContainer, and bpp::MapSequenceContainer.

◆ removeSequence()

virtual Sequence* bpp::SequenceContainer::removeSequence ( const std::string &  name)
throw (SequenceNotFoundException,
Exception
)
pure virtual

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.

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

◆ setComments()

virtual void bpp::SequenceContainer::setComments ( const std::string &  name,
const Comments comments 
)
throw (SequenceNotFoundException
)
pure virtual

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::OrderedSequenceContainer, bpp::VectorSequenceContainer, and bpp::AbstractSequenceContainer.

◆ setGeneralComments()

virtual void bpp::SequenceContainer::setGeneralComments ( const Comments comments)
pure virtual

Set the comments of this container.

Parameters
commentsThe comments to be associated to this container.

Implemented in bpp::AbstractSequenceContainer.

◆ setSequence()

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

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

◆ setSequencesNames()

virtual void bpp::SequenceContainer::setSequencesNames ( const std::vector< std::string > &  names,
bool  checkNames 
)
throw (Exception
)
pure virtual

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::OrderedSequenceContainer, bpp::MapSequenceContainer, bpp::CompressedVectorSiteContainer, bpp::VectorSequenceContainer, and bpp::VectorSiteContainer.

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

◆ toString()

virtual std::string bpp::SequenceContainer::toString ( const std::string &  name) const
throw (SequenceNotFoundException
)
pure virtual

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::OrderedSequenceContainer, and bpp::AbstractSequenceContainer.

Referenced by bpp::Phylip::writeInterleaved(), and bpp::Phylip::writeSequential().

◆ valueAt() [1/2]

virtual int& bpp::SequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
)
throw (SequenceNotFoundException,
IndexOutOfBoundsException
)
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.
Exceptions
SequenceNotFoundExceptionIf no corresponding sequence is found in the container.
IndexOutOfBoundsExceptionIf the element position is not valid.

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

◆ valueAt() [2/2]

virtual const int& bpp::SequenceContainer::valueAt ( const std::string &  sequenceName,
size_t  elementIndex 
) const
throw (SequenceNotFoundException,
IndexOutOfBoundsException
)
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.
Exceptions
SequenceNotFoundExceptionIf no corresponding sequence is found in the container.
IndexOutOfBoundsExceptionIf the element position is not valid.

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


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