bpp-seq  2.2.0
KleinAANetChargeIndex.h
Go to the documentation of this file.
1 //
2 // File: KleinAANetChargeIndex.h
3 // Created by: Julien Dutheil
4 // Created on: Wed Aug 31 17:48 2005
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 _KLEINAANETCHARGEINDEX_H_
41 #define _KLEINAANETCHARGEINDEX_H_
42 
43 #include "AlphabetIndex1.h"
44 #include "../Alphabet/ProteicAlphabet.h"
45 
46 namespace bpp
47 {
70  public AlphabetIndex1
71 {
72 private:
73  std::vector<double> charge_;
74 
75 public:
77  {
78  charge_.resize(20);
79  charge_[ 0] = 0.; // A
80  charge_[ 1] = 1.; // R
81  charge_[ 2] = 0.; // N
82  charge_[ 3] = -1.; // D
83  charge_[ 4] = 0.; // C
84  charge_[ 5] = 0.; // Q
85  charge_[ 6] = -1.; // E
86  charge_[ 7] = 0.; // G
87  charge_[ 8] = 0.; // H
88  charge_[ 9] = 0.; // I
89  charge_[10] = 0.; // L
90  charge_[11] = 1.; // K
91  charge_[12] = 0.; // M
92  charge_[13] = 0.; // F
93  charge_[14] = 0.; // P
94  charge_[15] = 0.; // S
95  charge_[16] = 0.; // T
96  charge_[17] = 0.; // W
97  charge_[18] = 0.; // Y
98  charge_[19] = 0.; // V
99  }
100 
102 
104 
105 public:
106  double getIndex(int state) const throw (BadIntException)
107  {
108  if (state < 0 || state > 19) throw BadIntException(state, "KleinAANetChargeIndex::getIndex(). Invalid state.", &AlphabetTools::PROTEIN_ALPHABET);
109  return charge_[static_cast<size_t>(state)];
110  }
111 
112  double getIndex(const std::string& state) const throw (BadCharException)
113  {
114  return charge_[static_cast<size_t>(AlphabetTools::PROTEIN_ALPHABET.charToInt(state))];
115  }
116 
117  std::vector<double>* getIndexVector() const { return new std::vector<double>(charge_); }
118 
120 };
121 } // end of namespace bpp.
122 
123 #endif // _KLEINAANETCHARGEINDEX_H_
124 
An alphabet exception thrown when trying to specify a bad char to the alphabet.
This alphabet is used to deal NumericAlphabet.
double getIndex(const std::string &state) const
Get the index associated to a state.
The Alphabet interface.
Definition: Alphabet.h:130
Charge of each amino acid.
std::vector< double > * getIndexVector() const
One dimensionnal alphabet index interface.
KleinAANetChargeIndex * clone() const
double getIndex(int state) const
Get the index associated to a state.
const Alphabet * getAlphabet() const
Get the alphabet associated to this index.
std::vector< double > charge_
An alphabet exception thrown when trying to specify a bad int to the alphabet.
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.