1 |
#define EXTERN extern |
2 |
#include "pcwin.h" |
3 |
#include "pcmod.h" |
4 |
#include "substr.h" |
5 |
#include "field.h" |
6 |
#include "atom_k.h" |
7 |
#include "pot.h" |
8 |
#include "energies.h" |
9 |
#include "solv.h" |
10 |
#include "fix.h" |
11 |
|
12 |
EXTERN int ncol[]; |
13 |
|
14 |
struct t_residues { |
15 |
int nchain, ichainstart[10]; |
16 |
int ngroup, iresnum[200], irestype[200], istartatom[200]; |
17 |
} residues; |
18 |
|
19 |
EXTERN struct t_minim_values { |
20 |
int iprint, ndc, nconst; |
21 |
float dielc; |
22 |
} minim_values; |
23 |
EXTERN struct t_units { |
24 |
double bndunit, cbnd, qbnd; |
25 |
double angunit, cang, qang, pang, sang, aaunit; |
26 |
double stbnunit, ureyunit, torsunit, storunit, v14scale; |
27 |
double aterm, bterm, cterm, dielec, chgscale; |
28 |
} units; |
29 |
EXTERN struct t_minim_control { |
30 |
int type, method, field, added_const; |
31 |
char added_path[256],added_name[256]; |
32 |
} minim_control; |
33 |
EXTERN struct t_dmomv { |
34 |
float xn,yn,zn,xp,yp,zp; |
35 |
} dmomv; |
36 |
EXTERN struct t_dipolemom { |
37 |
double total, xdipole, ydipole, zdipole; |
38 |
} dipolemom; |
39 |
EXTERN struct t_vdw1 { |
40 |
int nvdw; |
41 |
float rad[MAXVDWCONST], eps[MAXVDWCONST]; |
42 |
int lpd[MAXVDWCONST], ihtyp[MAXVDWCONST], ihdon[MAXVDWCONST]; |
43 |
float alpha[MAXVDWCONST],n[MAXVDWCONST],a[MAXVDWCONST],g[MAXVDWCONST]; |
44 |
char da[MAXVDWCONST][2]; |
45 |
} vdw1; |
46 |
|
47 |
EXTERN struct { |
48 |
int mm3, mmff, amber, opls; |
49 |
} AtomTypes[]; |
50 |
|
51 |
EXTERN struct ElementType { char symbol[3]; |
52 |
int atomnum; |
53 |
float weight, covradius, vdwradius; |
54 |
int s,p,d,f, type; |
55 |
} Elements[]; |
56 |
|
57 |
EXTERN struct t_centroid { |
58 |
int ncentroid, numsel[10]; |
59 |
int isel[10][10]; |
60 |
double x[10], y[10], z[10]; |
61 |
} centroid; |
62 |
|
63 |
void InitialTransform(void); |
64 |
int make_atom(int , float , float , float,char * ); |
65 |
void make_bond(int , int , int ); |
66 |
void generate_bonds(void); |
67 |
void deleteatom(int); |
68 |
void deletebond(int, int); |
69 |
void set_atomtype(int,int,int,int,int,int); |
70 |
void set_atomdata(int,int,int,int,int,int); |
71 |
extern void matrotat(float (*)[4], int, float); |
72 |
extern void matxform(float (*)[4], int); |
73 |
void message_alert(char *, char *); |
74 |
void charge_dipole(void); |
75 |
int isangle(int,int); |
76 |
int mm3_mmxtype(int); |
77 |
int mmff_mmxtype(int); |
78 |
|
79 |
// =============================================== |
80 |
void set_atomdata(int ia, int mmxtype, int mm3type, int mmfftype,int ambertype,int oplstype) |
81 |
{ |
82 |
int type; |
83 |
|
84 |
if (mmxtype > 0) |
85 |
atom[ia].mmx_type = mmxtype; |
86 |
if (mm3type > 0) |
87 |
atom[ia].mm3_type = mm3type; |
88 |
if (mmfftype > 0) |
89 |
atom[ia].mmff_type = mmfftype; |
90 |
if (ambertype > 0) |
91 |
atom[ia].amber_type = ambertype; |
92 |
if (oplstype > 0) |
93 |
atom[ia].opls_type = oplstype; |
94 |
|
95 |
if (field.type == MMX || field.type == MM2) |
96 |
{ |
97 |
type = mmxtype; |
98 |
} else if (field.type == MM3) |
99 |
{ |
100 |
type = mm3type; |
101 |
}else if (field.type == AMBER) |
102 |
{ |
103 |
type = ambertype; |
104 |
} else if (field.type == MMFF94) |
105 |
{ |
106 |
type = mmfftype; |
107 |
} else if (field.type == OPLSAA) |
108 |
{ |
109 |
type = oplstype; |
110 |
} |
111 |
|
112 |
if ( type < 300) |
113 |
{ |
114 |
atom[ia].tclass = atom_k.tclass[type]; |
115 |
atom[ia].atomnum = atom_k.number[type]; |
116 |
atom[ia].atomwt = atom_k.weight[type]; |
117 |
strcpy(atom[ia].name, atom_k.symbol[type]); |
118 |
} |
119 |
|
120 |
if ( field.type == MMX && mmxtype == LPTYPE) |
121 |
atom[ia].color = 1; |
122 |
else if ( type < 300 && mmxtype != LPTYPE ) |
123 |
atom[ia].color = ncol[atom[ia].atomnum-1]; |
124 |
else |
125 |
atom[ia].color = 7; |
126 |
|
127 |
} |
128 |
// =============================================== |
129 |
void set_atomtype(int ia, int mmxtype, int mm3type, int mmfftype,int ambertype,int oplstype) |
130 |
{ |
131 |
if (mmxtype > 0) |
132 |
atom[ia].mmx_type = mmxtype; |
133 |
if (mm3type > 0) |
134 |
atom[ia].mm3_type = mm3type; |
135 |
if (mmfftype > 0) |
136 |
atom[ia].mmff_type = mmfftype; |
137 |
if (ambertype > 0) |
138 |
atom[ia].amber_type = ambertype; |
139 |
if (oplstype > 0) |
140 |
atom[ia].opls_type = oplstype; |
141 |
|
142 |
} |
143 |
// ====================================================== |
144 |
int make_atom(int type, float x, float y, float z,char *name) |
145 |
{ |
146 |
int i,iz; |
147 |
int mmxtype, mm3type, mmfftype,ambertype,oplstype; |
148 |
|
149 |
natom++; |
150 |
if (natom >= MAXATOM - 10) |
151 |
{ |
152 |
natom--; |
153 |
message_alert("Max atoms exceeded in makeatom","PCMODEL Error"); |
154 |
return -1; |
155 |
} |
156 |
iz = strlen(name); |
157 |
if (iz > 0) // got an atom name use it |
158 |
{ |
159 |
for (i=1; i <= atom_k.natomtype; i++) |
160 |
{ |
161 |
if (strcmp(name,atom_k.symbol[i]) == 0) // names match |
162 |
{ |
163 |
strcpy(atom[natom].name,name); |
164 |
atom[natom].tclass = atom_k.tclass[i]; |
165 |
atom[natom].atomwt = atom_k.weight[i]; |
166 |
atom[natom].atomnum = atom_k.number[i]; |
167 |
atom[natom].type = atom_k.type[i]; |
168 |
if (type == 0) |
169 |
{ |
170 |
type = atom[natom].type; // this is an mmff type |
171 |
mmxtype = mmff_mmxtype(type); |
172 |
mm3type = 0; |
173 |
mmfftype = type; |
174 |
ambertype = 0; |
175 |
oplstype = 0; |
176 |
set_atomtype(natom,mmxtype,mm3type,mmfftype,ambertype,oplstype); |
177 |
if (mmfftype == 0) return -1; |
178 |
} else if (field.type == MMX || field.type == MM2) |
179 |
{ |
180 |
atom[natom].mmx_type = type; |
181 |
mmxtype = type; |
182 |
mm3type = AtomTypes[type-1].mm3; |
183 |
mmfftype = AtomTypes[type-1].mmff; |
184 |
ambertype = AtomTypes[type-1].amber; |
185 |
oplstype = AtomTypes[type-1].opls; |
186 |
set_atomtype(natom,mmxtype,mm3type,mmfftype,ambertype,oplstype); |
187 |
} else if (field.type == MM3) |
188 |
{ |
189 |
atom[natom].mm3_type = type; |
190 |
mmxtype = mm3_mmxtype(type); |
191 |
mm3type = type; |
192 |
mmfftype = AtomTypes[mmxtype-1].mmff; |
193 |
ambertype = AtomTypes[mmxtype-1].amber; |
194 |
oplstype = AtomTypes[mmxtype-1].opls; |
195 |
set_atomtype(natom,mmxtype,mm3type,mmfftype,ambertype,oplstype); |
196 |
} else if (field.type == MMFF94) |
197 |
{ |
198 |
atom[natom].mmff_type = type; |
199 |
mmxtype = mmff_mmxtype(type); |
200 |
mm3type = AtomTypes[mmxtype-1].mm3; |
201 |
mmfftype = type; |
202 |
ambertype = AtomTypes[mmxtype-1].amber; |
203 |
oplstype = AtomTypes[mmxtype-1].opls; |
204 |
set_atomtype(natom,mmxtype,mm3type,mmfftype,ambertype,oplstype); |
205 |
} |
206 |
|
207 |
atom[natom].color = ncol[atom[natom].atomnum-1]; |
208 |
atom[natom].x = x; atom[natom].y = y; atom[natom].z = z; |
209 |
atom[natom].vdw_radius = Elements[atom[natom].atomnum-1].covradius; |
210 |
atom[natom].substr[0] = (1L << 0); |
211 |
atom[natom].flags = 0; |
212 |
substr.istract[0] = TRUE; |
213 |
return natom; |
214 |
} |
215 |
} |
216 |
for( i = 0; i < 103; i++ ) |
217 |
{ |
218 |
if( strcasecmp(Elements[i].symbol,name) == 0 ) |
219 |
{ |
220 |
strcpy(atom[natom].name,Elements[i].symbol); |
221 |
atom[natom].atomwt = Elements[i].weight; |
222 |
atom[natom].atomnum = Elements[i].atomnum; |
223 |
atom[natom].type = Elements[i].type; // set generic type |
224 |
atom[natom].tclass = Elements[i].type; // set generic type |
225 |
atom[natom].mmx_type = Elements[i].type; // set generic type |
226 |
if (type > 0) |
227 |
{ |
228 |
atom[natom].type = type; // overwrite type if type is passed in |
229 |
if (field.type == MMX || field.type == MM2) |
230 |
atom[natom].mmx_type = type; |
231 |
else if (field.type == MM3) |
232 |
atom[natom].mm3_type = type; |
233 |
else if (field.type == MMFF94) |
234 |
atom[natom].mmff_type = type; |
235 |
else if (field.type == AMBER) |
236 |
atom[natom].amber_type = type; |
237 |
else if (field.type == OPLSAA) |
238 |
atom[natom].opls_type = type; |
239 |
} |
240 |
if (type != 0) atom[natom].type = type; |
241 |
atom[natom].color = ncol[atom[natom].atomnum-1]; |
242 |
atom[natom].x = x; atom[natom].y = y; atom[natom].z = z; |
243 |
atom[natom].vdw_radius = Elements[i].covradius; |
244 |
atom[natom].substr[0] = (1L << 0); |
245 |
substr.istract[0] = TRUE; |
246 |
if (type > 299) |
247 |
return -1; |
248 |
else if (atom[natom].mmff_type == 0) |
249 |
return -1; |
250 |
else |
251 |
return natom; |
252 |
} |
253 |
} |
254 |
} else |
255 |
{ |
256 |
message_alert("Input atom does not have valid atomic symbol or atom type","Error"); |
257 |
return -1; |
258 |
} |
259 |
return -1; |
260 |
} |
261 |
// ==================================================== |
262 |
void make_bond(int ia1, int ia2, int bo) |
263 |
{ |
264 |
int loop,loop1; |
265 |
|
266 |
if (ia1 < 1 || ia1 > MAXATOM) return; |
267 |
if (ia2 < 1 || ia2 > MAXATOM) return; |
268 |
/* find if bond exists */ |
269 |
for (loop = 0; loop < MAXIAT; loop++) |
270 |
{ |
271 |
if (atom[ia1].iat[loop] == ia2) |
272 |
{ |
273 |
if (bo == 1) |
274 |
atom[ia1].bo[loop] += bo; |
275 |
else |
276 |
atom[ia1].bo[loop] = bo; |
277 |
|
278 |
for (loop1 = 0; loop1 < MAXIAT; loop1++) |
279 |
{ |
280 |
if (atom[ia2].iat[loop1] == ia1) |
281 |
{ |
282 |
if ( bo == 1) |
283 |
{ |
284 |
atom[ia2].bo[loop1] += bo; /* bond exists return */ |
285 |
return; |
286 |
} else |
287 |
{ |
288 |
atom[ia2].bo[loop1] = bo; /* bond exists return */ |
289 |
return; |
290 |
} |
291 |
} |
292 |
} |
293 |
} |
294 |
} |
295 |
/* bond does not exist create it */ |
296 |
for (loop = 0; loop < MAXIAT; loop++) |
297 |
{ |
298 |
if (atom[ia1].iat[loop] == 0) |
299 |
{ |
300 |
atom[ia1].iat[loop] = ia2; |
301 |
atom[ia1].bo[loop] = bo; |
302 |
break; |
303 |
} |
304 |
} |
305 |
for (loop = 0; loop < MAXIAT; loop++) |
306 |
{ |
307 |
if (atom[ia2].iat[loop] == 0) |
308 |
{ |
309 |
atom[ia2].iat[loop] = ia1; |
310 |
atom[ia2].bo[loop] = bo; |
311 |
break; |
312 |
} |
313 |
} |
314 |
} |
315 |
// =============================================== |
316 |
void deleteatom(int i) |
317 |
{ |
318 |
int j,k, ibo; |
319 |
atom[i].type = 0; |
320 |
atom[i].x = 0.0F; |
321 |
atom[i].y = 0.0F; |
322 |
atom[i].z = 0.0F; |
323 |
atom[i].flags = 0; |
324 |
for (j=0; j < MAXSSCLASS; j++) |
325 |
atom[i].substr[j] = 0; |
326 |
for (j=0; j<MAXIAT; j++) |
327 |
{ |
328 |
if (atom[i].iat[j] != 0 ) |
329 |
{ |
330 |
if (atom[atom[i].iat[j]].atomnum == 1 || atom[atom[i].iat[j]].atomnum == 0 ) |
331 |
{ |
332 |
atom[atom[i].iat[j]].type = 0; |
333 |
atom[atom[i].iat[j]].x = 0.0F; |
334 |
atom[atom[i].iat[j]].y = 0.0F; |
335 |
atom[atom[i].iat[j]].z = 0.0F; |
336 |
atom[atom[i].iat[j]].flags = 0; |
337 |
} |
338 |
ibo = atom[i].bo[j]; |
339 |
for (k=1; k <= ibo; k++) |
340 |
deletebond(i,atom[i].iat[j]); |
341 |
atom[i].iat[j] = 0; |
342 |
} |
343 |
} |
344 |
natom--; |
345 |
} |
346 |
// ================================================== |
347 |
void deletebond(int i, int j) |
348 |
{ |
349 |
int i1,j1; |
350 |
for (i1=0; i1 < MAXIAT; i1++) |
351 |
{ |
352 |
if (atom[i].iat[i1] == j) |
353 |
{ |
354 |
if (atom[i].bo[i1] == 9) /* if deleting a coordinated bond - delete it completely */ |
355 |
{ |
356 |
atom[i].bo[i1] = 0; |
357 |
atom[i].iat[i1] = 0; |
358 |
} |
359 |
atom[i].bo[i1] -= 1; |
360 |
if (atom[i].bo[i1] <= 0 ) |
361 |
atom[i].iat[i1] = 0; |
362 |
break; |
363 |
} |
364 |
} |
365 |
for (j1=0; j1 < MAXIAT; j1++) |
366 |
{ |
367 |
if (atom[j].iat[j1] == i) |
368 |
{ |
369 |
if (atom[j].bo[j1] == 9) /* if deleting a coordinated bond - delete it completely */ |
370 |
{ |
371 |
atom[j].bo[j1] = 0; |
372 |
atom[j].iat[j1] = 0; |
373 |
} |
374 |
atom[j].bo[j1] -= 1; |
375 |
if (atom[j].bo[j1] <= 0) |
376 |
atom[j].iat[j1] = 0; |
377 |
break; |
378 |
} |
379 |
} |
380 |
} |
381 |
/* --------------------------- */ |
382 |
void generate_bonds(void) |
383 |
{ |
384 |
int i,j; |
385 |
|
386 |
bonds.numbonds = 0; |
387 |
for (i= 0; i <= natom; i++) |
388 |
{ |
389 |
bonds.ia1[i] = 0; |
390 |
bonds.ia2[i] = 0; |
391 |
bonds.bondorder[i] = 0; |
392 |
} |
393 |
|
394 |
for (i = 1; i <= natom; i++) |
395 |
{ |
396 |
for (j = 0; j < MAXIAT; j++) |
397 |
{ |
398 |
if (atom[i].iat[j] > i && atom[i].iat[j] != 0) |
399 |
{ |
400 |
bonds.ia1[bonds.numbonds] = i; |
401 |
bonds.ia2[bonds.numbonds] = atom[i].iat[j]; |
402 |
bonds.bondorder[bonds.numbonds] = atom[i].bo[j]; |
403 |
bonds.numbonds++; |
404 |
} |
405 |
} |
406 |
} |
407 |
} |