-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheintcal.cc
executable file
·334 lines (278 loc) · 15 KB
/
eintcal.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/*
$Id: eintcal.cc,v 1.17 2007/04/27 06:01:48 garrett Exp $
AutoDock
Copyright (C) 1989-2007, Garrett M. Morris, David S. Goodsell, Ruth Huey, Arthur J. Olson,
All Rights Reserved.
AutoDock is a Trade Mark of The Scripps Research Institute.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <math.h>
#include "eintcal.h"
#include "constants.h"
#include "distdepdiel.h"
extern Linear_FE_Model AD4;
extern int Nnb_array[3];
extern Real nb_group_energy[3];
#ifndef EINTCALPRINT
// Calculate internal energy
Real eintcal( NonbondParam * const nonbondlist,
const EnergyTables *ptr_ad_energy_tables,
const Real tcoord[MAX_ATOMS][SPACE],
const int Nnb,
const Boole B_calcIntElec,
const Boole B_include_1_4_interactions,
const Real scale_1_4,
const Real qsp_abs_charge[MAX_ATOMS],
const ParameterEntry parameterArray[MAX_MAPS],
const Boole B_use_non_bond_cutoff,
const Boole B_have_flexible_residues // if the receptor has flexibile residues, this will be set to TRUE
)
#else
// eintcalPrint [
extern FILE *logFile;
// Calculate internal energy and print out a detailed report
Real eintcalPrint( NonbondParam * const nonbondlist,
const EnergyTables *ptr_ad_energy_tables,
const Real tcoord[MAX_ATOMS][SPACE],
const int Nnb,
const Boole B_calcIntElec,
const Boole B_include_1_4_interactions,
const Real scale_1_4,
const Real qsp_abs_charge[MAX_ATOMS],
const ParameterEntry parameterArray[MAX_MAPS],
const Boole B_use_non_bond_cutoff,
const Boole B_have_flexible_residues // if the receptor has flexibile residues, this will be set to TRUE
)
// eintcalPrint ]
#endif
/* *****************************************************************************/
/* Name: eintcal */
/* Function: Calculate the Internal Energy of the Small Molecule. */
/* Accelerated non-square-rooting, dx,dy,dz version. */
/* Copyright: (C) 1994-2004, TSRI */
/* ____________________________________________________________________________*/
/* Authors: Garrett M. Morris, TSRI */
/* David Goodsell, UCLA */
/* Date: 16/03/94 */
/* ____________________________________________________________________________*/
/* Inputs: nonbondlist, ptr_ad_energy_tables, tcoord, type, Nnb */
/* Returns: total_e_internal */
/* Globals: NEINT, MAX_ATOMS, SPACE */
/* ____________________________________________________________________________*/
/* Modification Record */
/* Date Inits Comments */
/* 07/05/92 DSG Original FORTRAN */
/* 15/05/92 GMM Translated into C */
/* 15/05/92 GMM hypotenuse macro */
/* 19/11/93 GMM Accelerated non-square-rooting version. */
/* 16/03/94 GMM Accelerated dx,dy,dz version. */
/* 10/02/04 GMM Reduced NBC from 64.0 to 8.0 */
/* 04/03/05 GMM Added the new internal desolvation term */
/* *****************************************************************************/
{
// if r is less than the non-bond-cutoff,
// -OR-
// If we are computing the unbound conformation then we ignore the non bond cutoff, NBC
#ifndef EINTCALPRINT // eintcal [
# ifndef NOSQRT
register double r=0.0L; // SQRT
// if we have defined USE_8A_CUTOFF, then NBC = 8
const double nbc = B_use_non_bond_cutoff ? NBC : 999;
# else
// if we have defined USE_8A_CUTOFF, then NBC = 8 // Xcode-gmm
const double nbc2 = B_use_non_bond_cutoff ? NBC2 : 999 * 999;
# endif
// eintcal ]
#else // eintcalPrint [
# ifndef NOSQRT
register double d=0.0L; // SQRT
//const double nbc = NBC;
// if we have defined USE_8A_CUTOFF, then NBC = 8
const double nbc = B_use_non_bond_cutoff ? NBC : 999;
# else
//const double nbc2 = NBC2;
// if we have defined USE_8A_CUTOFF, then NBC = 8 // Xcode-gmm
const double nbc2 = B_use_non_bond_cutoff ? NBC2 : 999 * 999;
# endif
#endif // eintcalPrint ]
register double dx=0.0L, dy=0.0L, dz=0.0L;
register double r2=0.0L;
register double total_e_internal=0.0L; // total_e_internal = eint
register double e_elec=0.0L;
#ifdef EINTCALPRINT
double total_e_elec=0.0L;
double total_e_vdW_Hb=0.0L;
double e_vdW_Hb=0.0L;
double total_e_desolv=0.0L;
#endif
register int inb=0;
register int a1=0, a2=0;
register int t1=0, t2=0; // Xcode-gmm
register int nonbond_type=0; // if = 4, it is a 1_4; otherwise it is another kind of nonbond
register int index_lt_NEINT=0;
register int index_lt_NDIEL=0;
register int nb_group=0;
int inb_from=0;
int inb_to=0;
int nb_group_max = 1; // By default, we have one nonbond group, (1) intramolecular in the ligand
if (B_have_flexible_residues) {
// If we have flexible residues, we need to consider three groups of nonbonds:
// (1) intramolecular in the ligand, (2) intermolecular and (3) intramolecular in the receptor
nb_group_max = 3;
}
// Loop over the nonbonding groups --
// Either (intramolecular ligand nonbonds)
// or (intramolecular ligand nonbonds, intermolecular nonbonds, and intramolecular receptor nonbonds)
for (nb_group = 0; nb_group < nb_group_max; nb_group++) {
#ifdef EINTCALPRINT
if (nb_group == 0) {
pr(logFile, "\n\n\t\tLigand Intramolecular Energy Analysis\n");
pr(logFile, "\t\t=====================================\n\n");
}
if (nb_group == 1) {
pr(logFile, "\n\n\t\tLigand-Receptor Moving-Atom Intermolecular Energy Analysis\n");
pr(logFile, "\t\t==========================================================\n\n");
}
if (nb_group == 2) {
pr(logFile, "\n\n\t\tReceptor Moving-Atom Intramolecular Energy Analysis\n");
pr(logFile, "\t\t===================================================\n\n");
}
if (B_calcIntElec) {
pr( logFile, "Non-bond Atom1-Atom2 Distance Total Elec vdW+Hb Desolv Sol_fn Type Dielectric\n"); // eintcalPrint
pr( logFile, "________ ___________ ________ ______ ________ ________ ________ ________ ____ __________\n"); // eintcalPrint
} else {
pr( logFile, "Non-bond Atom1-Atom2 Distance Total vdW+Hb Desolv Sol_fn Type Dielectric\n"); // eintcalPrint
pr( logFile, "________ ___________ ________ ______ ________ ________ ________ ____ __________\n"); // eintcalPrint
}
#endif
if (nb_group == 0) {
inb_from = 0;
} else {
inb_from = Nnb_array[nb_group-1];
}
inb_to = Nnb_array[nb_group];
// Loop over the non-bonds in this nonbond "group", "inb",
for (inb = inb_from; inb < inb_to; inb++) {
double e_internal=0; // e_internal = epair
double e_desolv=0; // e_desolv = dpair
a1 = nonbondlist[inb].a1;
a2 = nonbondlist[inb].a2;
t1 = nonbondlist[inb].t1; // Xcode-gmm // t1 is a map_index
t2 = nonbondlist[inb].t2; // Xcode-gmm // t2 is a map_index
nonbond_type = nonbondlist[inb].nonbond_type;
double nb_desolv = nonbondlist[inb].desolv;
double q1q2 = nonbondlist[inb].q1q2;
// fprintf(stderr, "ITERATION %d\na1 = %d\na2 = %d\nt1 = %d\nt2 = %d\nnonbond=%d\ndesolv = %f\nq1q2 = %f\n", inb,a1,a2,t1,t2,nonbond_type,nb_desolv, q1q2);
dx = tcoord[a1][X] - tcoord[a2][X];
dy = tcoord[a1][Y] - tcoord[a2][Y];
dz = tcoord[a1][Z] - tcoord[a2][Z];
// Calculate the van der Waals and/or H-bonding energy & the desolvation energy.
//|
//| desolvation energy = sol_fn[dist] * ( rec.vol * (lig.solpar + qsolpar * |lig.charge|)
//| + lig.vol * (rec.solpar + qsolpar * |rec.charge|) );
//|
//| lig.solpar = parameterArray[t1].solpar;
//| lig.vol = parameterArray[t1].vol;
//| lig.charge = qsp_abs_charge[a1]/qsolpar;
//| rec.solpar = parameterArray[t2].solpar;
//| rec.vol = parameterArray[t2].vol;
//| rec.charge = qsp_abs_charge[a2]/qsolpar;
#ifndef NOSQRT
// Use square-root, slower...
// r = the separation between the atoms a1 and a2 in this non-bond, inb,
r = clamp(hypotenuse(dx,dy,dz), RMIN_ELEC); // clamp prevents electrostatic potential becoming too high when shorter than RMIN_ELEC
r2 = r*r;
register const int index = Ang_to_index(r); // convert real-valued distance r to an index for energy lookup tables
#else
// Non-square-rooting version, faster...
r2 = sqhypotenuse(dx,dy,dz); // r2, the square of the separation between the atoms a1 and a2 in this non-bond, inb,
r2 = clamp(r2, RMIN_ELEC2);
register const int index = SqAng_to_index(r2);
#endif // NOSQRT ]
index_lt_NEINT = BoundedNeint(index); // guarantees that index_lt_NEINT is never greater than (NEINT - 1)
index_lt_NDIEL = BoundedNdiel(index); // guarantees that index_lt_NDIEL is never greater than (NDIEL - 1)
if (B_calcIntElec) {
// Calculate Electrostatic Energy
double r_dielectric = ptr_ad_energy_tables->r_epsilon_fn[index_lt_NDIEL];
e_elec = q1q2 * r_dielectric;
e_internal = e_elec;
}
if ( r2 < nbc2 ) {
e_desolv = ptr_ad_energy_tables->sol_fn[index_lt_NEINT] * nb_desolv;
if (B_include_1_4_interactions != 0 && nonbond_type == 4) {
// fprintf(stderr,"index_1t_NEINT = %d\nindex t2 = %d\nindex t1 = %d\n", index_1t_NEINT, t2, t1);
//| Compute a scaled 1-4 interaction,
e_internal += scale_1_4 * (ptr_ad_energy_tables->e_vdW_Hb[index_lt_NEINT][t2][t1] + e_desolv);
} else {
// fprintf(stderr,"index_1t_NEINT = %d\nindex t2 = %d\nindex t1 = %d\n", index_lt_NEINT, t2, t1);
e_internal += ptr_ad_energy_tables->e_vdW_Hb[index_lt_NEINT][t2][t1] + e_desolv;
// fprintf(stderr, "e_vdW_Hb[%d][%d][%d] = %f\n", index_lt_NEINT, t2, t1, ptr_ad_energy_tables->e_vdW_Hb[index_lt_NEINT][t2][t1]);
}
}
total_e_internal += e_internal;
#ifdef EINTCALPRINT // eintcalPrint [
total_e_desolv += e_desolv;
total_e_elec += e_elec;
double dielectric = ptr_ad_energy_tables->epsilon_fn[index_lt_NDIEL];
if (B_calcIntElec) {
e_vdW_Hb = e_internal - e_desolv - e_elec,
pr( logFile, " %6d %5d-%-5d %7.2lf %+8.3lf %+8.3lf %+8.3lf %+8.3lf %+8.3lf %d %8.3lf\n",
(int)(inb+1), (int)(a1+1), (int)(a2+1), (double)sqrt(r2),
(double)e_internal, (double)e_elec, (double)e_vdW_Hb, (double)e_desolv,
(double)ptr_ad_energy_tables->sol_fn[index_lt_NEINT], (int)nonbond_type, (double)dielectric
);
} else {
e_vdW_Hb = e_internal - e_desolv,
pr( logFile, " %6d %5d-%-5d %7.2lf %+8.3lf %+8.3lf %+8.3lf %+8.3lf %d %8.3lf\n",
(int)(inb+1), (int)(a1+1), (int)(a2+1), (double)sqrt(r2),
(double)e_internal, (double)e_vdW_Hb, (double)e_desolv,
(double)ptr_ad_energy_tables->sol_fn[index_lt_NEINT], (int)nonbond_type, (double)dielectric
);
}
total_e_vdW_Hb += e_vdW_Hb;
#endif // eintcalPrint ]
} // inb -- next non-bond interaction
if (nb_group == INTRA_LIGAND) { // [0]
// Intramolecular energy of ligand
nb_group_energy[INTRA_LIGAND] = total_e_internal;
} else if (nb_group == INTER) { // [1]
// intermolecular energy
nb_group_energy[INTER] = total_e_internal - nb_group_energy[INTRA_LIGAND];
} else if (nb_group == INTRA_RECEPTOR) { // [2]
// intramolecular energy of receptor
nb_group_energy[INTRA_RECEPTOR] = total_e_internal - nb_group_energy[INTRA_LIGAND] - nb_group_energy[INTER];
}
} // nb_group -- intra lig, inter, intra rec
#ifdef EINTCALPRINT
if (B_calcIntElec) {
pr( logFile, " ________ ________ ________ ________\n");
pr( logFile, "Total %+8.3lf %+8.3lf %+8.3lf %+8.3lf\n", total_e_internal, total_e_elec, total_e_vdW_Hb, total_e_desolv);
pr( logFile, " ________ ________ ________ ________\n");
pr( logFile, " Total Elec vdW+Hb Desolv\n");
} else {
pr( logFile, " ________ ________ ________\n");
pr( logFile, "Total %+8.3lf %+8.3lf %+8.3lf\n", total_e_internal, total_e_vdW_Hb, total_e_desolv);
pr( logFile, " ________ ________ ________n");
pr( logFile, " Total vdW+Hb Desolv\n");
}
#endif
#ifdef EINTCALPRINT
pr( logFile, "\nTotal Intramolecular Interaction Energy = %+.3lf kcal/mol\n", (double)total_e_internal); // eintcalPrint
#endif
return (Real) total_e_internal;
}
/* EOF */