bpp-seq  2.2.0
ProteicAlphabet.h
Go to the documentation of this file.
1 //
2 // File: ProteicAlphabet.h
3 // Authors: Guillaume Deuchst
4 // Julien Dutheil
5 // Sylvain Gaillard
6 // Created on: Tue Jul 22 2003
7 //
8 
9 /*
10  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
11 
12  This software is a computer program whose purpose is to provide classes
13  for sequences analysis.
14 
15  This software is governed by the CeCILL license under French law and
16  abiding by the rules of distribution of free software. You can use,
17  modify and/ or redistribute the software under the terms of the CeCILL
18  license as circulated by CEA, CNRS and INRIA at the following URL
19  "http://www.cecill.info".
20 
21  As a counterpart to the access to the source code and rights to copy,
22  modify and redistribute granted by the license, users are provided only
23  with a limited warranty and the software's author, the holder of the
24  economic rights, and the successive licensors have only limited
25  liability.
26 
27  In this respect, the user's attention is drawn to the risks associated
28  with loading, using, modifying and/or developing or reproducing the
29  software by the user in light of its specific status of free software,
30  that may mean that it is complicated to manipulate, and that also
31  therefore means that it is reserved for developers and experienced
32  professionals having in-depth computer knowledge. Users are therefore
33  encouraged to load and test the software's suitability as regards their
34  requirements in conditions enabling the security of their systems and/or
35  data to be ensured and, more generally, to use and operate it in the
36  same conditions as regards security.
37 
38  The fact that you are presently reading this means that you have had
39  knowledge of the CeCILL license and that you accept its terms.
40 */
41 
42 
43 #ifndef _PROTEICALPHABET_H_
44 #define _PROTEICALPHABET_H_
45 
46 #include "LetterAlphabet.h"
47 #include "ProteicAlphabetState.h"
48 
49 namespace bpp
50 {
51 
60  public LetterAlphabet
61  {
66  public:
67  const ProteicAlphabetState& getState(const std::string& letter) const
68  throw (BadCharException)
69  {
70  return dynamic_cast<const ProteicAlphabetState&>(
72  );
73  }
74 
75  const ProteicAlphabetState& getState(int num) const
76  throw (BadIntException)
77  {
78  return dynamic_cast<const ProteicAlphabetState&>(
80  );
81  }
82 
83  protected:
84 
85  const ProteicAlphabetState& getStateAt(size_t pos) const
86  throw (IndexOutOfBoundsException)
87  {
88  return dynamic_cast<const ProteicAlphabetState&>(
90  );
91  }
92 
94  throw (IndexOutOfBoundsException)
95  {
96  return dynamic_cast<ProteicAlphabetState&>(
98  );
99  }
100 
102  public:
103  ProteicAlphabet();
104 
106 
108  {
110  return *this;
111  }
112 
114  {
115  return new ProteicAlphabet(*this);
116  }
117 
118 
119  virtual ~ProteicAlphabet() {}
120 
121 
122  public:
123  unsigned int getSize() const { return 20; }
124  unsigned int getNumberOfTypes() const { return 23; }
125  int getUnknownCharacterCode() const { return 22; }
126  std::vector<int> getAlias(int state) const throw (BadIntException);
127  std::vector<std::string> getAlias(const std::string& state) const throw (BadCharException);
128  int getGeneric(const std::vector<int>& states) const throw (BadIntException);
129  std::string getGeneric(const std::vector<std::string>& states) const throw (BadCharException);
130  bool isUnresolved(int state) const { return state > 19; }
131  bool isUnresolved(const std::string& state) const { return charToInt(state) > 19; }
132  std::string getAlphabetType() const { return "Proteic alphabet"; }
133 
134  public:
135 
147  std::string getAbbr(const std::string & aa) const throw (AlphabetException);
148 
154  std::string getAbbr(int aa) const throw (AlphabetException);
157  };
158 
159 } //end of namespace bpp.
160 
161 #endif // _PROTEICALPHABET_H_
162 
LetterAlphabet & operator=(const LetterAlphabet &bia)
const ProteicAlphabetState & getState(const std::string &letter) const
Get a state by its letter.
An alphabet exception thrown when trying to specify a bad char to the alphabet.
std::vector< int > getAlias(int state) const
Get all resolved states that match a generic state.
bool isUnresolved(int state) const
This alphabet is used to deal NumericAlphabet.
const ProteicAlphabetState & getStateAt(size_t pos) const
Get a state at a position in the alphabet_ vector.
ProteicAlphabet * clone() const
int getGeneric(const std::vector< int > &states) const
Get the generic state that match a set of states.
ProteicAlphabetState & getStateAt(size_t pos)
Get a state at a position in the alphabet_ vector.
ProteicAlphabet & operator=(const ProteicAlphabet &bia)
Specialized partial implementation of Alphabet using single letters.
const AlphabetState & getState(const std::string &letter) const
Get a state by its letter.
std::string getAlphabetType() const
Identification method.
This alphabet is used to deal with proteins.
std::string getAbbr(const std::string &aa) const
Get the abbreviation (3 letter code) for a state coded as char.
This is the base class to describe states in a ProteicAlphabet.
unsigned int getNumberOfTypes() const
Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number o...
const ProteicAlphabetState & getState(int num) const
Get a state by its num.
The alphabet exception base class.
int getUnknownCharacterCode() const
bool isUnresolved(const std::string &state) const
An alphabet exception thrown when trying to specify a bad int to the alphabet.
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.
virtual AlphabetState & getStateAt(size_t stateIndex)
Get a state at a position in the alphabet_ vector.
int charToInt(const std::string &state) const
Give the int description of a state given its string description.
ProteicAlphabet(const ProteicAlphabet &bia)