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