bpp-seq3  3.0.0
LexicalAlphabet.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_LEXICALALPHABET_H
6 #define BPP_SEQ_ALPHABET_LEXICALALPHABET_H
7 
8 
9 #include "AbstractAlphabet.h"
10 
11 // From the STL:
12 #include <string>
13 #include <vector>
14 
15 namespace bpp
16 {
22  public AbstractAlphabet
23 {
24 public:
25  // Constructor and destructor.
34  LexicalAlphabet(const std::vector<std::string>& vocab);
35 
37 
39  {
41  return *this;
42  }
43 
45  {
46  return new LexicalAlphabet(*this);
47  }
48 
49  virtual ~LexicalAlphabet() {}
50 
51 public:
57  unsigned int getSize() const
58  {
59  return getNumberOfChars() - 2;
60  }
61 
65  unsigned int getNumberOfTypes() const
66  {
67  return getNumberOfChars() - 1;
68  }
69 
70  std::string getAlphabetType() const;
71 
73  {
74  return static_cast<int>(getSize());
75  }
76 
77  bool isUnresolved(int state) const { return state == getUnknownCharacterCode(); }
78  bool isUnresolved(const std::string& state) const { return charToInt(state) == getUnknownCharacterCode(); }
79 };
80 } // end of namespace bpp.
81 #endif // BPP_SEQ_ALPHABET_LEXICALALPHABET_H
A partial implementation of the Alphabet interface.
unsigned int getNumberOfChars() const
Get the number of supported characters in this alphabet, including generic characters (e....
AbstractAlphabet & operator=(const AbstractAlphabet &alph)
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
Alphabet made of given words.
unsigned int getNumberOfTypes() const
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
int getUnknownCharacterCode() const
unsigned int getSize() const
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
bool isUnresolved(int state) const
bool isUnresolved(const std::string &state) const
LexicalAlphabet & operator=(const LexicalAlphabet &bia)
LexicalAlphabet(const LexicalAlphabet &bia)
std::string getAlphabetType() const
Identification method.
LexicalAlphabet(const std::vector< std::string > &vocab)
Builds a new word alphabet from a vector of given words.
LexicalAlphabet * clone() const
This alphabet is used to deal NumericAlphabet.