bpp-seq3  3.0.0
bpp::SimpleSequencePositionIterator Class Reference

Loop over all positions in a Sequence. More...

#include <Bpp/Seq/SequencePositionIterators.h>

+ Inheritance diagram for bpp::SimpleSequencePositionIterator:
+ Collaboration diagram for bpp::SimpleSequencePositionIterator:

Public Member Functions

bool hasMorePositions () const
 Tells if there is more positions in the Sequence. More...
 
unsigned int getPosition () const
 Get the actual position of the iterator in the Sequence. More...
 
void setPosition (unsigned int pos)
 Set the position of the iterator. More...
 
int getValue () const
 Get the numerical value of the Sequence at current position. More...
 
std::string getChar () const
 Get the textual value of the Sequence at current position. More...
 
const SequencegetSequence () const
 Get the Sequence on which the iterator loops. More...
 
Constructors and destructor
 SimpleSequencePositionIterator (const Sequence &seq, unsigned int pos=0)
 General constructor. More...
 
 SimpleSequencePositionIterator (const SequencePositionIterator &it)
 Copy constructor. More...
 
virtual ~SimpleSequencePositionIterator ()
 
Operators
SimpleSequencePositionIteratoroperator++ ()
 
virtual SimpleSequencePositionIterator operator++ (int i)
 
SimpleSequencePositionIteratoroperator+= (int i)
 
SimpleSequencePositionIteratoroperator-= (int i)
 
virtual SimpleSequencePositionIterator operator+ (int i) const
 
virtual SimpleSequencePositionIterator operator- (int i) const
 
Comparison operators
bool operator== (const SequencePositionIterator &it) const
 
bool operator!= (const SequencePositionIterator &it) const
 

Private Attributes

const Sequencesequence_
 
unsigned int currentPosition_
 

Detailed Description

Loop over all positions in a Sequence.

This is the simplest implementation of SequencePositionIterator. It just loops over all positions of a Sequence.

Sequence seq = Sequence("seq1", "ATTCGATCCG-G", &AlphabetTools::DNA_ALPHABET);
for (SimpleSequencePositionIterator it(seq) ; it.hasMorePositions() ; ++it) {
cout << it.getPosition() << " : " << it.getValue() << " (" << it.getChar() << ")" << endl;
}
static std::shared_ptr< const DNA > DNA_ALPHABET
Definition: AlphabetTools.h:34
SimpleSequencePositionIterator(const Sequence &seq, unsigned int pos=0)
General constructor.
Author
Sylvain Gaillard

Definition at line 126 of file SequencePositionIterators.h.

Constructor & Destructor Documentation

◆ SimpleSequencePositionIterator() [1/2]

bpp::SimpleSequencePositionIterator::SimpleSequencePositionIterator ( const Sequence seq,
unsigned int  pos = 0 
)
inline

General constructor.

Parameters
seqA reference toward the Sequence object we want to loop over
posOptional integer where to start on the Sequence object

Definition at line 143 of file SequencePositionIterators.h.

◆ SimpleSequencePositionIterator() [2/2]

SimpleSequencePositionIterator::SimpleSequencePositionIterator ( const SequencePositionIterator it)

Copy constructor.

Parameters
itA reference toward a SequencePositionIterator

Definition at line 65 of file SequencePositionIterators.cpp.

◆ ~SimpleSequencePositionIterator()

virtual bpp::SimpleSequencePositionIterator::~SimpleSequencePositionIterator ( )
inlinevirtual

Definition at line 151 of file SequencePositionIterators.h.

Member Function Documentation

◆ getChar()

string AbstractSequencePositionIterator::getChar ( ) const
virtualinherited

Get the textual value of the Sequence at current position.

Implements bpp::SequencePositionIterator.

Definition at line 54 of file SequencePositionIterators.cpp.

◆ getPosition()

unsigned int AbstractSequencePositionIterator::getPosition ( ) const
virtualinherited

Get the actual position of the iterator in the Sequence.

Implements bpp::SequencePositionIterator.

Definition at line 40 of file SequencePositionIterators.cpp.

Referenced by hasMorePositions(), operator++(), and operator+=().

◆ getSequence()

const Sequence & AbstractSequencePositionIterator::getSequence ( ) const
virtualinherited

Get the Sequence on which the iterator loops.

Returns
A reference toward the Sequence object.

Implements bpp::SequencePositionIterator.

Definition at line 33 of file SequencePositionIterators.cpp.

Referenced by hasMorePositions().

◆ getValue()

int AbstractSequencePositionIterator::getValue ( ) const
virtualinherited

Get the numerical value of the Sequence at current position.

Implements bpp::SequencePositionIterator.

Definition at line 47 of file SequencePositionIterators.cpp.

◆ hasMorePositions()

bool SimpleSequencePositionIterator::hasMorePositions ( ) const
virtual

Tells if there is more positions in the Sequence.

Returns
true if there is more positions in the Sequence

Implements bpp::SequencePositionIterator.

Definition at line 127 of file SequencePositionIterators.cpp.

References bpp::AbstractSequencePositionIterator::getPosition(), bpp::AbstractSequencePositionIterator::getSequence(), and bpp::AbstractTemplateSymbolList< T >::size().

◆ operator!=()

bool AbstractSequencePositionIterator::operator!= ( const SequencePositionIterator it) const
virtualinherited

◆ operator+()

SimpleSequencePositionIterator SimpleSequencePositionIterator::operator+ ( int  i) const
virtual

Definition at line 111 of file SequencePositionIterators.cpp.

◆ operator++() [1/2]

◆ operator++() [2/2]

SimpleSequencePositionIterator SimpleSequencePositionIterator::operator++ ( int  i)
virtual

Definition at line 78 of file SequencePositionIterators.cpp.

◆ operator+=()

◆ operator-()

SimpleSequencePositionIterator SimpleSequencePositionIterator::operator- ( int  i) const
virtual

Definition at line 120 of file SequencePositionIterators.cpp.

◆ operator-=()

SimpleSequencePositionIterator & SimpleSequencePositionIterator::operator-= ( int  i)
virtual

Implements bpp::SequencePositionIterator.

Definition at line 104 of file SequencePositionIterators.cpp.

◆ operator==()

bool AbstractSequencePositionIterator::operator== ( const SequencePositionIterator it) const
virtualinherited

◆ setPosition()

void AbstractSequencePositionIterator::setPosition ( unsigned int  pos)
virtualinherited

Set the position of the iterator.

Parameters
posThe position on the Sequence

Implements bpp::SequencePositionIterator.

Definition at line 26 of file SequencePositionIterators.cpp.

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

Member Data Documentation

◆ currentPosition_

unsigned int bpp::AbstractSequencePositionIterator::currentPosition_
privateinherited

◆ sequence_

const Sequence* bpp::AbstractSequencePositionIterator::sequence_
privateinherited

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