bpp-seq  2.2.0
bpp::Sequence Class Referenceabstract

The sequence interface. More...

#include <Bpp/Seq/Sequence.h>

+ Inheritance diagram for bpp::Sequence:
+ Collaboration diagram for bpp::Sequence:

Public Member Functions

virtual ~Sequence ()
 
Sequenceclone () const =0
 
virtual const AlphabetgetAlphabet () const =0
 Get the alphabet associated to the list. More...
 
virtual size_t size () const =0
 Get the number of elements in the list. More...
 
virtual std::string toString () const =0
 Convert the list as a string. More...
 
Setting/getting the name of the sequence.
virtual const std::string & getName () const =0
 Get the name of this sequence. More...
 
virtual void setName (const std::string &name)=0
 Set the name of this sequence. More...
 
Setting/getting the comments associated to the sequence.
virtual const CommentsgetComments () const =0
 Get the comments associated to this sequence. More...
 
virtual void setComments (const Comments &comments)=0
 Set the comments associated to this sequence. More...
 
Adjusting the size of the sequence.
virtual void setContent (const std::string &sequence)=0 throw (BadCharException)
 Set the whole content of the sequence. More...
 
virtual void setContent (const std::vector< int > &list)=0 throw (BadIntException)
 Set the whole content of the list. More...
 
virtual void setContent (const std::vector< std::string > &list)=0 throw (BadCharException)
 Set the whole content of the list. More...
 
virtual void setToSizeR (size_t newSize)=0
 Set up the size of a sequence from the right side. More...
 
virtual void setToSizeL (size_t newSize)=0
 Set up the size of a sequence from the left side. More...
 
virtual void append (const std::vector< int > &content)=0 throw (BadIntException)
 Append the specified content to the sequence. More...
 
virtual void append (const std::vector< std::string > &content)=0 throw (BadCharException)
 Append the specified content to the sequence. More...
 
virtual void append (const std::string &content)=0 throw (BadCharException)
 Append the specified content to the sequence. More...
 
Acting on the content of the list.
virtual const std::vector< int > & getContent () const =0
 Get the whole content of the list as a vector of int. More...
 
Edition methods.
virtual void addElement (const std::string &c)=0 throw (BadCharException)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, const std::string &c)=0 throw (BadCharException, IndexOutOfBoundsException)
 Add a character at a certain position in the list. More...
 
virtual void addElement (int v)=0 throw (BadIntException)
 Add a character to the end of the list. More...
 
virtual void addElement (size_t pos, int v)=0 throw (BadIntException, IndexOutOfBoundsException)
 Add a character at a certain position in the list. More...
 
virtual void setElement (size_t pos, const std::string &c)=0 throw (BadCharException, IndexOutOfBoundsException)
 Set the element at position 'pos' to character 'c'. More...
 
virtual void setElement (size_t pos, int v)=0 throw (BadIntException, IndexOutOfBoundsException)
 Set the element at position 'pos' to character 'v'. More...
 
virtual void deleteElement (size_t pos)=0 throw (IndexOutOfBoundsException)
 Delete the element at position 'pos'. More...
 
virtual void deleteElements (size_t pos, size_t len)=0 throw (IndexOutOfBoundsException)
 Delete the elements at position 'pos'. More...
 
virtual std::string getChar (size_t pos) const =0 throw (IndexOutOfBoundsException)
 Get the element at position 'pos' as a character. More...
 
virtual int getValue (size_t pos) const =0 throw (IndexOutOfBoundsException)
 Get the element at position 'pos' as an int. More...
 
Provide direct access to the list content.
Warning
These operators allow you to modifiy the list content. No alphabet checking is performed for your modifications, so use with care, or consider using the setContent() method.
virtual const int & operator[] (size_t i) const =0
 Operator [] overloaded for quick access to a character in list. More...
 
virtual int & operator[] (size_t i)=0
 Operator [] overloaded for quick access to a character in list. More...
 
virtual void shuffle ()=0
 Randomly shuffle the content of the list, with linear complexity. More...
 

Detailed Description

The sequence interface.

This is a general purpose container, containing an ordered list of states. The states that allowed to be present in the sequence are defined by an alphabet object.

Sequence objets also contain a name attribute and potentially several comment lines. A sequence object is also event-driven, allowing easy extension.

See also
Alphabet

Definition at line 74 of file Sequence.h.

