BALL  1.4.2
 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_STRUCTURE_DOCKING_GEOMETRICFIT_H
6 #define BALL_STRUCTURE_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_STRUCTURE_DOCKING_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 
184  {
185  public:
186 
187  // constructor
188  Peak_();
189 
190  // destructor
191  ~Peak_();
192 
193  // Operator <
194  bool operator < (const Peak_& p) const;
195 
196  double value;
199  };
200 
205  {
206  public:
207 
208  // constructor
209  RotationAngles_();
210 
211  // constructor
212  RotationAngles_( int step );
213 
214  // destructor
216 
217  // generate all non-degenerate rotation angles.
218  // This algorithm is based on ???
219  bool generateSomeAngles( const float deg_phi, const float deg_psi, const float deg_theta,
220  const float phi_min, const float phi_max,
221  const float psi_min, const float psi_max,
222  const float theta_min, const float theta_max );
223 
224  // generate all non-degenerate rotation angles.
225  // This algorithm is based on ???
226  bool generateAllAngles( const int deg );
227 
228  int getRotationNum()
229  {
230  return ang_num_;
231  }
232 
233  int getXAng( int n ) // get the euler angle rotate around x axis
234  {
235  return phi_[n];
236  }
237 
238  int getYAng( int n ) // get the euler angle rotate around y axis
239  {
240  return theta_[n];
241  }
242 
243  int getZAng( int n ) // get the euler angle rotate around z axis
244  {
245  return psi_[n];
246  }
247 
248  // TODO: This class is a bit strange...
249  vector<int> phi_;
250  vector<int> theta_;
251  vector<int> psi_;
252 
253  private:
254  int ang_num_;
256  };
257 
258  // PROTEIN_A is the static protein, i.e., the bigger one;
259  // PROTEIN_B is the mobile protein, i.e., the smaller one.
260  enum ProteinIndex{ PROTEIN_A = 1, PROTEIN_B = 2 };
261 
262  // The surface type to use for construction of the grids.
263  enum SurfaceType { CONNOLLY = 1, VAN_DER_WAALS = 2, FTDOCK = 3 };
264 
265  // Default constructor
266  // Creates an empty GeometricFit object
267  GeometricFit();
268 
274  GeometricFit(System &system1, System &system2);
275 
280  GeometricFit(Options& new_options);
281 
286  GeometricFit(System &system1,System &system2 ,Options& new_options);
287 
288 
289 /* // Copy constructor */
290 /* // Copies an existing GeometricFit object */
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