Debian Codegraph @

include/BALL/DOCKING/IMGDOCK/IMGDock.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4
5 #ifndef BALL_DOCKING_IMGDOCK_IMGDOCK_H
6 #define BALL_DOCKING_IMGDOCK_IMGDOCK_H
7
8 #ifndef BALL_DOCKING_COMMON_DOCKINGALGORITHEM_H
9 #include <BALL/DOCKING/COMMON/dockingAlgorithm.h>
10 #endif
11
12 #ifndef BALL_MOLMEC_COMMON_FORCEFIELD_H
13 #include <BALL/MOLMEC/COMMON/forceField.h>
14 #endif
15
16 #ifndef BALL_MATH_MATRIX44_H
17 #include <BALL/MATHS/matrix44.h>
18 #endif
19
20 #ifndef BALL_SCORING_COMMON_SCORINGFUNCTION_H
21 #include <BALL/SCORING/COMMON/scoringFunction.h>
22 #endif
23
24 #ifndef BALL_DOCKING_COMMON_STATICLIGANDFRAGMENT_H
25 #include <BALL/DOCKING/COMMON/staticLigandFragment.h>
26 #endif
27
28 #ifndef BALL_DOCKING_COMMON_SIDECHAINOPTIMIZER_H
29 #include <BALL/DOCKING/COMMON/sideChainOptimizer.h>
30 #endif
31
32 #include <map>
33
34
35 namespace BALL
36 {
37 /** Iterative Multi-Greedy Docking */
38 class BALL_EXPORT IMGDock : public DockingAlgorithm
39 {
40 public:
41 /** @name Constructors&Destructors */
42 //@{
43 IMGDock(System& receptor, System& ligand, Options& new_options);
44
45 IMGDock(System& receptor, System& ligand);
46
47 IMGDock(System& receptor, System& ligand, string config_file);
48
49 ~IMGDock();
50 //@}
51
52 /** @name Constant Definitions
53 */
54 //@{
55 struct Option
56 {
57 static const char* STEP_WIDTH;
58 static const char* NO_SOLUTIONS;
59 static const char* GLOBAL_ROTATION;
60 static const char* POST_OPTIMIZATION_STEPS;
61 static const char* POST_OPTIMIZATION_STEP_WIDTH;
62 static const char* MIN_INHIBITOR_ATOMS;
63 static const char* SCORING_TYPE;
64 static const char* ITERATIONS;
65 static const char* DECREASE_STEPWIDTH;
66 static const char* SUPERPOSE_LIGAND;
67 };
68
69 struct Default
70 {
71 static int STEP_WIDTH;
72 static int NO_SOLUTIONS;
73 static bool GLOBAL_ROTATION;
74 static int POST_OPTIMIZATION_STEPS;
75 static double POST_OPTIMIZATION_STEP_WIDTH;
76 static int MIN_INHIBITOR_ATOMS;
77 static String SCORING_TYPE;
78 static int ITERATIONS;
79 static bool DECREASE_STEPWIDTH;
80 static bool SUPERPOSE_LIGAND;
81 };
82
83 /** @name Accessors */
84 //@{
85 void setup(System& receptor, System& ligand, Options& new_options);
86
87 void setup(System& receptor, System& ligand);
88
89 void start();
90
91 /** tries to dock a given ligand and return the obtained energy ( = internal conformation energy of the ligand + binding free energy) */
92 double dockLigand(AtomContainer& ligand, bool verbose = 0);
93
94 /** returns the energy of current conformation of the ligand candidate ( = conformation energy+interaction energy), as calculated by the last call of update() */
95 double getEnergy();
96
97 /** returns the IMGDock score for the current conformation of the ligand candidate as calculated by the last call of update(); i.e. the interaction+conformation energy scaled ... \n
98 -- with respect to the depth of burial of the ligand candidate into the binding pocket \n
99 -- and with respect to the number/fraction of ligand atoms that are located within the various reference areas (which are defined by the user) */
100 double getScore();
101
102 /** prints information about each fragment of the ligand */
103 void printFragments(std::ostream& out = std::cout);
104
105 void printResults(std::ostream& out = std::cout);
106
107 /** rotate a ligand fragment around one of its bonds that connects it to another fragment */
108 void rotateLigandFragment(Size fragment, Size bond, int degree);
109
110 void steps(Size no = 1);
111
112 /** updates energy and forces between target and ligand */
113 void update();
114
115 void startDock(bool verbose = 0);
116
117 const AtomContainer* getLigand();
118
119 //ConformationSet getConformationSet(Index total_conformations);
120
121 /** stores the default options of this algorithms in the given Option object */
122 static void getDefaultOptions(Options& options);
123 //@}
124
125 /** @name Attributes */
126 //@{
127 int rec;
128 //@}
129
130 private:
131 typedef std::multimap<double, std::vector<int> > PoseList;
132
133 /** @name Accessors */
134 //@{
135 void rotateLigandFragment(StaticLigandFragment* lf, TMatrix4x4<float>& M, Vector3& origin, int static_fragment);
136
137 /** translates the entire ligand candidate according to the given vector */
138 void translateLigand(Vector3& v);
139
140 /** calculates IMGDock score from the current interaction+conforamtion energy */
141 void calculateScore(double& interact_energy, double& conf_energy);
142
143 void createLigandFragments();
144
145 /** stores force vectors of ligand atoms to old_forces_ */
146 void storeForces();
147
148 /** reassigns the ligand atom forces from old_forces_ */
149 void reassignForces();
150
151 /** stores information about each inter-fragment bond in bond_information_ */
152 void saveBondInformation();
153
154 void saveBondInformation(AtomPairList* mapped_atoms);
155
156 bool findUnfrozenFragments(int fragment, std::set<int> frozen_fragments, std::set<int>& processed_fragments);
157
158 void postDockOptimization(double step_width, int no_steps);
159
160 void recursionPrint(string line);
161
162 void optimizeRotation(std::vector < int > & conf, PoseList& best_conformations, Size bond, bool ignore_original_angle);
163
164 void displayConformation(const std::vector < int > & conf, const double& energy);
165
166 void applyConformation(const std::vector < int > & conf, bool verbose = 0);
167
168 /** try to find a bond, so that the force vector is orthogonal to the plane spanned by the bond and the fragment center */
169 //void findBestFragmentRotation(int fragment, Size& bond, int& degree, map<int>* ignore_bonds);
170
171 /** find the inter-fragment bond that has the largest angle to the currently largest repulsive force vector (i.e. which is orthogonal in the best case)
172 @param ignore_bond ID of bond that should be ignored because rotation around it did not decrease energy; \n
173 if ignore_bond == -1, no bond is ignored
174 @param fragment if fragment == -1, the fragment to rotate is obtained by this function itself, overwriting the value at the given reference; \n
175 if fragment != -1, the bond to rotate around is searched within the given fragment
176 @param degree angle between largest repulsive force vector and plane build out of inter-fragment bond and atom on which this force vector acts on */
177 //void findBestRotation(int& fragment, Size& bond, int& degree, map* ignore_bonds = NULL, bool use_fragment_force = 0);
178
179 /** rotate the entire ligand around the X-, Y-, or Z-axis
180 @param a the axis to rotate around, 0: = X-axis, 1: = Y-axis, 2: = Z-axis */
181 void rotateLigand(int a, int degree);
182
183 /** sets all rotations back to zero degrees */
184 void resetRotations();
185
186 /** saves positions of current ligand to original_atom_positions_ */
187 void saveAtomPositions();
188
189 //@}
190
191 /** @name Attributes */
192 //@{
193
194 /** the number of times the algorithms tries to successively optimize all inter-fragment bonds */
195 int iterations_;
196
197 /** determines whether each ligand is superposed to the reference ligand before the actual docking is started */
198 bool superpose_ligand_;
199
200 int no_steps_;
201
202 std::vector<Vector3> original_atom_positions_;
203
204 //AtomContainer* receptor_;
205
206 double score_;
207
208 /** geometrical center of the reference ligand, i.e. the ligand obtained from the cristal structure */
209 Vector3 reference_center_;
210
211 /** saves force vectors of ligand atoms, so that after undoing a rotation (because it increased overall energy) the forces need not be calculated anew */
212 std::vector < Vector3 > old_forces_;
213
214 /** current rotation angles of all inter-fragment bonds */
215 std::vector < int > current_conformation_;
216
217 /** for each entry of current_conformation_, this matrix saves the id of the fragment and the id of the inter-fragment bond of this fragment that this entry corresponds to in one column */
218 std::vector < std::vector < int > > bond_information_;
219
220 /** the highest index of a inter-fragment bond that has been rotated so far */
221 int max_rotated_pos_;
222
223 /** if set to true (via options), the step-width is reduced by a factor of 2 in each iteration (whereas the number of steps is held constant). */
224 bool decrease_stepwidth_;
225
226 /** the size of the angle (in degrees) by which should be rotated around inter-fragment bonds in each step */
227 int step_width_;
228
229 Size no_solutions_;
230
231 /** the number of optimization steps that are to be done after docking by use of the function postDockOptimization() */
232 int post_optimization_steps_;
233
234 /** the width of each step of post docking optimization in units of Angstroem */
235 double post_optimization_step_width_;
236
237 /** determines whether the entire compound should be rotated around the global x-, y-, z-axis before opimizing inter-fragment bonds */
238 bool global_rotation_;
239
240 int min_inhibitor_atoms_;
241
242 /** average number of target atoms around each reference ligand atom */
243 int av_ref_lig_neighbors_;
244
245 PoseList best_conformations_;
246
247 SideChainOptimizer* sidechain_optimizer_;
248
249 //@}
250 };
251 }
252
253 #endif // BALL_DOCKING_IMGDOCK_IMGDOCK_H