Constructor & Destructor Documentation

◆ ~Sequence()

virtual bpp::Sequence::~Sequence ( )
inlinevirtual

Definition at line 78 of file Sequence.h.

Member Function Documentation

◆ addElement() [1/4]

virtual void bpp::SymbolList::addElement ( const std::string &  c)
throw (BadCharException
)
pure virtualinherited

Add a character to the end of the list.

Parameters
cThe character to add, given as a string.

Implemented in bpp::SequenceWithQuality, bpp::EdSymbolList, and bpp::BasicSymbolList.

Referenced by bpp::SequenceTools::getPutativeHaplotypes(), bpp::AbstractReverseTransliterator::reverse(), and bpp::AbstractTransliterator::translate().

◆ addElement() [2/4]

virtual void bpp::SymbolList::addElement ( size_t  pos,
const std::string &  c 
)
throw (BadCharException,
IndexOutOfBoundsException
)
pure virtualinherited

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
cThe character to add, given as a string.

Implemented in bpp::SequenceWithQuality, bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ addElement() [3/4]

virtual void bpp::SymbolList::addElement ( int  v)
throw (BadIntException
)
pure virtualinherited

Add a character to the end of the list.

Parameters
vThe character to add, given as an int.

Implemented in bpp::SequenceWithQuality, bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ addElement() [4/4]

virtual void bpp::SymbolList::addElement ( size_t  pos,
int  v 
)
throw (BadIntException,
IndexOutOfBoundsException
)
pure virtualinherited

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
vThe character to add, given as an int.

Implemented in bpp::SequenceWithQuality, bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ append() [1/3]

virtual void bpp::Sequence::append ( const std::vector< int > &  content)
throw (BadIntException
)
pure virtual

Append the specified content to the sequence.

Parameters
contentThe content to append to the sequence.
Exceptions
BadIntExceptionIf the content does not match the current alphabet.

Implemented in bpp::SequenceWithQuality, bpp::BasicSequence, and bpp::SequenceWithAnnotation.

Referenced by bpp::WordAlphabet::reverse().

◆ append() [2/3]

virtual void bpp::Sequence::append ( const std::vector< std::string > &  content)
throw (BadCharException
)
pure virtual

Append the specified content to the sequence.

Parameters
contentThe content to append to the sequence.
Exceptions
BadCharExceptionIf the content does not match the current alphabet.

Implemented in bpp::SequenceWithQuality, bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ append() [3/3]

virtual void bpp::Sequence::append ( const std::string &  content)
throw (BadCharException
)
pure virtual

Append the specified content to the sequence.

Parameters
contentThe content to append to the sequence.
Exceptions
BadCharExceptionIf the content does not match the current alphabet.

Implemented in bpp::SequenceWithQuality, bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ clone()

◆ deleteElement()

virtual void bpp::SymbolList::deleteElement ( size_t  pos)
throw (IndexOutOfBoundsException
)
pure virtualinherited

Delete the element at position 'pos'.

Parameters
posThe position of the element to delete.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

Referenced by bpp::SequenceTools::getCDS(), bpp::SequenceTools::removeGaps(), and bpp::VectorSiteContainer::removeSequence().

◆ deleteElements()

virtual void bpp::SymbolList::deleteElements ( size_t  pos,
size_t  len 
)
throw (IndexOutOfBoundsException
)
pure virtualinherited

Delete the elements at position 'pos'.

Parameters
posThe position of the first element to delete.
lenThe length of the region to delete.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ getAlphabet()

◆ getChar()

virtual std::string bpp::SymbolList::getChar ( size_t  pos) const
throw (IndexOutOfBoundsException
)
pure virtualinherited

Get the element at position 'pos' as a character.

Parameters
posThe position of the character to retrieve.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

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

◆ getComments()

virtual const Comments& bpp::Sequence::getComments ( ) const
pure virtual

Get the comments associated to this sequence.

Returns
The comments of the sequence.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

Referenced by bpp::AbstractSequenceContainer::getComments(), bpp::SequenceWithAnnotation::operator=(), and bpp::BasicSequence::operator=().

◆ getContent()

virtual const std::vector<int>& bpp::SymbolList::getContent ( ) const
pure virtualinherited

◆ getName()

virtual const std::string& bpp::Sequence::getName ( ) const
pure virtual

◆ getValue()

