bpp-seq  2.2.0
AAMassIndex.h
Go to the documentation of this file.
1 //
2 // File: AAMassIndex.h
3 // Created by: Bastien Boussau
4 // Created on: Fri Jan 14 10:31 2011
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 _AAMASSINDEX_H_
41 #define _AAMASSINDEX_H_
42 
43 #include "AlphabetIndex1.h"
44 #include "../Alphabet/ProteicAlphabet.h"
45 #include "../Alphabet/AlphabetTools.h"
46 
47 namespace bpp
48 {
52 class AAMassIndex :
53  public AlphabetIndex1
54 {
55 private:
56  std::vector<double> mass_;
57 
58 public:
60  mass_()
61  {
62  mass_.resize(20);
63  mass_[ 0] = 71.09; // A
64  mass_[ 1] = 156.19; // R
65  mass_[ 2] = 114.11; // N
66  mass_[ 3] = 115.09; // D
67  mass_[ 4] = 103.15; // C
68  mass_[ 5] = 128.14; // Q
69  mass_[ 6] = 129.12; // E
70  mass_[ 7] = 57.05; // G
71  mass_[ 8] = 137.14; // H
72  mass_[ 9] = 113.16; // I
73  mass_[10] = 113.16; // L
74  mass_[11] = 128.17; // K
75  mass_[12] = 131.19; // M
76  mass_[13] = 147.18; // F
77  mass_[14] = 97.12; // P
78  mass_[15] = 87.08; // S
79  mass_[16] = 101.11; // T
80  mass_[17] = 186.12; // W
81  mass_[18] = 163.18; // Y
82  mass_[19] = 99.14; // V
83  }
84 
85  virtual ~AAMassIndex() {}
86 
87  AAMassIndex* clone() const { return new AAMassIndex(); }
88 
89 public:
90  double getIndex(int state) const throw (BadIntException)
91  {
92  if (state < 0 || state > 19) throw BadIntException(state, "AAMassIndex::getIndex(). Invalid state.", &AlphabetTools::PROTEIN_ALPHABET);
93  return mass_[static_cast<size_t>(state)];
94  }
95 
96  double getIndex(const std::string& state) const throw (BadCharException)
97  {
98  return mass_[static_cast<size_t>(AlphabetTools::PROTEIN_ALPHABET.charToInt(state))];
99  }
100 
101  std::vector<double>* getIndexVector() const { return new std::vector<double>(mass_); }
102 
104 };
105 } // end of namespace bpp.
106 
107 #endif // _AAMASSINDEX_H_
108 
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
Mass (dalton) of each amino acid, according to http://www.imb-jena.de/IMAGE_AA.html.
Definition: AAMassIndex.h:52
AAMassIndex * clone() const
Definition: AAMassIndex.h:87
One dimensionnal alphabet index interface.
double getIndex(int state) const
Get the index associated to a state.
Definition: AAMassIndex.h:90
const Alphabet * getAlphabet() const
Get the alphabet associated to this index.
Definition: AAMassIndex.h:103
std::vector< double > * getIndexVector() const
Definition: AAMassIndex.h:101
virtual ~AAMassIndex()
Definition: AAMassIndex.h:85
An alphabet exception thrown when trying to specify a bad int to the alphabet.
std::vector< double > mass_
Definition: AAMassIndex.h:56
static const ProteicAlphabet PROTEIN_ALPHABET
Definition: AlphabetTools.h:64
double getIndex(const std::string &state) const
Get the index associated to a state.
Definition: AAMassIndex.h:96
int charToInt(const std::string &state) const
Give the int description of a state given its string description.