bpp-seq3  3.0.0
ProteicAlphabet.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_PROTEICALPHABET_H
6 #define BPP_SEQ_ALPHABET_PROTEICALPHABET_H
7 
8 
9 #include "LetterAlphabet.h"
10 #include "ProteicAlphabetState.h"
11 
12 namespace bpp
13 {
23  public LetterAlphabet
24 {
30 public:
31  const ProteicAlphabetState& getState(const std::string& letter) const
32  {
33  return dynamic_cast<const ProteicAlphabetState&>(
35  );
36  }
37 
38  const ProteicAlphabetState& getState(int num) const
39  {
40  return dynamic_cast<const ProteicAlphabetState&>(
42  );
43  }
44 
45 protected:
46  const ProteicAlphabetState& getStateAt(size_t pos) const
47  {
48  return dynamic_cast<const ProteicAlphabetState&>(
50  );
51  }
52 
54  {
55  return dynamic_cast<ProteicAlphabetState&>(
57  );
58  }
59 
62 public:
64 
66 
68  {
70  return *this;
71  }
72 
74  {
75  return new ProteicAlphabet(*this);
76  }
77 
78 
79  virtual ~ProteicAlphabet() {}
80 
81 public:
82  unsigned int getSize() const { return 20; }
83  unsigned int getNumberOfTypes() const { return 24; }
84  int getUnknownCharacterCode() const { return 23; }
85  bool isResolvedIn(int state1, int state2) const;
86  std::vector<int> getAlias(int state) const;
87  std::vector<std::string> getAlias(const std::string& state) const;
88  int getGeneric(const std::vector<int>& states) const;
89  std::string getGeneric(const std::vector<std::string>& states) const;
90  bool isUnresolved(int state) const { return state > 19; }
91  bool isUnresolved(const std::string& state) const { return charToInt(state) > 19; }
92  std::string getAlphabetType() const { return "Proteic"; }
93 
94 public:
106  std::string getAbbr(const std::string& aa) const;
107 
113  std::string getAbbr(int aa) const;
115 };
116 } // end of namespace bpp.
117 #endif // BPP_SEQ_ALPHABET_PROTEICALPHABET_H
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
const AlphabetState & getState(const std::string &letter) const
Get a state by its letter.
Specialized partial implementation of Alphabet using single letters.
LetterAlphabet & operator=(const LetterAlphabet &bia)
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
This is the base class to describe states in a ProteicAlphabet.
This alphabet is used to deal with proteins.
ProteicAlphabet(const ProteicAlphabet &bia)
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
int getUnknownCharacterCode() const
const ProteicAlphabetState & getStateAt(size_t pos) const
Get a state at a position in the alphabet_ vector.
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...
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
bool isResolvedIn(int state1, int state2) const
Tells if a given (potentially unresolved) state can be resolved in another resolved state.
ProteicAlphabet * clone() const
const ProteicAlphabetState & getState(int num) const
Get a state by its num.
std::string getAbbr(const std::string &aa) const
Get the abbreviation (3 letter code) for a state coded as char.
std::string getAlphabetType() const
Identification method.
ProteicAlphabet & operator=(const ProteicAlphabet &bia)
const ProteicAlphabetState & getState(const std::string &letter) const
Get a state by its letter.
bool isUnresolved(const std::string &state) const
ProteicAlphabetState & getStateAt(size_t pos)
Get a state at a position in the alphabet_ vector.
unsigned int getSize() const
Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet)....
This alphabet is used to deal NumericAlphabet.