bpp-seq
2.2.0
|
MapSequenceContainer class. More...
#include <Bpp/Seq/Container/MapSequenceContainer.h>
Public Member Functions | |
MapSequenceContainer (const std::map< std::string, Sequence *> &ms, const Alphabet *alpha) | |
MapSequenceContainer (const Alphabet *alpha) | |
MapSequenceContainer (const MapSequenceContainer &msc) | |
MapSequenceContainer & | operator= (const MapSequenceContainer &msc) |
virtual | ~MapSequenceContainer () |
const Sequence & | getSequenceByKey (const std::string &key) const throw (SequenceNotFoundException) |
Get a sequence. More... | |
void | setSequenceByKey (const std::string &key, const Sequence &sequence, bool checkNames=true) throw (SequenceNotFoundException) |
Set a sequence. More... | |
Sequence * | removeSequenceByKey (const std::string &key) throw (SequenceNotFoundException) |
Remove a sequence. More... | |
void | deleteSequenceByKey (const std::string &key) throw (SequenceNotFoundException) |
Delete a sequence. More... | |
void | addSequence (const std::string &key, const Sequence &sequence, bool checkNames=true) throw (Exception) |
Add a sequence and key. More... | |
std::vector< std::string > | getKeys () const |
std::string | getKey (size_t pos) const throw (IndexOutOfBoundsException) |
std::string | getKey (const std::string &name) const throw (SequenceNotFoundException) |
The clonable interface | |
MapSequenceContainer * | clone () const |
The SequenceContainer interface implementation: | |
const Sequence & | getSequence (const std::string &name) const throw (SequenceNotFoundException) |
Retrieve a sequence object from the container. More... | |
bool | hasSequence (const std::string &name) const |
Check if a sequence with a given name is present in the container. More... | |
void | addSequence (const Sequence &sequence, bool checkNames=true) throw (Exception) |
The SequenceContainer method. Calls the addSeqeucne(key, Sequence) method while using the resut of sequence.getName() as a key. More... | |
void | setSequence (const std::string &name, const Sequence &sequence, bool checkName=true) throw (SequenceNotFoundException) |
Replace a sequence in the container. More... | |
Sequence * | removeSequence (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... | |
void | clear () |
Delete all sequences in the container. More... | |
MapSequenceContainer * | createEmptyContainer () const |
Return a copy of this container, but with no sequence inside. 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 & | 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 & | 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() (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 implementation: | |
const Sequence & | getSequence (size_t sequenceIndex) const throw (IndexOutOfBoundsException) |
Retrieve a sequence object from the container. More... | |
size_t | getSequencePosition (const std::string &name) const throw (SequenceNotFoundException) |
Get the position of a sequence in sequence container from its name. More... | |
void | setSequence (size_t sequenceIndex, const Sequence &sequence, bool checkName=true) throw (IndexOutOfBoundsException) |
Replace a sequence in the container. More... | |
Sequence * | removeSequence (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 (size_t sequenceIndex, const Comments &comments) throw (IndexOutOfBoundsException) |
Set the comments of a particular sequence. 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) throw (Exception) |
Set all sequence names. More... | |
AbstractSequenceContainer methods. | |
Sequence & | getSequence_ (size_t i) throw (IndexOutOfBoundsException) |
Sequence & | getSequence_ (const std::string &name) throw (SequenceNotFoundException) |
From the SequenceContainer interface | |
const Alphabet * | getAlphabet () 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... | |
void | setComments (const std::string &name, const Comments &comments) throw (SequenceNotFoundException) |
Set the 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... | |
Private Attributes | |
std::map< std::string, Sequence * > | sequences_ |
MapSequenceContainer class.
Sequences are stored using a key std::string, in a map object. Sequences are ordered according to the key order (defined by the < operator).
Definition at line 63 of file MapSequenceContainer.h.
MapSequenceContainer::MapSequenceContainer | ( | const std::map< std::string, Sequence *> & | ms, |
const Alphabet * | alpha | ||
) |
Definition at line 50 of file MapSequenceContainer.cpp.
References addSequence().
Referenced by clone(), and createEmptyContainer().
|
inline |
Definition at line 71 of file MapSequenceContainer.h.
MapSequenceContainer::MapSequenceContainer | ( | const MapSequenceContainer & | msc | ) |
Definition at line 61 of file MapSequenceContainer.cpp.
References addSequence(), getKey(), getNumberOfSequences(), and getSequence().
|
virtual |
Definition at line 87 of file MapSequenceContainer.cpp.
References clear().
void MapSequenceContainer::addSequence | ( | const std::string & | key, |
const Sequence & | sequence, | ||
bool | checkNames = true |
||
) | |||
throw | ( | Exception | |
) |
Add a sequence and key.
key | The key of the new sequence. |
sequence | The new sequence that will be associated to the key. |
checkNames | Tell is the sequence name must be checked. |
Definition at line 344 of file MapSequenceContainer.cpp.
Referenced by addSequence(), MapSequenceContainer(), and operator=().
|
inlinevirtual |
The SequenceContainer method. Calls the addSeqeucne(key, Sequence) method while using the resut of sequence.getName() as a key.
Implements bpp::SequenceContainer.
Definition at line 166 of file MapSequenceContainer.h.
References addSequence(), and bpp::Sequence::getName().
|
virtual |
Delete all sequences in the container.
Implements bpp::SequenceContainer.
Definition at line 447 of file MapSequenceContainer.cpp.
References sequences_.
Referenced by operator=(), and ~MapSequenceContainer().
|
inline |
Definition at line 149 of file MapSequenceContainer.h.
References MapSequenceContainer().
|
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.
Implements bpp::SequenceContainer.
Definition at line 458 of file MapSequenceContainer.cpp.
References bpp::AbstractSequenceContainer::getAlphabet(), bpp::AbstractSequenceContainer::getGeneralComments(), MapSequenceContainer(), and bpp::AbstractSequenceContainer::setGeneralComments().
|
inlinevirtualinherited |
Delete the comments associated to this container.
Implements bpp::SequenceContainer.
Definition at line 150 of file AbstractSequenceContainer.h.
References bpp::AbstractSequenceContainer::comments_.
|
virtual |
Delete a sequence of the container.
name | The name of the sequence. |
SequenceNotFoundException | If the name does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 318 of file MapSequenceContainer.cpp.
|
virtual |
Delete a sequence of the container.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If the position does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 306 of file MapSequenceContainer.cpp.
void MapSequenceContainer::deleteSequenceByKey | ( | const std::string & | key | ) | |
throw | ( | SequenceNotFoundException | |||
) |
Delete a sequence.
key | The key of the sequence. |
SequenceNotFoundException | If no sequence is associated to the given key. |
Definition at line 333 of file MapSequenceContainer.cpp.
|
inlinevirtualinherited |
Get sequence container's alphabet.
Implements bpp::SequenceContainer.
Definition at line 123 of file AbstractSequenceContainer.h.
References bpp::AbstractSequenceContainer::alphabet_.
Referenced by createEmptyContainer(), bpp::VectorSiteContainer::createEmptyContainer(), bpp::VectorSequenceContainer::createEmptyContainer(), bpp::CompressedVectorSiteContainer::createEmptyContainer(), and bpp::VectorSiteContainer::realloc().
|
inlinevirtualinherited |
Get comments of a particular sequence.
name | The name of the sequence. |
SequenceNotFoundException | If 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().
|
inlinevirtualinherited |
Get comments of a particular sequence.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If 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().
|
inlinevirtualinherited |
Get the content of a sequence.
name | The name of the sequence. |
SequenceNotFoundException | If 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().
|
inlinevirtualinherited |
Get the content of a sequence.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If 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().
|
inlinevirtualinherited |
Get the comments of this container.
Implements bpp::SequenceContainer.
Definition at line 140 of file AbstractSequenceContainer.h.
References bpp::AbstractSequenceContainer::comments_.
Referenced by createEmptyContainer(), bpp::VectorSiteContainer::createEmptyContainer(), bpp::VectorSequenceContainer::createEmptyContainer(), and bpp::CompressedVectorSiteContainer::createEmptyContainer().
string MapSequenceContainer::getKey | ( | size_t | pos | ) | const |
throw | ( | IndexOutOfBoundsException | |||
) |
pos | The index of the sequence. |
IndexOutOfBoundsException | If pos is not a valid index. |
Definition at line 380 of file MapSequenceContainer.cpp.
Referenced by MapSequenceContainer().
string MapSequenceContainer::getKey | ( | const std::string & | name | ) | const |
throw | ( | SequenceNotFoundException | |||
) |
name | The name of the sequence. |
SequenceNotFoundException | If no sequence was found with the given name. |
Definition at line 391 of file MapSequenceContainer.cpp.
References bpp::SequenceNotFoundException::getSequenceId().
vector< string > MapSequenceContainer::getKeys | ( | ) | const |
Definition at line 370 of file MapSequenceContainer.cpp.
References sequences_.
Referenced by operator=().
|
inlinevirtualinherited |
Get the name of a particular sequence.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If 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().
|
inlinevirtual |
Get the number of sequences in the container.
Implements bpp::OrderedSequenceContainer.
Definition at line 173 of file MapSequenceContainer.h.
References sequences_.
Referenced by MapSequenceContainer(), and operator=().
|
virtual |
Retrieve a sequence object from the container.
name | The name of the sequence. |
SequenceNotFoundException | If the name does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 108 of file MapSequenceContainer.cpp.
Referenced by MapSequenceContainer(), operator()(), operator=(), and valueAt().
|
virtual |
Retrieve a sequence object from the container.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If the position does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 94 of file MapSequenceContainer.cpp.
Sequence & MapSequenceContainer::getSequence_ | ( | size_t | i | ) | |
throw | ( | IndexOutOfBoundsException | |||
) |
Definition at line 130 of file MapSequenceContainer.cpp.
Referenced by operator()(), and valueAt().
Sequence & MapSequenceContainer::getSequence_ | ( | const std::string & | name | ) | |
throw | ( | SequenceNotFoundException | |||
) |
Definition at line 141 of file MapSequenceContainer.cpp.
const Sequence & MapSequenceContainer::getSequenceByKey | ( | const std::string & | key | ) | const |
throw | ( | SequenceNotFoundException | |||
) |
Get a sequence.
key | The key of the sequence to retrieve. |
SequenceNotFoundException | If no sequence is associated to the given key. |
Definition at line 152 of file MapSequenceContainer.cpp.
|
virtual |
Get the position of a sequence in sequence container from its name.
name | The name of the sequence. |
SequenceNotFoundException | If no sequence with name 'name' could be found. |
Implements bpp::OrderedSequenceContainer.
Definition at line 163 of file MapSequenceContainer.cpp.
|
virtual |
Get all the names of the sequences in the container.
Implements bpp::OrderedSequenceContainer.
Definition at line 416 of file MapSequenceContainer.cpp.
References sequences_.
|
virtual |
Check if a sequence with a given name is present in the container.
name | The name of the sequence. |
Implements bpp::SequenceContainer.
Definition at line 119 of file MapSequenceContainer.cpp.
References sequences_.
|
inlinevirtual |
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!
sequenceName | The sequence name. |
elementIndex | The element position within the sequence. |
Implements bpp::SequenceContainer.
Definition at line 185 of file MapSequenceContainer.h.
References getSequence_().
|
inlinevirtual |
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!
sequenceName | The sequence name. |
elementIndex | The element position within the sequence. |
Implements bpp::SequenceContainer.
Definition at line 189 of file MapSequenceContainer.h.
References getSequence().
|
inlinevirtual |
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!
sequenceIndex | The sequence position. |
elementIndex | The element position within the sequence. |
Implements bpp::OrderedSequenceContainer.
Definition at line 202 of file MapSequenceContainer.h.
References getSequence_().
|
inlinevirtual |
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!
sequenceIndex | The sequence position. |
elementIndex | The element position within the sequence. |
Implements bpp::OrderedSequenceContainer.
Definition at line 206 of file MapSequenceContainer.h.
References getSequence().
MapSequenceContainer & MapSequenceContainer::operator= | ( | const MapSequenceContainer & | msc | ) |
Definition at line 70 of file MapSequenceContainer.cpp.
References addSequence(), clear(), getKeys(), getNumberOfSequences(), getSequence(), and bpp::AbstractSequenceContainer::operator=().
|
virtual |
Extract (and remove) a sequence from the container.
name | The name of the sequence. |
SequenceNotFoundException | If the name does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 278 of file MapSequenceContainer.cpp.
|
virtual |
Extract (and remove) a sequence from the container.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If the name does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Definition at line 265 of file MapSequenceContainer.cpp.
Sequence * MapSequenceContainer::removeSequenceByKey | ( | const std::string & | key | ) | |
throw | ( | SequenceNotFoundException | |||
) |
Remove a sequence.
key | The key of the sequence. |
SequenceNotFoundException | If no sequence is associated to the given key. |
Definition at line 293 of file MapSequenceContainer.cpp.
|
virtualinherited |
Set the comments of a particular sequence.
name | The name of the sequence. |
comments | The comments to set to sequence with name 'name'. |
SequenceNotFoundException | If the name does not match any sequence in the container. |
Implements bpp::OrderedSequenceContainer.
Reimplemented in bpp::VectorSequenceContainer.
Definition at line 48 of file AbstractSequenceContainer.cpp.
Referenced by bpp::VectorSequenceContainer::setComments().
|
virtual |
Set the comments of a particular sequence.
sequenceIndex | The position of the sequence. |
comments | The comments to set to sequence with position 'i'. |
IndexOutOfBoundsException | If the position does not match any sequence in the container. |
Implements bpp::AbstractSequenceContainer.
Definition at line 405 of file MapSequenceContainer.cpp.
|
inlinevirtualinherited |
Set the comments of this container.
comments | The comments to be associated to this container. |
Implements bpp::SequenceContainer.
Definition at line 145 of file AbstractSequenceContainer.h.
References bpp::AbstractSequenceContainer::comments_.
Referenced by bpp::AlignedSequenceContainer::createEmptyContainer(), createEmptyContainer(), bpp::VectorSiteContainer::createEmptyContainer(), bpp::VectorSequenceContainer::createEmptyContainer(), bpp::CompressedVectorSiteContainer::createEmptyContainer(), bpp::SiteContainerTools::getSelectedSites(), and bpp::VectorSequenceContainer::VectorSequenceContainer().
|
virtual |
Replace a sequence in the container.
name | The name of the sequence. |
sequence | The sequence to add. |
checkName | Tell if the container must check if the name of the sequence is already used in the container before adding it. |
SequenceNotFoundException | If the name does not match any sequence in the container. |
Exception | Any 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 209 of file MapSequenceContainer.cpp.
|
virtual |
Replace a sequence in the container.
sequenceIndex | The position of the sequence. |
sequence | The sequence to add. |
checkName | Tell if the container must check if the name of the sequence is already used in the container before adding it. |
IndexOutOfBoundsException | If the position does not match any sequence in the container. |
Exception | Any other kind of exception. |
Implements bpp::OrderedSequenceContainer.
Definition at line 179 of file MapSequenceContainer.cpp.
void MapSequenceContainer::setSequenceByKey | ( | const std::string & | key, |
const Sequence & | sequence, | ||
bool | checkNames = true |
||
) | |||
throw | ( | SequenceNotFoundException | |
) |
Set a sequence.
key | The key of the sequence. |
sequence | The new sequence that will be associated to the key. |
checkNames | Tell is the sequence name must be checked. |
SequenceNotFoundException | If no sequence is associated to the given key. |
Definition at line 237 of file MapSequenceContainer.cpp.
|
virtual |
Set all sequence names.
names | A vector of strings with all sequence names. Its size must be strictly equal to the the size of the container (the number of sequences). |
checkNames | Tell if the container must check if the name of the sequence is already used in the container before adding it. |
Exception | If there are redundant names in the input vector. |
Implements bpp::OrderedSequenceContainer.
Definition at line 426 of file MapSequenceContainer.cpp.
|
inlinevirtualinherited |
Convert a particular sequence to a string.
name | The name of the sequence. |
SequenceNotFoundException | If 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().
|
inlinevirtualinherited |
Convert a particular sequence to a string.
sequenceIndex | The position of the sequence. |
IndexOutOfBoundsException | If 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().
|
inlinevirtual |
Element access function.
Allows direct access to the data stored in the container.
sequenceName | The sequence name. |
elementIndex | The element position within the sequence. |
SequenceNotFoundException | If no corresponding sequence is found in the container. |
IndexOutOfBoundsException | If the element position is not valid. |
Implements bpp::OrderedSequenceContainer.
Definition at line 177 of file MapSequenceContainer.h.
References getSequence_().
|
inlinevirtual |
Element access function.
Allows direct access to the data stored in the container.
sequenceName | The sequence name. |
elementIndex | The element position within the sequence. |
SequenceNotFoundException | If no corresponding sequence is found in the container. |
IndexOutOfBoundsException | If the element position is not valid. |
Implements bpp::OrderedSequenceContainer.
Definition at line 181 of file MapSequenceContainer.h.
References getSequence().
|
inlinevirtual |
Element access operator.
Allows direct access to the data stored in the container.
sequenceIndex | The sequence position. |
elementIndex | The element position within the sequence. |
IndexOutOfBoundsException | If a position is not valid. |
Implements bpp::OrderedSequenceContainer.
Definition at line 194 of file MapSequenceContainer.h.
References getSequence_().
|
inlinevirtual |
Element access operator.
Allows direct access to the data stored in the container.
sequenceIndex | The sequence position. |
elementIndex | The element position within the sequence. |
IndexOutOfBoundsException | If a position is not valid. |
Implements bpp::OrderedSequenceContainer.
Definition at line 198 of file MapSequenceContainer.h.
References getSequence().
|
private |
Definition at line 67 of file MapSequenceContainer.h.
Referenced by clear(), getKeys(), getNumberOfSequences(), getSequencesNames(), and hasSequence().