|
bpp-seq
2.1.0
|
Utilitary methods working on raw string objects. More...
#include <Bpp/Seq/StringSequenceTools.h>
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 Alphabet * | getAlphabetFromSequence (const std::string &sequence) throw (EmptySequenceException, SequenceException, AlphabetException) |
| Parse a sequence and try to guess the correct alphabet to use. | |
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.
Definition at line 66 of file StringSequenceTools.h.
| bpp::StringSequenceTools::StringSequenceTools | ( | ) | [inline] |
Definition at line 69 of file StringSequenceTools.h.
| bpp::StringSequenceTools::~StringSequenceTools | ( | ) | [inline] |
Definition at line 70 of file StringSequenceTools.h.
| 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.
| sequence | The sequence to parse. |
| alphabet | The alphabet to use to code the sequence. |
| BarCharException | If 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.
For this method, sequence is supposed to be of type DNA.
| sequence | The sequence to complement. |
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.
| sequence | The sequence object to convert. |
| alphabet | The alphabet to use to decode the sequence. |
| BarIntException | If 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.
| sequence | The sequence to parse. |
| chars | The character to remove. |
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.
| sequence | The sequence to parse. |
| chars | The characters to remove. |
Definition at line 109 of file StringSequenceTools.cpp.
| Alphabet * StringSequenceTools::getAlphabetFromSequence | ( | const std::string & | sequence | ) | throw (EmptySequenceException, SequenceException, AlphabetException) [static] |
Parse a sequence and try to guess the correct alphabet to use.
| sequence | The sequence to parse. |
| EmptySequenceException | if the sequence is empty. |
| SequenceException | if their is an ambiguity between several alphabet. |
| AlphabetException | if 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.
| sequence | The sequence to analyse. |
| pos | The position where to compute the GC content. |
| window | The size of the window to use. |
| BadIntException | If the sequence is not of type DNA or RNA. |
| Exception | Error 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.
| sequence | The sequence to reverse. |
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.
| sequence | The input sequence. |
| size | The 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.
| sequence | The input sequence. |
| size | The 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.
| sequence | The input sequence. |
| begin | The begining position (included). |
| end | The ending position (included). |
| Exception | If position does not not match the interval [0, length]. |
Definition at line 61 of file StringSequenceTools.cpp.