bpp-core3  3.0.0
NumericAlphabet.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_ALPHABET_NUMERICALPHABET_H
6 #define BPP_SEQ_ALPHABET_NUMERICALPHABET_H
7 
8 #include <Bpp/Numeric/Prob/UniformDiscreteDistribution.h>
9 #include <string>
10 
11 #include "AbstractAlphabet.h"
12 #include "AlphabetNumericState.h"
13 
19 namespace bpp
20 {
22 {
23 private:
24  const UniformDiscreteDistribution* pdd_;
25 
26  std::map<double, size_t> values_;
27 
28 public:
29  NumericAlphabet(const UniformDiscreteDistribution&);
30 
31  virtual ~NumericAlphabet() { delete pdd_;}
32 
34 
36 
38  {
39  return new NumericAlphabet(*this);
40  }
41 
42 public:
43  void setState(size_t pos, AlphabetState* st);
44  void registerState(AlphabetState* st);
45 
46  bool containsGap(const std::string& state) const;
47 
48  unsigned int getSize() const;
49  unsigned int getNumberOfTypes() const;
50  int getUnknownCharacterCode() const { return -1; }
51  bool isGap(int state) const;
52  std::vector<int> getAlias(int state) const;
53  std::vector<std::string> getAlias(const std::string& state) const;
54  bool isUnresolved(int state) const;
55  bool isUnresolved(const std::string& state) const;
56 
57  std::string getAlphabetType() const { return "Numeric"; }
58 
59  AlphabetNumericState& getStateAt(size_t stateIndex);
60  const AlphabetNumericState& getStateAt(size_t stateIndex) const;
61 
71  double getDelta() const;
72 
77  double intToValue(int state) const;
78 
83  size_t getValueIndex(double value) const;
84 
88  void remap();
89 };
90 }
91 #endif // BPP_SEQ_ALPHABET_NUMERICALPHABET_H
This is the base class to describe states in an Alphabet.
Definition: AlphabetState.h:21
bool isUnresolved(int state) const
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.
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.