bpp-seq  2.1.0
bpp::StringSequenceTools Class Reference

Utilitary methods working on raw string objects. More...

#include <Bpp/Seq/StringSequenceTools.h>

List of all members.

Public Member Functions

 StringSequenceTools ()
 ~StringSequenceTools ()

Static Public Member Functions

static std::string subseq (const std::string &sequence, int begin, int end) throw (Exception)
 Get a subsequence.
static std::string setToSizeR (const std::string &sequence, int size)
 Set up the size of a sequence from the right side.
static std::string setToSizeL (const std::string &sequence, int size)
 Set up the size of a sequence from the left side.
static std::string deleteChar (const std::string &sequence, char chars)
 Delete all occurence of a character in the sequence.
static std::string deleteChar (const std::string &sequence, std::string chars)
 Delete all occurence of several characters in the sequence.
static std::string * reverse (const std::string &sequence)
 Reverse the sequence.
static std::string * complement (const std::string &sequence)
 Get the complement of a sequence.
static double getGCcontent (const std::string &sequence, size_t pos, size_t window) throw (BadIntegerException, Exception)
 Calculate the local GC content of a sequence.
static std::vector< int > codeSequence (const std::string &sequence, const Alphabet *alphabet) throw (BadCharException)
 Convert a string sequence to a vector of int.
static std::string decodeSequence (const std::vector< int > &sequence, const Alphabet *alphabet) throw (BadIntException)
 Convert a sequence to its string representation.
static AlphabetgetAlphabetFromSequence (const std::string &sequence) throw (EmptySequenceException, SequenceException, AlphabetException)
 Parse a sequence and try to guess the correct alphabet to use.

Detailed Description

Utilitary methods working on raw string objects.

Sequences may be stored as strings, but this approach is not as powerful as using true sequence objects. Consider using the Sequence and SequenceTools classes for more methods.

Some of the methods implemented here are internally used by the Sequence object.

See also:
Sequence, Site, SequenceTools, SiteTools

Definition at line 66 of file StringSequenceTools.h.


Constructor & Destructor Documentation


Member Function Documentation

vector< int > StringSequenceTools::codeSequence ( const std::string &  sequence,
const Alphabet alphabet 
) throw (BadCharException) [static]

Convert a string sequence to a vector of int.

This method is used in the sequence constructor. This deals with the most simple cases: the sequence (string) contains a succession of all characters. This is indeed the case for simple alphabets, but may be more complicated if the alphabet is coded with variable code length.

Parameters:
sequenceThe sequence to parse.
alphabetThe alphabet to use to code the sequence.
Returns:
A vector of int codes.
Exceptions:
BarCharExceptionIf some character does not match the specified alphabet.

Definition at line 272 of file StringSequenceTools.cpp.

References bpp::AlphabetTools::getAlphabetCodingSize().

Referenced by bpp::SequenceWithAnnotation::append(), bpp::BasicSequence::append(), bpp::SequenceWithAnnotation::setContent(), and bpp::BasicSequence::setContent().

string * StringSequenceTools::complement ( const std::string &  sequence) [static]

Get the complement of a sequence.

Deprecated:
Consider working with sequence objects and translators.

For this method, sequence is supposed to be of type DNA.

Parameters:
sequenceThe sequence to complement.
Returns:
The complementary sequence.
See also:
Sequence
NucleicAcidsReplication

Definition at line 148 of file StringSequenceTools.cpp.

string StringSequenceTools::decodeSequence ( const std::vector< int > &  sequence,
const Alphabet alphabet 
) throw (BadIntException) [static]

Convert a sequence to its string representation.

Parameters:
sequenceThe sequence object to convert.
alphabetThe alphabet to use to decode the sequence.
Returns:
A string representation of the sequence.
Exceptions:
BarIntExceptionIf some value does not match the specified alphabet.

Definition at line 290 of file StringSequenceTools.cpp.

Referenced by bpp::BasicSymbolList::toString(), and bpp::EdSymbolList::toString().

string StringSequenceTools::deleteChar ( const std::string &  sequence,
char  chars 
) [static]

Delete all occurence of a character in the sequence.

Parameters:
sequenceThe sequence to parse.
charsThe character to remove.
Returns:
The sequence with all specified characters removed.

Definition at line 92 of file StringSequenceTools.cpp.

string StringSequenceTools::deleteChar ( const std::string &  sequence,
std::string  chars 
) [static]

Delete all occurence of several characters in the sequence.

Parameters:
sequenceThe sequence to parse.
charsThe characters to remove.
Returns:
The sequence with all specified characters removed.

Definition at line 109 of file StringSequenceTools.cpp.

Parse a sequence and try to guess the correct alphabet to use.

Parameters:
sequenceThe sequence to parse.
Returns:
A pointer toward a new Alphabet object.
Exceptions:
EmptySequenceExceptionif the sequence is empty.
SequenceExceptionif their is an ambiguity between several alphabet.
AlphabetExceptionif the sequence does not match any alphabet.

Definition at line 302 of file StringSequenceTools.cpp.

References bpp::AlphabetTools::getType().

double StringSequenceTools::getGCcontent ( const std::string &  sequence,
size_t  pos,
size_t  window 
) throw (BadIntegerException, Exception) [static]

Calculate the local GC content of a sequence.

GC contents are calculated using a window of specified size around the given position. Note : Calculus for last nucleotides (sequence's size - window size) will return the last possible rate calculated.

Parameters:
sequenceThe sequence to analyse.
posThe position where to compute the GC content.
windowThe size of the window to use.
Returns:
The GC content as a ratio (# of GC / window).
Exceptions:
BadIntExceptionIf the sequence is not of type DNA or RNA.
ExceptionError in calculus (if the sequence contain gaps for instance).

Definition at line 194 of file StringSequenceTools.cpp.

string * StringSequenceTools::reverse ( const std::string &  sequence) [static]

Reverse the sequence.

Parameters:
sequenceThe sequence to reverse.
Returns:
The reversed sequence.

Definition at line 130 of file StringSequenceTools.cpp.

string StringSequenceTools::setToSizeL ( const std::string &  sequence,
int  size 
) [static]

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:
sequenceThe input sequence.
sizeThe new size of the sequence.

Definition at line 85 of file StringSequenceTools.cpp.

References bpp::TextTools::resizeLeft().

string StringSequenceTools::setToSizeR ( const std::string &  sequence,
int  size 
) [static]

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:
sequenceThe input sequence.
sizeThe new size of the sequence.

Definition at line 80 of file StringSequenceTools.cpp.

References bpp::TextTools::resizeRight().

string StringSequenceTools::subseq ( const std::string &  sequence,
int  begin,
int  end 
) throw (Exception) [static]

Get a subsequence.

Parameters:
sequenceThe input sequence.
beginThe begining position (included).
endThe ending position (included).
Returns:
A string with the subsequence.
Exceptions:
ExceptionIf position does not not match the interval [0, length].

Definition at line 61 of file StringSequenceTools.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends