bpp-seq  2.2.0
NumericAlphabet.h
Go to the documentation of this file.
1 //
2 // File: NumericAlphabet.h
3 // Created by: Laurent Gueguen
4 // Created on: March 2010
5 //
6 
7 /*
8  Copyright 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
21  only with a limited warranty and the software's author, the holder of
22  the 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
32  their requirements in conditions enabling the security of their
33  systems and/or data to be ensured and, more generally, to use and
34  operate it in the 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 
41 #ifndef _NUMERICALPHABET_H_
42 #define _NUMERICALPHABET_H_
43 
44 #include "AbstractAlphabet.h"
45 #include "AlphabetNumericState.h"
46 
47 #include <Bpp/Numeric/Prob/UniformDiscreteDistribution.h>
48 
49 #include <string>
50 
56 namespace bpp
57 {
59  {
60  private:
61  const UniformDiscreteDistribution* pdd_;
62 
63  std::map<double, size_t> values_;
64 
65  public:
66 
67  NumericAlphabet(const UniformDiscreteDistribution&);
68 
69  virtual ~NumericAlphabet() { delete pdd_;}
70 
72 
74 
76  {
77  return new NumericAlphabet(*this);
78  }
79 
80  public:
81  void setState(size_t pos, AlphabetState* st) throw (Exception);
82  void registerState(AlphabetState* st) throw (Exception);
83 
84  bool containsGap(const std::string& state) const throw (BadCharException);
85 
86  unsigned int getSize() const;
87  unsigned int getNumberOfTypes() const;
88  int getUnknownCharacterCode() const { return -1; }
89  bool isGap(int state) const;
90  std::vector<int> getAlias(int state) const throw (BadIntException);
91  std::vector<std::string> getAlias(const std::string& state) const throw (BadCharException);
92  bool isUnresolved(int state) const;
93  bool isUnresolved(const std::string& state) const;
94 
95  std::string getAlphabetType() const { return "Numeric alphabet"; }
96 
97  AlphabetNumericState& getStateAt(size_t stateIndex) throw (IndexOutOfBoundsException);
98  const AlphabetNumericState& getStateAt(size_t stateIndex) const throw (IndexOutOfBoundsException);
99 
109  double getDelta() const;
110 
115  double intToValue(int state) const throw (BadIntException);
116 
121  size_t getValueIndex(double value) const;
122 
126  void remap();
127 
128  };
129 }
130 #endif // _NUMERICALPHABET_H_
131 
This is the base class to describe states in an Alphabet.
Definition: AlphabetState.h:54
bool isUnresolved(int state) const
An alphabet exception thrown when trying to specify a bad char to the alphabet.
unsigned int getNumberOfTypes() const
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
bool isGap(int state) const
This alphabet is used to deal NumericAlphabet.
unsigned int getSize() const
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you&#39;ll need in most cases.
double intToValue(int state) const
Returns the value for the character number.
int getUnknownCharacterCode() const
std::map< double, size_t > values_
double getDelta() const
Returns the difference between successive values.
const UniformDiscreteDistribution * pdd_
bool containsGap(const std::string &state) const
void remap()
Re-update the maps.
NumericAlphabet & operator=(const NumericAlphabet &)
NumericAlphabet(const UniformDiscreteDistribution &)
void setState(size_t pos, AlphabetState *st)
Set a state in the Alphabet.
void registerState(AlphabetState *st)
Add a state to the Alphabet.
A partial implementation of the Alphabet interface.
NumericAlphabet * clone() const
AlphabetNumericState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
States that do have a double value.
std::string getAlphabetType() const
Identification method.
size_t getValueIndex(double value) const
Returns the CategoryIndex of the category to which the value belongs.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.