SLIKMC  1.0
 All Classes Functions Variables Pages
Rotamer.h
1 /*
2  * Rotamer.h
3  *
4  * Created on: Jan 24, 2013
5  * Author: Yajia
6  */
7 
8 #ifndef ROTAMER_H_
9 #define ROTAMER_H_
10 #include <vector>
11 #include <string.h>
12 #include <iostream>
13 #include <map>
14 #include <PProtein.h>
15 using namespace std;
16 
17 class ChiDistribution;
18 class RotamerGrid;
19 class RotamerGridSpecial;
20 class RotamerGridKey;
21 class Rotamer;
22 
27  bool operator()(RotamerGridKey lhv, RotamerGridKey rhv) const;
28 };
29 
30 typedef map<RotamerGridKey, RotamerGrid, RotamerGridKeyComparator> GridMap;
31 typedef map<RotamerGridKey, RotamerGridSpecial, RotamerGridKeyComparator> GridMapSpecial;
32 typedef map<RotamerGridKey, RotamerGrid, RotamerGridKeyComparator>::iterator GridMapIter;
33 typedef map<RotamerGridKey, RotamerGridSpecial, RotamerGridKeyComparator>::iterator GridMapIterSpecial;
34 
39 public:
40  double prob;
41  vector< double> means;
42  vector< double> stds;
43 };
44 
49  friend class Rotamer;
50 public:
51  //number of effective chi angles
52  int n_chi;
53  vector<double> acc_rotamer;
54  //accumulated distribution for each rotamer
55  vector<ChiDistribution> dist_rotamer;
56 };
57 
62  friend class Rotamer;
63 public:
64  int degree_begin;
65  int degree_end;
66  int stepLength;
67  bool check() const;
68  vector<double> dist_terminal;
69  vector< vector<double> > acc_terminal;
70  vector< vector<double> > chi_terminal;
71 };
72 
77  friend class Rotamer;
78  friend struct RotamerGridKeyComparator;
79 public:
86  RotamerGridKey( const string& name, const int& phi, const int& psi);
87 
92  string toString() const;
93 
97  void print() const;
98 
104  bool operator==(const RotamerGridKey& key) const;
105 private:
106  string name;
107  int phi;
108  int psi;
109 };
110 
115 class Rotamer {
116 public:
121  Rotamer(PProtein* protein);
122 
131  void sample( const string& residue_name, const double& phi, const double& psi, int& rotamer_grid, vector<double>& dAngles);
132 
141  void sample_common( const string& residue_name, const int& phi, const int& psi, int& rotamer_grid, vector<double>& dAngles);
142 
151  void sample_Special( const string& residue_name, const int& phi, const int& psi, int& rotamer_grid, vector<double>& dAngles);
152 
157  void output( char* filename);
158 
159  //Evaluate the conformation of sidechain and return log(prob);
167  double evalSidechain_log(PChain* chain, const int s, const int e);
168 // double evalResidue(const string& residue_name, const double& phi, const double& psi, const int& rotamer_index, const vector<double>& angles);
169 
174  void initSidechainDatabase( PProtein* protein);
175 private:
176  void init();
181  void read( const string& res_name);
182 
187  void read_common( const string& res_name);
188 
193  void read_special( const string& res_name);
194 
195  GridMap gridMap;
196  GridMapSpecial gridMapSpecial;
197 
198  //For special amino acids.
199  vector<int> degree_start;
200  vector<int> degree_end;
201  vector<int> stepLength;
202 
203  static const int ASN = 0;
204  static const int ASP = 1;
205  static const int PHE = 2;
206  static const int TRP = 3;
207  static const int HIS = 4;
208  static const int TYR = 5;
209  static const int GLN = 6;
210  static const int GLU = 7;
211 
216  int type( const string& res_name);
217 
223  bool isSpecial( const string& res_name);
224  map<string, int> typeMap;
225 };
226 
227 #endif /* ROTAMER_H_ */