bpp-seq  2.2.0
StringSequenceTools.h
Go to the documentation of this file.
1 //
2 // File: StringSequenceTools.h
3 // Created by: Julien Dutheil
4 // Created on: Sun Nov 30 11:29:07 2003
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _STRINGSEQUENCETOOLS_H_
41 #define _STRINGSEQUENCETOOLS_H_
42 
43 #include "Alphabet/Alphabet.h"
45 #include "SequenceExceptions.h"
46 #include <Bpp/Exceptions.h>
47 
48 // From the STL:
49 #include <string>
50 #include <vector>
51 
52 namespace bpp
53 {
54 
67 {
68  public:
71 
72  public:
73 
83  static std::string subseq(const std::string& sequence, size_t begin, size_t end) throw (Exception);
84 
94  static std::string setToSizeR(const std::string& sequence, size_t size);
95 
105  static std::string setToSizeL(const std::string& sequence, size_t size);
106 
114  static std::string deleteChar(const std::string& sequence, char chars);
115 
123  static std::string deleteChar(const std::string& sequence, std::string chars);
124 
131  static std::string* reverse(const std::string& sequence);
132 
144  static std::string* complement(const std::string& sequence);
145 
160  static double getGCcontent(const std::string& sequence, size_t pos, size_t window) throw (BadIntegerException, Exception);
161 
176  static std::vector<int> codeSequence(const std::string& sequence, const Alphabet* alphabet) throw (BadCharException);
177 
186  static std::string decodeSequence(const std::vector<int>& sequence, const Alphabet* alphabet) throw (BadIntException);
187 
197  static Alphabet* getAlphabetFromSequence(const std::string& sequence) throw (EmptySequenceException, SequenceException, AlphabetException);
198 
199 };
200 
201 } //end of namespace bpp.
202 
203 #endif //_STRINGSEQUENCETOOLS_H
204 
An alphabet exception thrown when trying to specify a bad char to the alphabet.
static std::string * reverse(const std::string &sequence)
Reverse the sequence.
This alphabet is used to deal NumericAlphabet.
The Alphabet interface.
Definition: Alphabet.h:130
static Alphabet * getAlphabetFromSequence(const std::string &sequence)
Parse a sequence and try to guess the correct alphabet to use.
static std::string decodeSequence(const std::vector< int > &sequence, const Alphabet *alphabet)
Convert a sequence to its string representation.
static std::string setToSizeR(const std::string &sequence, size_t size)
Set up the size of a sequence from the right side.
static std::vector< int > codeSequence(const std::string &sequence, const Alphabet *alphabet)
Convert a string sequence to a vector of int.
static double getGCcontent(const std::string &sequence, size_t pos, size_t window)
Calculate the local GC content of a sequence.
static std::string setToSizeL(const std::string &sequence, size_t size)
Set up the size of a sequence from the left side.
Utilitary methods working on raw string objects.
static std::string deleteChar(const std::string &sequence, char chars)
Delete all occurence of a character in the sequence.
The alphabet exception base class.
The sequence exception base class.
static std::string subseq(const std::string &sequence, size_t begin, size_t end)
Get a subsequence.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
static std::string * complement(const std::string &sequence)
Get the complement of a sequence.
Exception thrown when a sequence is found to be empty and it should not.