bpp-seq3  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 
9 #include <string>
10 
11 #include "AbstractAlphabet.h"
12 #include "AlphabetNumericState.h"
13 
19 namespace bpp
20 {
22 {
23 private:
25 
26  std::map<double, size_t> values_;
27 
28 public:
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
A partial implementation of the Alphabet interface.
States that do have a double value.
This is the base class to describe states in an Alphabet.
Definition: AlphabetState.h:22
double intToValue(int state) const
Returns the value for the character number.
NumericAlphabet & operator=(const NumericAlphabet &)
double getDelta() const
Returns the difference between successive values.
std::string getAlphabetType() const
Identification method.
bool containsGap(const std::string &state) const
unsigned int getSize() const
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
const UniformDiscreteDistribution * pdd_
AlphabetNumericState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
std::map< double, size_t > values_
void setState(size_t pos, AlphabetState *st)
Set a state in the Alphabet.
NumericAlphabet * clone() const
int getUnknownCharacterCode() const
void registerState(AlphabetState *st)
Add a state to the Alphabet.
void remap()
Re-update the maps.
bool isUnresolved(int state) const
size_t getValueIndex(double value) const
Returns the CategoryIndex of the category to which the value belongs.
unsigned int getNumberOfTypes() const
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
NumericAlphabet(const UniformDiscreteDistribution &)
bool isGap(int state) const
This alphabet is used to deal NumericAlphabet.