bpp-seq3  3.0.0
Alphabet.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_ALPHABET_H
6 #define BPP_SEQ_ALPHABET_ALPHABET_H
7 
8 #include <Bpp/Clonable.h>
9 #include <string>
10 #include <vector>
11 #include <memory>
12 
13 #include "AlphabetState.h"
14 
66 namespace bpp
67 {
68 #pragma GCC diagnostic push
69 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" // Disable warning coming from the STL because of std::enable_shared_from_this
96 class Alphabet :
97  public virtual Clonable,
98  public std::enable_shared_from_this<Alphabet>
99 {
100 public:
101  Alphabet() {}
102  virtual ~Alphabet() = default;
103 
109  Alphabet* clone() const = 0;
112 #pragma GCC diagnostic pop
113 
114 public:
125  virtual std::string getName(int state) const = 0;
126 
137  virtual std::string getName(const std::string& state) const = 0;
138 
143  virtual int getIntCodeAt(size_t stateIndex) const = 0;
144 
149  virtual const std::string& getCharCodeAt(size_t stateIndex) const = 0;
150 
154  virtual size_t getStateIndex(int state) const = 0;
155 
159  virtual size_t getStateIndex(const std::string& state) const = 0;
160 
174  virtual bool isIntInAlphabet(int state) const = 0;
175 
183  virtual bool isCharInAlphabet(const std::string& state) const = 0;
199  virtual const AlphabetState& getStateAt(size_t stateIndex) const = 0;
200 
210  virtual const AlphabetState& getState(int state) const = 0;
211 
219  virtual const AlphabetState& getState(const std::string& state) const = 0;
220 
236  virtual std::string intToChar(int state) const = 0;
237 
245  virtual int charToInt(const std::string& state) const = 0;
260  virtual size_t getNumberOfStates() const = 0;
261 
268  virtual unsigned int getNumberOfChars() const = 0;
269 
276  virtual unsigned int getNumberOfTypes() const = 0;
277 
284  virtual unsigned int getSize() const = 0;
285 
304  virtual bool isResolvedIn(int state1, int state2) const = 0;
305 
315  virtual std::vector<int> getAlias(int state) const = 0;
316 
326  virtual std::vector<std::string> getAlias(const std::string& state) const = 0;
327 
338  virtual int getGeneric(const std::vector<int>& states) const = 0;
339 
351  virtual std::string getGeneric(const std::vector<std::string>& states) const = 0;
352 
360  virtual const std::vector<int>& getSupportedInts() const = 0;
361 
369  virtual const std::vector<std::string>& getSupportedChars() const = 0;
370 
378  virtual const std::vector<std::string>& getResolvedChars() const = 0;
379 
383  virtual int getUnknownCharacterCode() const = 0;
384 
388  virtual int getGapCharacterCode() const = 0;
389 
394  virtual bool isGap(int state) const = 0;
395 
400  virtual bool isGap(const std::string& state) const = 0;
401 
406  virtual bool isUnresolved(int state) const = 0;
407 
412  virtual bool isUnresolved(const std::string& state) const = 0;
413 
425  virtual std::string getAlphabetType() const = 0;
426 
432  virtual unsigned int getStateCodingSize() const = 0;
433 
439  virtual bool equals(const Alphabet& alphabet) const = 0;
440 };
441 } // end of namespace bpp.
442 #endif // BPP_SEQ_ALPHABET_ALPHABET_H
This is the base class to describe states in an Alphabet.
Definition: AlphabetState.h:22
The Alphabet interface.
Definition: Alphabet.h:99
virtual unsigned int getNumberOfChars() const =0
Get the number of supported characters in this alphabet, including generic characters (e....
virtual bool isUnresolved(const std::string &state) const =0
virtual size_t getNumberOfStates() const =0
This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.
virtual const std::vector< std::string > & getResolvedChars() const =0
virtual std::string getAlphabetType() const =0
Identification method.
virtual const std::vector< int > & getSupportedInts() const =0
virtual bool isResolvedIn(int state1, int state2) const =0
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
virtual std::string getName(const std::string &state) const =0
Get the complete name of a state given its string description.
virtual std::vector< int > getAlias(int state) const =0
Get all resolved states that match a generic state.
virtual bool equals(const Alphabet &alphabet) const =0
Comparison of alphabets.
virtual std::string intToChar(int state) const =0
Give the string description of a state given its int description.
virtual std::string getName(int state) const =0
Get the complete name of a state given its int description.
virtual bool isUnresolved(int state) const =0
virtual int charToInt(const std::string &state) const =0
Give the int description of a state given its string description.
virtual bool isGap(int state) const =0
virtual const std::vector< std::string > & getSupportedChars() const =0
virtual std::vector< std::string > getAlias(const std::string &state) const =0
Get all resolved states that match a generic state.
virtual unsigned int getNumberOfTypes() const =0
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
virtual int getGapCharacterCode() const =0
virtual std::string getGeneric(const std::vector< std::string > &states) const =0
Get the generic state that match a set of states.
virtual bool isCharInAlphabet(const std::string &state) const =0
Tell if a state (specified by its string description) is allowed by the the alphabet.
virtual ~Alphabet()=default
virtual int getUnknownCharacterCode() const =0
virtual size_t getStateIndex(int state) const =0
virtual int getIntCodeAt(size_t stateIndex) const =0
virtual bool isIntInAlphabet(int state) const =0
Tell if a state (specified by its int description) is allowed by the the alphabet.
virtual int getGeneric(const std::vector< int > &states) const =0
Get the generic state that match a set of states.
virtual unsigned int getStateCodingSize() const =0
Get the size of the string coding a state.
virtual unsigned int getSize() const =0
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
virtual const std::string & getCharCodeAt(size_t stateIndex) const =0
virtual const AlphabetState & getState(int state) const =0
Get a state given its int description.
virtual size_t getStateIndex(const std::string &state) const =0
virtual const AlphabetState & getState(const std::string &state) const =0
Get a state given its string description.
virtual const AlphabetState & getStateAt(size_t stateIndex) const =0
Get a state given its index.
Alphabet * clone() const =0
virtual bool isGap(const std::string &state) const =0
This alphabet is used to deal NumericAlphabet.