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