virtual int bpp::SymbolList::getValue ( size_t  pos) const
throw (IndexOutOfBoundsException
)
pure virtualinherited

Get the element at position 'pos' as an int.

Parameters
posThe position of the character to retrieve.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

Referenced by bpp::SequenceTools::findFirstOf(), bpp::SequenceTools::invert(), and bpp::SequenceTools::invertComplement().

◆ operator[]() [1/2]

virtual const int& bpp::SymbolList::operator[] ( size_t  i) const
pure virtualinherited

Operator [] overloaded for quick access to a character in list.

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ operator[]() [2/2]

virtual int& bpp::SymbolList::operator[] ( size_t  i)
pure virtualinherited

Operator [] overloaded for quick access to a character in list.

Parameters
iThe position to retrieve.
Returns
The integer value of character at position i.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ setComments()

virtual void bpp::Sequence::setComments ( const Comments comments)
pure virtual

Set the comments associated to this sequence.

Parameters
commentsThe new comments of the sequence.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ setContent() [1/3]

virtual void bpp::Sequence::setContent ( const std::string &  sequence)
throw (BadCharException
)
pure virtual

Set the whole content of the sequence.

Parameters
sequenceThe new content of the sequence.
See also
The Sequence constructor for information about the way sequences are internaly stored.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

Referenced by bpp::SequenceTools::getSequenceWithCompleteSites(), bpp::SequenceTools::getSequenceWithoutGaps(), and bpp::SequenceTools::getSequenceWithoutStops().

◆ setContent() [2/3]

virtual void bpp::Sequence::setContent ( const std::vector< int > &  list)
throw (BadIntException
)
pure virtual

Set the whole content of the list.

Parameters
listThe new content of the list.
See also
The list constructor for information about the way lists are internaly stored.

Implements bpp::SymbolList.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ setContent() [3/3]

virtual void bpp::Sequence::setContent ( const std::vector< std::string > &  list)
throw (BadCharException
)
pure virtual

Set the whole content of the list.

Parameters
listThe new content of the list.
See also
The list constructor for information about the way lists are internaly stored.

Implements bpp::SymbolList.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ setElement() [1/2]

virtual void bpp::SymbolList::setElement ( size_t  pos,
const std::string &  c 
)
throw (BadCharException,
IndexOutOfBoundsException
)
pure virtualinherited

Set the element at position 'pos' to character 'c'.

Parameters
posThe position of the character to set.
cThe value of the element, given as a string.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

Referenced by bpp::SequenceTools::invert(), and bpp::SequenceTools::invertComplement().

◆ setElement() [2/2]

virtual void bpp::SymbolList::setElement ( size_t  pos,
int  v 
)
throw (BadIntException,
IndexOutOfBoundsException
)
pure virtualinherited

Set the element at position 'pos' to character 'v'.

Parameters
posThe position of the character to set.
vThe value of the element, given as an int.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ setName()

virtual void bpp::Sequence::setName ( const std::string &  name)
pure virtual

Set the name of this sequence.

Parameters
nameThe new name of the sequence.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

Referenced by bpp::SequenceTools::getPutativeHaplotypes().

◆ setToSizeL()

virtual void bpp::Sequence::setToSizeL ( size_t  newSize)
pure virtual

Set up the size of a sequence from the left side.

All new characters are filled with gaps. If the specified size is < to the sequence size, the sequence will be truncated.

Parameters
newSizeThe new size of the sequence.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ setToSizeR()

virtual void bpp::Sequence::setToSizeR ( size_t  newSize)
pure virtual

Set up the size of a sequence from the right side.

All new characters are filled with gaps. If the specified size is < to the sequence size, the sequence will be truncated.

Parameters
newSizeThe new size of the sequence.

Implemented in bpp::BasicSequence, and bpp::SequenceWithAnnotation.

◆ shuffle()

virtual void bpp::SymbolList::shuffle ( )
pure virtualinherited

Randomly shuffle the content of the list, with linear complexity.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

◆ size()

◆ toString()

virtual std::string bpp::SymbolList::toString ( ) const
pure virtualinherited

Convert the list as a string.

This method is useful for dumping a list to a file or to the screen for display.

Returns
The whole list as a string.

Implemented in bpp::EdSymbolList, and bpp::BasicSymbolList.

Referenced by bpp::AbstractSequenceContainer::toString().


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