MDA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
Related Functions | List of all members
MDAT::Sequence Class Reference

A generic class to represent a plain sequence. More...

#include <Sequence.hpp>

Inheritance diagram for MDAT::Sequence:
MDAT::DNASequence MDAT::ProteinSequence

Public Member Functions

Constructors & Destructors
 Sequence (const std::string &seq_name, const std::string &seq, const std::string &comment_="", size_t seq_id=0)
 A simple sequence constuctor. More...
 
 Sequence (const std::string &seq_name, const std::string &comment_, unsigned int seq_length, size_t seq_id=0)
 A sequence constructor which allows the reservation of memory. More...
 
 Sequence (const Sequence &seq)
 The copy constructor. More...
 
virtual ~Sequence ()
 Destructor.
 
Basic methods
const std::string & name () const
 Returns the name of the sequence. More...
 
void name (const std::string &na)
 
const std::string & sequence () const
 Returns the sequence as a string. More...
 
void sequence (const std::string &seq)
 Sets the sequence. More...
 
const std::string & comment () const
 Returns the comment of a string. More...
 
void comment (const std::string &com)
 Sets the comment. More...
 
size_t size () const
 The length of the sequence. More...
 
size_t length () const
 The length of the sequence. More...
 
size_t ungapped_size () const
 The size of the sequence without gaps. More...
 
size_t id () const
 Returns the sequence id of the sequence. More...
 
void id (size_t val)
 Sets the id of the sequence. More...
 
Manipulation methods
template<class T >
void append (const T &seq)
 Appends a string to the sequence.
 
void append (const Sequence &seq)
 Appends a string to the sequence.
 
void append (char c)
 Appends a char to the sequence.
 
void resize (unsigned int new_length)
 Resizes the sequence. More...
 
void to_upper ()
 Turns all charachters of the sequence to uppercase.
 
void to_lower ()
 Turns all characters of the sequence to lowercase.
 
void reverse ()
 Reverses the order of characters in the sequence.
 
void insert_gaps (const std::vector< std::pair< unsigned int, unsigned int > > vec)
 Inserts gaps into the sequence. More...
 
void insert_gaps (const std::string &edit_string)
 

Related Functions

(Note that these are not member functions.)

template<typename SequenceType >
SequenceType substr (const SequenceType &seq, size_t start, size_t length)
 returns a new Sequence that is a substring of an existing one. More...
 
template<typename SequenceType >
SequenceType substr_no_renaming (const SequenceType &seq, size_t start, size_t length)
 returns a new Sequence that is a substring of an existing one. More...
 
template<typename SequenceType >
SequenceType * substr_end (const SequenceType &seq, size_t start, size_t end)
 returns a new Sequence that is a substring of an existing one. More...
 
template<typename SequenceType >
void reverse_complement (SequenceType &seq)
 Computes the reverse complement of a DNA sequence. More...
 
template<typename SequenceTypeIn , typename SequenceTypeOut >
SequenceTypeOut dna2prot (const SequenceTypeIn &seq)
 Turns a DNA sequence into a ProteinSequence. More...
 

Operators

char & operator[] (unsigned int index)
 Access operator. More...
 
const char & operator[] (unsigned int index) const
 
Sequenceoperator= (const Sequence &other)
 
bool operator== (const Sequence &a, const Sequence &b)
 Comparison operators. More...
 
bool operator!= (const Sequence &a, const Sequence &b)
 Comparison operators. More...
 
bool operator< (const Sequence &a, const Sequence &b)
 Lesser operator. More...
 
bool operator> (const Sequence &a, const Sequence &b)
 Greater operator. More...
 
bool operator<= (const Sequence &a, const Sequence &b)
 Lesser or equal operator. More...
 
bool operator>= (const Sequence &a, const Sequence &b)
 Greater or equal operator. More...
 
std::ostream & operator<< (std::ostream &out, const Sequence &seq)
 

Detailed Description

A generic class to represent a plain sequence.

Constructor & Destructor Documentation

MDAT::Sequence::Sequence ( const std::string &  seq_name,
const std::string &  seq,
const std::string &  comment_ = "",
size_t  seq_id = 0 
)

A simple sequence constuctor.

Parameters
seq_nameThe sequence name.
comment_A sequence comment.
seqThe sequence.
seq_idThe sequence id to give to the sequence.
MDAT::Sequence::Sequence ( const std::string &  seq_name,
const std::string &  comment_,
unsigned int  seq_length,
size_t  seq_id = 0 
)

A sequence constructor which allows the reservation of memory.

The memory for the actual sequence will be reserved but the actual sequence can be larger without causing problems.

