bpp-seq  2.2.0
AAChargeIndex.h
Go to the documentation of this file.
1 //
2 // File: AAChargeIndex.h
3 // Created by: Julien Dutheil
4 // Created on: Tue May 02 13:34 2006
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for sequences analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38  */
39 
40 #ifndef _AACHARGEINDEX_H_
41 #define _AACHARGEINDEX_H_
42 
43 #include "AlphabetIndex1.h"
44 #include "../Alphabet/ProteicAlphabet.h"
45 #include "../Alphabet/AlphabetTools.h"
46 
47 namespace bpp
48 {
96  public AlphabetIndex1
97 {
98 private:
99  std::vector<double> charge_;
100 
101 public:
103  charge_()
104  {
105  charge_.resize(20);
106  charge_[ 0] = 0.; // A
107  charge_[ 1] = 1.; // R
108  charge_[ 2] = 0.; // N
109  charge_[ 3] = -1.; // D
110  charge_[ 4] = 0.; // C
111  charge_[ 5] = 0.; // Q
112  charge_[ 6] = -1.; // E
113  charge_[ 7] = 0.; // G
114  charge_[ 8] = 1.; // H
115  charge_[ 9] = 0.; // I
116  charge_[10] = 0.; // L
117  charge_[11] = 1.; // K
118  charge_[12] = 0.; // M
119  charge_[13] = 0.; // F
120  charge_[14] = 0.; // P
121  charge_[15] = 0.; // S
122  charge_[16] = 0.; // T
123  charge_[17] = 0.; // W
124  charge_[18] = 0.; // Y
125  charge_[19] = 0.; // V
126  }
127 
128  virtual ~AAChargeIndex() {}
129 
130  AAChargeIndex* clone() const { return new AAChargeIndex(); }
131 
132 public:
133  double getIndex(int state) const throw (BadIntException)
134  {
135  if (state < 0 || state > 19) throw BadIntException(state, "AAChargeIndex::getIndex(). Invalid state.", &AlphabetTools::PROTEIN_ALPHABET);
136  return charge_[static_cast<size_t>(state)];
137  }
138 
139  double getIndex(const std::string& state) const throw (BadCharException)
140  {
141  return charge_[static_cast<size_t>(AlphabetTools::PROTEIN_ALPHABET.charToInt(state))];
142  }
143 
144  std::vector<double>* getIndexVector() const { return new std::vector<double>(charge_); }
145 
147 };
148 } // end of namespace bpp.
149 
150 #endif // _AACHARGEINDEX_H_
151 
An alphabet exception thrown when trying to specify a bad char to the alphabet.
const Alphabet * getAlphabet() const
Get the alphabet associated to this index.
AAChargeIndex * clone() const
This alphabet is used to deal NumericAlphabet.
The Alphabet interface.
Definition: Alphabet.h:130
virtual ~AAChargeIndex()
One dimensionnal alphabet index interface.
Charge of each amino acid.
Definition: AAChargeIndex.h:95
std::vector< double > charge_
Definition: AAChargeIndex.h:99
std::vector< double > * getIndexVector() const
double getIndex(const std::string &state) const
Get the index associated to a state.
An alphabet exception thrown when trying to specify a bad int to the alphabet.
double getIndex(int state) const
Get the index associated to a state.
static const ProteicAlphabet PROTEIN_ALPHABET
Definition: AlphabetTools.h:64
int charToInt(const std::string &state) const
Give the int description of a state given its string description.