BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
geometricFit.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_DOCKING_GEOMETRICFIT_H
6 #define BALL_DOCKING_GEOMETRICFIT_H
7 
8 #ifndef BALL_DATATYPE_REGULARDATA3D_H
10 #endif
11 
12 #ifndef BALL_KERNEL_SYSTEM_H
13 #include <BALL/KERNEL/system.h>
14 #endif
15 
16 #ifndef BALL_MATHS_COMPLEX_H
17 #include <BALL/MATHS/complex.h>
18 #endif
19 
20 #ifndef BALL_MATHS_FFT3D_H
21 #include <BALL/MATHS/FFT3D.h>
22 #endif
23 
24 #ifndef BALL_DOCKING_COMMON_DOCKINGALGORITHM_H
26 #endif
27 
28 namespace BALL
29 {
37  : public DockingAlgorithm
38  {
39  public:
41 
42 
48  {
49  // the parameter r,
50  // "Any grid point is considered inside the molecule if there is at
51  // least one atom nucleus within a distance r from it."
52  // Default value is 1.8 Angstrom
53  static const String NEAR_RADIUS;
54 
55  // Default grid spacing.
56  // Default value is 1.0 Angstrom
57  static const String GRID_SPACING;
58 
59  // grid size = (ceil)(molecule size / grid spacing);
60  static const String GRID_SIZE;
61 
62  // The thickness of the surface of the protein
63  // Default value is 1.0 Angstrom
64  static const String SURFACE_THICKNESS;
65 
66  // Degree interval is the delta parameter,
67  // which is the degrees that protein B rotates every time
68  // Default value is 20 degrees
69  static const String DEGREE_INTERVAL;
70 
71  // How many peaks should the program keep for each rotation
72  static const String TOP_N;
73 
80  static const String SURFACE_TYPE;
81 
82  // How many results should be kept in total (also in DockingAlgorithms)
83  static const String BEST_NUM;
84 
85  // Verbosity of the Algorithm (also in DockingAlgorithm)
86  static const String VERBOSITY;
87 
88  // Euler angels for redocking
89  static const String PHI_MIN;
90  static const String PHI_MAX;
91  static const String DEG_PHI;
92 
93  static const String THETA_MIN;
94  static const String THETA_MAX;
95  static const String DEG_THETA;
96 
97  static const String PSI_MIN;
98  static const String PSI_MAX;
99  static const String DEG_PSI;
100 
101  // penalty value of the inside points
102  // Default value for static protein is -15, for mobile protein 1
103  static const String PENALTY_STATIC;
104  static const String PENALTY_MOBILE;
105 
106  // Number of processes in total for a parallel run
108 
109  // Full path to the slave to spawn
110  static const String SLAVE_PATH;
111  };
112 
114  {
115  // Default parameter r,
116  // Default value is 1.8 Angstrom
117  static const float NEAR_RADIUS;
118 
119  // Default grid spacing.
120  // Default value is 1.0 Angstrom
121  static const float GRID_SPACING;
122 
123  // grid size = (ceil)(molecule size / grid spacing);
124  static const int GRID_SIZE;
125 
126  // Default thickness of the surface of the protein
127  // Default value is 1.0 Angstrom
128  static const float SURFACE_THICKNESS;
129 
130  // Degree interval is the delta parameter,
131  // which is the degrees that protein B rotates every time
132  // Default value is 20 degrees
133  static const double DEGREE_INTERVAL;
134 
138  static const int SURFACE_TYPE;
139 
140  // How many peaks should the program keep for each rotation
141  static const int TOP_N;
142 
143  // How many overall top best peaks should the program keep
144  // after doing all rotations.
145  static const int BEST_NUM;
146 
147  // Verbosity of the algorithm
148  // Default value is 0
149  // For values > 1, some information is printed on Log
150  // For values > 5, timing information is included
151  static const int VERBOSITY;
152 
153  // Euler angels for redocking
154  static const float PHI_MIN;
155  static const float PHI_MAX;
156  static const float DEG_PHI;
157 
158  static const float THETA_MIN;
159  static const float THETA_MAX;
160  static const float DEG_THETA;
161 
162  static const float PSI_MIN;
163  static const float PSI_MAX;
164  static const float DEG_PSI;
165 
166  // penalty value of the inside points
167  // Default value for static protein is -15, for mobile protein 1
168  static const int PENALTY_STATIC;
169  static const int PENALTY_MOBILE;
170 
171  // number of processes for a parallel run
172  static const int NUMBER_OF_PROCESSES;
173 
174  // Full path to the slave to spawn
175  static const String SLAVE_PATH;
176  };
177 
183  {
184  public:
185 
186  // constructor
187  Peak_();
188 
189  // destructor
190  ~Peak_();
191 
192  // Operator <
193  bool operator < (const Peak_& p) const;
194 
195  double value;
198  };
199 
203  {
204  public:
205 
206  // constructor
207  RotationAngles_();
208 
209  // constructor
210  RotationAngles_( int step );
211 
212  // destructor
214 
215  // generate all non-degenerate rotation angles.
216  // This algorithm is based on ???
217  bool generateSomeAngles( const float deg_phi, const float deg_psi, const float deg_theta,
218  const float phi_min, const float phi_max,
219  const float psi_min, const float psi_max,
220  const float theta_min, const float theta_max );
221 
222  // generate all non-degenerate rotation angles.
223  // This algorithm is based on ???
224  bool generateAllAngles( const int deg );
225 
227  {
228  return ang_num_;
229  }
230 
231  int getXAng( int n ) // get the euler angle rotate around x axis
232  {
233  return phi_[n];
234  }
235 
236  int getYAng( int n ) // get the euler angle rotate around y axis
237  {
238  return theta_[n];
239  }
240 
241  int getZAng( int n ) // get the euler angle rotate around z axis
242  {
243  return psi_[n];
244  }
245 
246  // TODO: This class is a bit strange...
247  vector<int> phi_;
248  vector<int> theta_;
249  vector<int> psi_;
250 
251  private:
252  int ang_num_;
253  int max_rotation_;
254  };
255 
256  // PROTEIN_A is the static protein, i.e., the bigger one;
257  // PROTEIN_B is the mobile protein, i.e., the smaller one.
258  enum ProteinIndex{ PROTEIN_A = 1, PROTEIN_B = 2 };
259 
260  // The surface type to use for construction of the grids.
261  enum SurfaceType { CONNOLLY = 1, VAN_DER_WAALS = 2, FTDOCK = 3 };
262 
266  GeometricFit();
267 
273  GeometricFit(System &system1, System &system2);
274 
279  GeometricFit(Options& new_options);
280 
285  GeometricFit(System &system1,System &system2 ,Options& new_options);
286 
287 
291  GeometricFit( const GeometricFit& geo_fit );
292 
293  // Destructor
294  ~GeometricFit();
295 
298  virtual void setup(System& system1, System& system2, Options& new_options);
299 
300  virtual void setup(System& system1, System& system2);
301 
304  void start();
305 
306 #ifdef BALL_HAS_MPI
307 
308  void MPI_Slave_start(int argc, char**argv);
309 #endif
310 
311  // return the overall docking progress as a percentage
312  float getProgress() const;
313 
314  //
315  bool hasFinished() const;
316 
319  Vector3 getTranslation(Index con_num) const;
320 
323  Vector3 getOrientation(Index con_num) const;
324 
327  ConformationSet getConformationSet(Index total_number = 0);
328 
330  // the member variables
331 
335 
336  protected:
337 
338  // Free all allocated memory and destroys the options and results
339  void destroy_();
340 
341  // find the inside points
342  void findInsidePoints_( System& system, ProteinIndex pro_idx );
343 
344  // find out the surface points according to the Connolly's surface definition.
345  void findConnollySurfacePoints_( System& system, ProteinIndex pro_idx );
346 
347  // find out the surface points according to the van der Waal's surface definition.
348  void findVanDerWaalsSurfacePoints_( System& system, ProteinIndex pro_idx );
349 
350  // find the inside points using the same algorithm as FTDock
351  void findFTDockInsidePoints_( System& system, ProteinIndex pro_idx );
352 
353  // find out the surface points according to the FTDock surface definition.
354  void findFTDockSurfacePoints_( System& system, ProteinIndex pro_idx );
355 
358  Vector3 getMassCenter_( System& system );
359 
362  float getRadius_( System& system );
363 
364  void doPreTranslation_( ProteinIndex pro_idx );
365 
366  void initGridSizes_();
367 
373  int optimizeGridSize_( int raw_size );
374 
377  void initFFTGrid_( ProteinIndex pro_idx );
378 
379  // make grid from System
380  void makeFFTGrid_( ProteinIndex pro_idx );
381 
382  // get the global peaks and put them into a list
383  void getGlobalPeak_(Peak_* peak_list);
384 
385  // change the orientation of protein around its center according to euler_ang
386  void changeProteinOrientation_( System& system, Vector3 euler_ang );
387 
388  // calculate the conjugate of each point in FFT grid
389  void calcConjugate_( ProteinIndex pro_idx );
390 
391  // calculate the product of the two FFT grids
392  void FFTGridMulti_();
393 
394  // get the transformation of the peak value according to its position in matrix
395  Vector3 getTranslation_( const Vector3& mat_pos );
396 
397  Vector3 getSeparation_( const Vector3& mat_pos );
398 
399 
400  // here we have two units for the size
401  // index : in the unit of grid points
402  // coord : in the unit of Angstrom
403 
404  // the FFT grid for protein A
406 
407  // the FFT grid for protein B
409 
410  float radius_a_;
411  float radius_b_;
412 
417 
419 
420  // the translation we do to the system b before FFT
421  // it is to reduse the size of the FFT_grid
424 
426 
427  // current execution progress
429 
430  // execution round of whole work
432 
433  // ordered set of the top_n peaks
434  std::multiset<Peak_> peak_set_;
435 
436  // Needed to produce the correct results in getRankedConformations
439 
440  // Vectors to store orientation and translation of the results in the ranked conformations
441  vector<Vector3> translations_;
442  vector<Vector3> orientations_;
443 
444  }; // class GeometricFit
445 
446 } // namespace BALL
447 
448 #endif
static const float THETA_MAX
Definition: geometricFit.h:159
static const String SURFACE_TYPE
Definition: geometricFit.h:80
Vector3 FFT_grid_upper_coord_
Definition: geometricFit.h:416
static const float PHI_MIN
Definition: geometricFit.h:154
static const String SLAVE_PATH
Definition: geometricFit.h:175
#define BALL_CREATE(name)
Definition: create.h:62
Vector3 FFT_grid_size_index_
Definition: geometricFit.h:418
static const String PSI_MIN
Definition: geometricFit.h:97
static const String TOP_N
Definition: geometricFit.h:72
static const float PSI_MAX
Definition: geometricFit.h:163
static const int VERBOSITY
Definition: geometricFit.h:151
static const int NUMBER_OF_PROCESSES
Definition: geometricFit.h:172
static const String GRID_SPACING
Definition: geometricFit.h:57
static const float GRID_SPACING
Definition: geometricFit.h:121
Vector3 pre_translation_a_
Definition: geometricFit.h:422
Vector3 pre_translation_b_
Definition: geometricFit.h:423
vector< Vector3 > translations_
Definition: geometricFit.h:441
static const String DEG_PHI
Definition: geometricFit.h:91
static const String PSI_MAX
Definition: geometricFit.h:98
static const String NEAR_RADIUS
Definition: geometricFit.h:53
static const String DEGREE_INTERVAL
Definition: geometricFit.h:69
static const float SURFACE_THICKNESS
Definition: geometricFit.h:128
static const int PENALTY_STATIC
Definition: geometricFit.h:168
static const int GRID_SIZE
Definition: geometricFit.h:124
static const String PENALTY_STATIC
Definition: geometricFit.h:103
static const String PHI_MAX
Definition: geometricFit.h:90
static const float THETA_MIN
Definition: geometricFit.h:158
static const float DEG_PSI
Definition: geometricFit.h:164
static const String GRID_SIZE
Definition: geometricFit.h:60
Vector3 FFT_grid_upper_index_
Definition: geometricFit.h:414
static const float NEAR_RADIUS
Definition: geometricFit.h:117
static const String THETA_MIN
Definition: geometricFit.h:93
static const String SURFACE_THICKNESS
Definition: geometricFit.h:64
static const String DEG_THETA
Definition: geometricFit.h:95
vector< Vector3 > orientations_
Definition: geometricFit.h:442
static const int BEST_NUM
Definition: geometricFit.h:145
static const String VERBOSITY
Definition: geometricFit.h:86
Vector3 FFT_grid_lower_index_
Definition: geometricFit.h:413
static const int PENALTY_MOBILE
Definition: geometricFit.h:169
static const float PSI_MIN
Definition: geometricFit.h:162
static const float PHI_MAX
Definition: geometricFit.h:155
static const String BEST_NUM
Definition: geometricFit.h:83
static const int SURFACE_TYPE
Definition: geometricFit.h:138
static const String PHI_MIN
Definition: geometricFit.h:89
static const String NUMBER_OF_PROCESSES
Definition: geometricFit.h:107
std::multiset< Peak_ > peak_set_
Definition: geometricFit.h:434
static const float DEG_PHI
Definition: geometricFit.h:156
static const double DEGREE_INTERVAL
Definition: geometricFit.h:133
Vector3 FFT_grid_lower_coord_
Definition: geometricFit.h:415
static const String DEG_PSI
Definition: geometricFit.h:99
Vector3 FFT_grid_origin_
Definition: geometricFit.h:425
static const float DEG_THETA
Definition: geometricFit.h:160
static const String PENALTY_MOBILE
Definition: geometricFit.h:104
static const String THETA_MAX
Definition: geometricFit.h:94
#define BALL_EXPORT
Definition: COMMON/global.h:50
static const String SLAVE_PATH
Definition: geometricFit.h:110
BALL_EXPORT bool operator<(const String &s1, const String &s2)