Parameters
seq_nameThe sequence name.
comment_A sequence comment.
seq_lengthThe sequence size for which memory should be reserved.
seq_idThe sequence id to give to the sequence.
MDAT::Sequence::Sequence ( const Sequence seq)

The copy constructor.

Parameters
seqThe sequence of wich a copy should be made.

Member Function Documentation

const std::string& MDAT::Sequence::comment ( ) const
inline

Returns the comment of a string.

Returns
The comment.
void MDAT::Sequence::comment ( const std::string &  com)
inline

Sets the comment.

Parameters
comThe comment.
size_t MDAT::Sequence::id ( ) const
inline

Returns the sequence id of the sequence.

It represents the order in which the sequences were read.

Returns
The id of the sequence.
void MDAT::Sequence::id ( size_t  val)
inline

Sets the id of the sequence.

Parameters
valThe new value.
void MDAT::Sequence::insert_gaps ( const std::vector< std::pair< unsigned int, unsigned int > >  vec)

Inserts gaps into the sequence.

Parameters
vecA vector of pairs. The first value of a pair gives the position of the gap, the second one the length of it.
size_t MDAT::Sequence::length ( ) const
inline

The length of the sequence.

Returns
Length of the sequence.
const std::string& MDAT::Sequence::name ( ) const
inline

Returns the name of the sequence.

Returns
The name.
char& MDAT::Sequence::operator[] ( unsigned int  index)
inline

Access operator.

Parameters
indexThe index of to access.
const char& MDAT::Sequence::operator[] ( unsigned int  index) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MDAT::Sequence::resize ( unsigned int  new_length)
inline

Resizes the sequence.

Parameters
new_lengthThe new_length.
const std::string& MDAT::Sequence::sequence ( ) const
inline

Returns the sequence as a string.

Returns
The sequence.
void MDAT::Sequence::sequence ( const std::string &  seq)
inline

Sets the sequence.

Parameters
seqThe sequence
size_t MDAT::Sequence::size ( ) const
inline

The length of the sequence.

Returns
Length of the sequence.
size_t MDAT::Sequence::ungapped_size ( ) const

The size of the sequence without gaps.

Returns
The size of the ungapped sequence.

Friends And Related Function Documentation

template<typename SequenceTypeIn , typename SequenceTypeOut >
SequenceTypeOut dna2prot ( const SequenceTypeIn &  seq)
related

Turns a DNA sequence into a ProteinSequence.

Template Parameters
SequenceTypeInThe type of the sequence input
SequenceTypeOutThe outputType of the sequence
Parameters
seqThe sequence to translate.
Returns
The new Sequence.
bool operator!= ( const Sequence a,
const Sequence b 
)
friend

Comparison operators.

Parameters
aThe first sequence.
bThe second sequence.
bool operator< ( const Sequence a,
const Sequence b 
)
friend

Lesser operator.

Parameters
aThe first sequence.
bThe second sequence.
bool operator<= ( const Sequence a,
const Sequence b 
)
friend

Lesser or equal operator.

Parameters
aThe first sequence.
bThe second sequence.
bool operator== ( const Sequence a,
const Sequence b 
)
friend

Comparison operators.

Parameters
aThe first sequence.
bThe second sequence.
bool operator> ( const Sequence a,
const Sequence b 
)
friend

Greater operator.

Parameters
aThe first sequence.
bThe second sequence.
bool operator>= ( const Sequence a,
const Sequence b 
)
friend

Greater or equal operator.

Parameters
aThe first sequence.
bThe second sequence.
template<typename SequenceType >
void reverse_complement ( SequenceType &  seq)
related

Computes the reverse complement of a DNA sequence.

Parameters
seqThe sequence to change.
template<typename SequenceType >
SequenceType substr ( const SequenceType &  seq,
size_t  start,
size_t  length 
)
related

returns a new Sequence that is a substring of an existing one.

Parameters
seqThe sequence to produce the new one from.
startThe start position of the substring.
lengthThe lengths of the substr.
Returns
The new sequence.
template<typename SequenceType >
SequenceType * substr_end ( const SequenceType &  seq,
size_t  start,
size_t  end 
)
related

returns a new Sequence that is a substring of an existing one.

Parameters
seqThe sequence to produce the new one from.
startThe start position of the substring.
endThe last position of the substring in sequence.
Returns
The new sequence.
template<typename SequenceType >
SequenceType substr_no_renaming ( const SequenceType &  seq,
size_t  start,
size_t  length 
)
related

returns a new Sequence that is a substring of an existing one.

Parameters
seqThe sequence to produce the new one from.
startThe start position of the substring.
lengthThe lengths of the substr.
Returns
The new sequence.