ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/type_mmx.c
Revision: 125
Committed: Thu Jun 18 18:38:50 2009 UTC (11 years, 8 months ago) by wdelano
File size: 111905 byte(s)
Log Message:
added fn prototypes; eliminated more warnings
Line File contents
1 #define EXTERN extern
2 #include "pcwin.h"
3 #include "pcmod.h"
4 #include "utility.h"
5
6 void set_atomtype(int,int,int,int);
7 void set_atomtypes(int);
8 int is_ring31(int);
9 int is_ring41(int);
10 int is_ring51(int);
11 int is_ring61(int);
12 int is_cyclo5(int, int *);
13 int isbond(int,int);
14 int aromatic_5(int *,long int *flags,int *atomnum,int **,int **);
15 int find_rsize(int,int);
16 void get_rsize(int,int,int, int *);
17 int icompare(int, int *, int *);
18 void adjust_mmfftypes(void);
19 void deletebond(int,int);
20 int get_field(void);
21 int count_ewg(int);
22 void type_mmx(void);
23
24 // ==================
25 void type_mmx()
26 {
27 int i, j, ij, jji, jjk, jjbo, jj_bo, iatype,nh,newg;
28 int k, l, jatm, katm, latm, jbo,kbo,lbo, ismetal;
29 int nnit,nnh,nc;
30 int ktype,jtype;
31 int adjn, nplus, adjn1, noxide, icurr;
32 int mmxtype,mm3type,mmfftype, gafftype, ia, ib, ia1, ib1;
33 int ndouble, ntriple;
34 int icycl3, icycl4, icycl5, icycl6;
35 int full_ring=0, non_pi;
36 int array[7];
37 int nit[6];
38 long int aromatic_mask, mask6, type_mask;
39
40
41 aromatic_mask = (1 << AROMATIC_MASK);
42 mask6 = (1L << RING6);
43 type_mask = (1L << NO_RETYPE);
44 ia = 0;
45 ib = 0;
46 mm3type = 0;
47 latm = katm = jatm = 0;
48 k = 0;
49 jji = 0;
50
51 for (i=1; i <= natom; i++)
52 {
53 mmxtype = atom.mmx_type[i];
54 gafftype = atom.gaff_type[i];
55 mmfftype = atom.mmff_type[i];
56 if (atom.atomnum[i] != 0 && !(atom.flags[i] & type_mask) )
57 {
58 if (mmxtype == 100 || mmxtype == 101 || mmxtype == 102 || mmxtype == 103 ) // user defined type
59 {
60 goto L_20;
61 }
62 if (atom.atomnum[i] == 1) // hydrogens
63 {
64 if (atom.mmx_type[i] == 45) // TS H
65 {
66 mmxtype = 45;
67 mm3type = 0;
68 mmfftype = 0;
69 goto L_10;
70 }
71 if (atom.mmx_type[i] == 36) // Deuterium
72 {
73 mmxtype = 36;
74 mm3type = 36;
75 mmfftype = 5;
76 goto L_10;
77 }
78 jji = atom.nconnect[i];
79 if (jji == 2 ) // hydrogen bonded to two atoms or bonded to one and coordinated to another
80 {
81 mmxtype = 70;
82 goto L_10;
83 }
84 if (atom.atomnum[atom.iat[i][0]] == 6) // carbon
85 {
86 mmxtype = 5;
87 mm3type = 5;
88 mmfftype = 5;
89 gafftype = 25; // default to H on aliphatic carbon
90 jatm = atom.iat[i][0];
91 for (j=0; j < 3; j++) // Acetylene
92 {
93 if (atom.bo[jatm][j] == 3)
94 {
95 mm3type = 124;
96 goto L_10;
97 }
98 }
99 newg = count_ewg(jatm);
100 if (atom.flags[jatm] & aromatic_mask)
101 {
102 gafftype = 25;
103 if (newg == 1) gafftype = 56; // h4
104 if (newg == 2) gafftype = 57; // h5
105 } else
106 {
107 if (newg == 1) gafftype = 53; // h1
108 if (newg == 2) gafftype = 54; // h2
109 if (newg == 3) gafftype = 55; // h3
110 }
111
112 goto L_10;
113 } else if (atom.atomnum[atom.iat[i][0]] == 7) // nitrogen
114 {
115 jatm = atom.iat[i][0];
116 iatype = atom.mmx_type[jatm];
117 noxide = FALSE;
118 ismetal = FALSE;
119 mmxtype = 23;
120 mm3type = 23;
121 mmfftype = 23;
122 gafftype = 28;
123 jj_bo = atom.tbo[jatm];
124 for (j=0; j < jji; j++)
125 {
126 if (atom.mmx_type[atom.iat[jatm][j]] >= 300)
127 ismetal = TRUE;
128 if (atom.atomnum[atom.iat[jatm][j]] == 8)
129 {
130 katm = atom.iat[jatm][j];
131 jjk = atom.nconnect[atom.iat[katm][k]];
132 if (jjk == 1)
133 noxide = TRUE;
134 }
135 }
136 if (jj_bo == 4) // N+
137 {
138 mmxtype = 24;
139 mm3type = 48;
140 if (ismetal == TRUE)
141 {
142 mmxtype = 23;
143 mm3type = 23;
144 }
145 mmfftype = 36;
146 if (noxide == TRUE)
147 mmfftype = 23;
148 goto L_10;
149 }
150 if (atom.flags[jatm] & aromatic_mask)
151 {
152 mmxtype = 23;
153 mm3type = 23;
154 mmfftype = 23;
155 if (is_cyclo5(jatm,array) )
156 {
157 jjk = 0;
158 for (j=0; j < 5; j++)
159 {
160 if (atom.atomnum[array[j]] == 7)
161 jjk++;
162 }
163 if (jjk == 2)
164 {
165 jj_bo = 0;
166 for (j=0; j < 5; j++)
167 {
168 if (atom.atomnum[array[j]] == 7 && array[j] != jatm)
169 {
170 katm = array[j];
171 jj_bo = atom.tbo[katm];
172 if (jj_bo == 4)
173 {
174 mmfftype = 36;
175 goto L_10;
176 }
177 }
178 }
179 }
180 }
181 goto L_10;
182 }
183 if (atom.mmff_type[atom.iat[i][0]] == 56 || atom.mmff_type[atom.iat[i][0]] == 55)
184 {
185 mmfftype = 36;
186 goto L_10;
187 }
188 if (atom.mmff_type[atom.iat[i][0]] == 62)
189 {
190 mmfftype = 23;
191 goto L_10;
192 }
193 for (j=0; j < atom.nconnect[jatm]; j++)
194 {
195 if (atom.iat[jatm][j] != 0 && atom.mmx_type[atom.iat[jatm][j]] != 20)
196 {
197 if (atom.bo[jatm][j] == 2 && (atom.atomnum[atom.iat[jatm][j]] == 6 || atom.atomnum[atom.iat[jatm][j]] == 7)) // imine
198 {
199 mmxtype = 23;
200 mm3type = 23;
201 mmfftype = 27;
202 goto L_10;
203 }
204 if (atom.bo[jatm][j] == 2 && atom.atomnum[atom.iat[jatm][j]] == 16 ) // imine
205 {
206 mmxtype = 23;
207 mm3type = 23;
208 mmfftype = 28;
209 goto L_10;
210 }
211 if (atom.atomnum[atom.iat[jatm][j]] == 16 && atom.mmff_type[atom.iat[jatm][j]] == 18) // thioamide
212 {
213 mmxtype = 23;
214 mm3type = 23;
215 mmfftype = 28;
216 goto L_10;
217 }
218 if (atom.atomnum[atom.iat[jatm][j]] == 6 || atom.atomnum[atom.iat[jatm][j]] == 7) // amide and enamine
219 {
220 katm = atom.iat[jatm][j];
221 for (k=0; k < atom.nconnect[katm]; k++)
222 {
223 if (atom.iat[katm][k] != 0 && atom.iat[katm][k] != jatm)
224 {
225 if (atom.bo[katm][k] == 3 && atom.atomnum[atom.iat[katm][k]] == 7)
226 {
227 mmxtype = 23;
228 mm3type = 23;
229 if (atom.mmff_type[jatm] != 8)
230 mmfftype = 28;
231 else
232 mmfftype = 23;
233 goto L_10;
234 }
235 if (atom.bo[katm][k] == 2)
236 {
237 if (atom.atomnum[atom.iat[katm][k]] == 8 || atom.atomnum[atom.iat[katm][k]] == 16) // amide
238 {
239 mmxtype = 23;
240 mm3type = 28;
241 mmfftype = 28;
242 goto L_10;
243 } else if (atom.atomnum[atom.iat[katm][k]] == 6)
244 {
245 mmxtype = 23;
246 mm3type = 28;
247 if (atom.mmff_type[jatm] != 8)
248 mmfftype = 28;
249 else
250 mmfftype = 23;
251 goto L_10;
252 } else if ( atom.atomnum[atom.iat[katm][k]] == 7) // HN-c=n and HN-c=n+
253 {
254 mmfftype = 28;
255 noxide = FALSE;
256 latm = atom.iat[katm][k];
257 jjk = atom.tbo[latm];
258 for (l=0; l < atom.nconnect[latm]; l++)
259 {
260 if (atom.atomnum[atom.iat[latm][l]] == 8)
261 noxide = TRUE;
262 }
263 if (jjk == 4 && noxide == FALSE && atom.mmff_type[jatm] != 40)
264 mmfftype = 36;
265 goto L_10;
266 }
267 }
268 }
269 }
270 }
271 }
272 }
273 mmxtype = 23; // amine
274 mm3type = 23;
275 mmfftype = 23;
276 goto L_10;
277 } else if (atom.atomnum[atom.iat[i][0]] == 8) // oxygen
278 {
279 mmxtype = 21;
280 mm3type = 21;
281 mmfftype = 21;
282 gafftype = 27;
283 jatm = atom.iat[i][0];
284 if (atom.iat[jatm][0] != i)
285 katm = atom.iat[jatm][0];
286 else
287 katm = atom.iat[jatm][1];
288 jjk = 0;
289 for (j=0; j < atom.nconnect[jatm]; j++)
290 {
291 if (atom.iat[jatm][j] != 0 && atom.atomnum[atom.iat[jatm][j]] == 1)
292 jjk++;
293 }
294 if (atom.atomnum[katm] == 1 && jjk == 2) // water
295 {
296 mmxtype = 21;
297 mm3type = 21;
298 mmfftype = 31;
299 goto L_10;
300 } else if (atom.atomnum[katm] == 1 && jjk == 3) // h3o+
301 {
302 mmxtype = 24;
303 mm3type = 21;
304 mmfftype = 50;
305 goto L_10;
306 }
307 if (atom.atomnum[katm] == 15) // h-o-p
308 {
309 mmxtype = 24;
310 mm3type = 24;
311 mmfftype = 24;
312 goto L_10;
313 }
314 if (atom.atomnum[katm] == 16) // h-o-s
315 {
316 mmxtype = 24;
317 mm3type = 24;
318 mmfftype = 33;
319 goto L_10;
320 }
321 jjk = atom.nconnect[jatm];
322 if (jjk == 3 || jjk == 4) // O+
323 {
324 mmxtype = 24;
325 mm3type = 21;
326 mmfftype = 50;
327 goto L_10;
328 }
329 for (j=0; j < atom.nconnect[katm]; j++)
330 {
331 if (atom.atomnum[atom.iat[katm][j]] == 8 && atom.iat[katm][j] != jatm)
332 {
333 if (atom.bo[katm][j] == 2) // carboxyl
334 {
335 mmxtype = 24;
336 mm3type = 24;
337 mmfftype = 24;
338 goto L_10;
339 }
340 }
341 if (atom.atomnum[katm] == 6 && (atom.atomnum[atom.iat[katm][j]] == 6 || atom.atomnum[atom.iat[katm][j]] == 7)
342 && atom.iat[katm][j] != jatm) // enol
343 {
344 if (atom.bo[katm][j] == 2)
345 {
346 mmxtype = 28;
347 mm3type = 73;
348 mmfftype = 29;
349 goto L_10;
350 }
351 }
352 }
353 if (jji == 2) // OH
354 {
355 mmxtype = 21;
356 mm3type = 21;
357 mmfftype = 21;
358 for (j=0; j < atom.nconnect[jatm]; j++) // H-O=C
359 {
360 if (atom.iat[jatm][j] == katm && atom.bo[jatm][j] == 2)
361 {
362 mmxtype = 24;
363 mmfftype = 52;
364 goto L_10;
365 }
366 }
367 goto L_10;
368 }
369 goto L_10;
370 } else if (atom.atomnum[atom.iat[i][0]] == 5) // boron
371 {
372 mmxtype = 23;
373 mm3type = 5;
374 mmfftype = 71;
375 goto L_10;
376 } else if (atom.atomnum[atom.iat[i][0]] == 9 || atom.atomnum[atom.iat[i][0]] == 17 ||
377 atom.atomnum[atom.iat[i][0]] == 35 || atom.atomnum[atom.iat[i][0]] == 53) // halogens
378 {
379 mmxtype = 21;
380 mm3type = 5;
381 mmfftype = 71;
382 goto L_10;
383 } else if (atom.atomnum[atom.iat[i][0]] == 16) // sulfur
384 {
385 mmxtype = 21;
386 mm3type = 5;
387 mmfftype = 71;
388 gafftype = 30;
389 goto L_10;
390 } else if (atom.atomnum[atom.iat[i][0]] == 15) // phosphorous
391 {
392 mmxtype = 23;
393 mm3type = 5;
394 mmfftype = 71;
395 gafftype = 29;
396 goto L_10;
397 } else // bridging hydrogens
398 {
399 jji = atom.nconnect[i];
400 mm3type = 5;
401 if (jji == 2)
402 mmxtype = 70;
403 else
404 {
405 mmxtype = 5;
406 mm3type = 5;
407 mmfftype = 5;
408 }
409 goto L_10;
410 }
411 } else if (atom.atomnum[i] == 5) // boron
412 {
413 if (atom.mmx_type[i] == 27) // four coordinate boron
414 {
415 mmxtype = 27;
416 mm3type = 27;
417 mmfftype = 0;
418 goto L_10;
419 }
420 if (atom.mmx_type[i] == 43) // Transition state boron
421 {
422 mmxtype = 43;
423 mm3type = 0;
424 mmfftype = 0;
425 goto L_10;
426 }
427 jji = atom.nconnect[i];
428 if (jji == 4)
429 {
430 mmxtype = 27;
431 mm3type = 27;
432 mmfftype = 0;
433 } else
434 {
435 mmxtype = 26;
436 mm3type = 26;
437 mmfftype = 0;
438 }
439 goto L_10;
440 // =========================== Carbon ===============================
441 } else if (atom.atomnum[i] == 6) // carbon
442 {
443 ndouble = 0;
444 ntriple = 0;
445 jji = atom.nconnect[i];
446 icycl3 = find_rsize(3,i);
447 icycl4 = find_rsize(4,i);
448 icycl5 = find_rsize(5,i);
449 icycl6 = find_rsize(6,i);
450
451 for (j=0; j < jji; j++)
452 {
453 if (atom.bo[i][j] == 3)
454 ntriple++;
455 if (atom.bo[i][j] == 2)
456 ndouble++;
457 }
458 // check here for types that can not be done by rules but must be set by user
459 // and thus should not be changed
460 if (mmxtype == 29) // C radical
461 {
462 mmxtype = 29;
463 mm3type = 29;
464 mmfftype = 0;
465 goto L_10;
466 } else if (mmxtype == 30) // C cation
467 {
468 mmxtype = 30;
469 mm3type = 30;
470 mmfftype = 0;
471 goto L_10;
472 } else if (mmxtype == 48) // C anion
473 {
474 mmxtype = 48;
475 mm3type = 0;
476 mmfftype = 0;
477 goto L_10;
478 } else if (mmxtype == 40) // aromatic carbon
479 {
480 mmxtype = 40;
481 mm3type = 50;
482 mmfftype = 37;
483 goto L_10;
484 } else if (mmxtype == 49 || mmxtype == 50 || mmxtype == 51 || mmxtype == 52) // TS atoms
485 {
486 mm3type = 0;
487 mmfftype = 0;
488 goto L_10;
489 }
490 // check rings
491 if (icycl5 >= 1 && icycl6 >= 1 && atom.flags[i] & aromatic_mask) // CB and CN
492 {
493 get_rsize(i,5,0,array);
494 for (j=0; j < 5; j++)
495 {
496 if ( !(atom.flags[array[j]] & aromatic_mask))
497 goto L_NOTPURINE;
498 }
499 nnh = 0;
500 nnit = 0;
501 for (j=0; j < 5; j++)
502 {
503 if (atom.atomnum[array[j]] == 7)
504 {
505 nnit++;
506 for (k=0; k < 4; k++)
507 {
508 if (atom.atomnum[atom.iat[array[j]][k]] == 1)
509 nnh++;
510 }
511 }
512 }
513 if (nnit == 2 && nnh == 2)
514 {
515 mmxtype = 2;
516 mm3type = 2;
517 mmfftype = 78;
518 goto L_10;
519 }
520 //
521 nnh = 0;
522 nnit = 0;
523 for (j=0; j < atom.nconnect[i]; j++)
524 {
525 if (atom.atomnum[atom.iat[i][j]] == 7)
526 {
527 nnit++;
528 for (k=0; k < atom.nconnect[atom.iat[i][j]]; k++)
529 {
530 if (atom.atomnum[atom.iat[atom.iat[i][j]][k]] == 1)
531 {
532 nnh++;
533 }
534 }
535 }
536 }
537 }
538 L_NOTPURINE:
539 if (icycl5 >= 1 && atom.flags[i] & aromatic_mask)
540 {
541 mmxtype = 2;
542 mm3type = 2;
543 for (ij=0; ij < icycl5; ij++)
544 {
545 // do mmff types
546 get_rsize(i,5,ij,array);
547 if (aromatic_5(array,atom.flags,atom.atomnum,atom.iat,atom.bo))
548 {
549 icurr = -1;
550 nplus = FALSE;
551 for (j=0; j < 5; j++)
552 {
553 if (array[j] == i)
554 icurr = j;
555 if (atom.atomnum[array[j]] == 7)
556 {
557 jjk = atom.nconnect[array[j]];
558 jj_bo = atom.tbo[array[j]];
559 if (jjk == 2 && jj_bo == 2) // divalent N anion
560 {
561 mmfftype = 78;
562 goto L_10;
563 }
564 if (jj_bo == 4)
565 nplus = TRUE;
566 }
567 }
568
569 // check alpha
570 ia = (icurr+4)%5;
571 ib = (icurr+6)%5;
572 if (atom.atomnum[array[ia]] == 7 && atom.atomnum[array[ib]] == 7) // n=c-n
573 {
574 jatm = array[ia];
575 katm = array[ib];
576 jbo = atom.tbo[jatm];
577 kbo = atom.tbo[katm];
578 if ( jbo == 4 && kbo == 3)
579 {
580 adjn = FALSE;
581 for (j=0; j < atom.nconnect[katm]; j++)
582 {
583 if (atom.iat[katm][j] != 0 && atom.bo[katm][j] == 2)
584 adjn = TRUE;
585 }
586 if (adjn == FALSE)
587 {
588 mmfftype = 80;
589 goto L_10;
590 }
591 }else if (jbo == 3 && kbo == 4)
592 {
593 adjn = FALSE;
594 for (j=0; j < atom.nconnect[jatm]; j++)
595 {
596 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
597 adjn = TRUE;
598 }
599 if (adjn == FALSE)
600 {
601 mmfftype = 80;
602 goto L_10;
603 }
604 }
605 }
606 if (nplus == TRUE) // found N+ in ring
607 {
608 noxide = FALSE;
609 jjk = 0;
610 for (j=0; j < 5; j++)
611 {
612 if (atom.atomnum[array[j]] == 7)
613 {
614 nit[jjk] = j;
615 jjk++;
616 }
617 }
618 if (jjk >= 2)
619 {
620 jatm = array[nit[0]];
621 katm = array[nit[1]];
622 jbo = atom.tbo[jatm];
623 kbo = atom.tbo[katm];
624 adjn = FALSE;
625 adjn1 = FALSE;
626 for (k=0; k < atom.nconnect[jatm]; k++)
627 {
628 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] == 2)
629 adjn = TRUE;
630 }
631 for (k=0; k < atom.nconnect[katm]; k++)
632 {
633 if (atom.iat[katm][k] != 0 && atom.bo[katm][k] == 2)
634 adjn1 = TRUE;
635 }
636 if ( (jbo == 4 && kbo == 3 && adjn1 == FALSE) ||
637 (jbo == 3 && kbo == 4 && adjn == FALSE) )
638 {
639 noxide = FALSE;
640 if (jbo == 4)
641 ia1 = jatm;
642 else
643 ia1 = katm;
644 for (k=0; k < atom.nconnect[ia1]; k++)
645 {
646 if (atom.iat[ia1][k] != 0 && atom.atomnum[atom.iat[ia1][k]] == 8)
647 {
648 ib1 = atom.iat[ia1][k];
649 jjk = atom.nconnect[ib1];
650 if (jjk == 1)
651 noxide = TRUE;
652 }
653 }
654 if (noxide == FALSE)
655 {
656 mmfftype = 78;
657 goto L_10;
658 }
659 }
660 }
661 }
662
663 if (atom.atomnum[array[ia]] != 6 && atom.atomnum[array[ib]] != 6) // x=c-x
664 {
665 jatm = array[ia];
666 katm = array[ib];
667 jbo = atom.tbo[jatm];
668 kbo = atom.tbo[katm];
669 if ( (jbo == 4 && kbo == 2) || (jbo == 2 && kbo == 4))
670 {
671 for (j=0; j < atom.nconnect[i]; j++)
672 {
673 if (atom.iat[i][j] != 0 && atom.iat[i][j] != jatm && atom.iat[i][j] != katm)
674 {
675 if (atom.atomnum[atom.iat[i][j]] == 7)
676 {
677 mmfftype = 80;
678 goto L_10;
679 }
680 }
681 }
682 }
683 }
684 if (atom.atomnum[array[ia]] == 7) // alpha n
685 {
686 jatm = array[ia];
687 adjn = FALSE;
688 for (j=0; j < atom.nconnect[jatm]; j++)
689 {
690 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] ==2)
691 adjn = TRUE;
692 }
693 if (adjn == FALSE)
694 {
695 mmfftype = 63;
696 goto L_10;
697 }
698 }
699 if (atom.atomnum[array[ib]] == 7) // alpha n
700 {
701 jatm = array[ib];
702 adjn = FALSE;
703 for (j=0; j < atom.nconnect[jatm]; j++)
704 {
705 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
706 adjn = TRUE;
707 }
708 if (adjn == FALSE)
709 {
710 mmfftype = 63;
711 goto L_10;
712 }
713 }
714 if (atom.atomnum[array[ia]] == 8 || atom.atomnum[array[ib]] == 8 || // alpha o or s
715 atom.atomnum[array[ia]] == 16 || atom.atomnum[array[ib]] == 16 )
716 {
717 mmfftype = 63;
718 goto L_10;
719 }
720 // check beta
721 ia = (icurr+3)%5;
722 ib = (icurr+7)%5;
723 if (atom.atomnum[array[ia]] == 7) // c=x-n
724 {
725 jatm = array[ia];
726 adjn = FALSE;
727 for (j=0; j < atom.nconnect[jatm]; j++)
728 {
729 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
730 adjn = TRUE;
731 }
732 if (adjn == FALSE)
733 {
734 mmfftype = 64;
735 goto L_10;
736 }
737 }
738 if (atom.atomnum[array[ib]] == 7) // c=x-n
739 {
740 jatm = array[ib];
741 adjn = FALSE;
742 for (j=0; j < atom.nconnect[jatm]; j++)
743 {
744 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
745 adjn = TRUE;
746 }
747 if (adjn == FALSE)
748 {
749 mmfftype = 64;
750 goto L_10;
751 }
752 }
753 if (atom.atomnum[array[ia]] == 8 || atom.atomnum[array[ib]] == 8 || // beta o or s
754 atom.atomnum[array[ia]] == 16 || atom.atomnum[array[ib]] == 16 )
755 {
756 mmfftype = 64;
757 goto L_10;
758 }
759 }
760 }
761 }
762 if (icycl6 >= 1 && atom.flags[i] & aromatic_mask)
763 {
764 mmxtype = 2;
765 mm3type = 2;
766 mmfftype = 37;
767 for (k = 0; k < icycl6; k++)
768 {
769 get_rsize(i,6,k,array);
770 {
771 full_ring = TRUE;
772 non_pi = FALSE;
773 for (j=0; j < 6; j++) // check all ring atoms are pi
774 {
775 if ( !(atom.flags[array[j]] & aromatic_mask) )
776 non_pi = TRUE;
777 }
778 if (non_pi == TRUE)
779 full_ring = FALSE;
780 }
781 if (full_ring == TRUE)
782 break;
783 }
784 if (full_ring == FALSE) mmfftype = 2;
785 goto L_10;
786 }
787 if (icycl3 >= 1 )
788 {
789 mmxtype = 22;
790 mm3type = 22; // type 38 for cyclopropene, type 67 for cyclopropanone
791 if (ndouble >= 1)
792 {
793 for (j=0; j < atom.nconnect[i]; j++)
794 {
795 if (atom.iat[i][j] != 0)
796 {
797 if (atom.bo[i][j] == 2 && atom.atomnum[atom.iat[i][j]] == 8)
798 {
799 mmxtype = 3;
800 mm3type = 67;
801 goto L_10;
802 }
803 }
804 }
805 mm3type = 38;
806 }
807 mmfftype = 22;
808 goto L_10;
809 }
810 // start of check on bondorders
811 if (ntriple == 1)
812 {
813 mmxtype = 4;
814 mm3type = 4;
815 mmfftype = 4;
816 if (jji == 1 && atom.atomnum[atom.iat[i][0]] == 7)
817 {
818 mmfftype = 60; // isonitrile carbon
819 }
820 if ( (atom.mmx_type[atom.iat[i][0]] >= 300) &&
821 atom.mmx_type[atom.iat[i][1]] == 46)
822 {
823 mmxtype = 63;
824 goto L_10;
825 }
826 if ( (atom.mmx_type[atom.iat[i][1]] >= 300) &&
827 atom.mmx_type[atom.iat[i][0]] == 46)
828 {
829 mmxtype = 63;
830 goto L_10;
831 }
832 for (j=0; j < atom.nconnect[i]; j++)
833 {
834 if ( (atom.mmx_type[atom.iat[i][j]] >= 300) && atom.bo[i][j] == 3)
835 {
836 mmxtype = 62;
837 goto L_10;
838 }
839 }
840 goto L_10;
841 }
842 if (ndouble == 2) // allenes and ketenes
843 {
844 mmxtype = 4;
845 mm3type = 68;
846 mmfftype = 4;
847 for (j=0; j < atom.nconnect[i]; j++) // metal carbene
848 {
849 if ( atom.mmx_type[atom.iat[i][j]] >= 300)
850 mmxtype = 61;
851 }
852 goto L_10;
853 }
854 if (ndouble == 1)
855 {
856 for (j=0; j < atom.nconnect[i]; j++)
857 {
858 if (atom.iat[i][j] != 0)
859 {
860 if (atom.bo[i][j] == 2)
861 {
862 jatm = atom.iat[i][j];
863 break;
864 }
865 }
866 }
867 if (atom.atomnum[jatm] == 15) // c=p
868 {
869 mmxtype = 2;
870 mm3type = 2;
871 mmfftype = 3;
872 goto L_10;
873 }
874 if (atom.atomnum[jatm] == 16) // c=s
875 {
876 mmxtype = 2;
877 mm3type = 2;
878 mmfftype = 3;
879 for (k=0; k < atom.nconnect[i]; k++)
880 {
881 if (atom.iat[i][k] != 0 && atom.bo[i][k] != 9)
882 {
883 if (atom.atomnum[atom.iat[i][k]] == 16 && atom.iat[i][k] != jatm)
884 {
885 katm = atom.iat[i][k];
886 jjk = atom.nconnect[katm];
887 if (jjk == 1) // thiocarboxylate
888 {
889 mmfftype = 41;
890 goto L_10;
891 }
892 }
893 }
894 }
895 goto L_10;
896 }
897 if (atom.atomnum[jatm] == 8) // C=O
898 {
899 mmxtype = 3;
900 mm3type = 3;
901 mmfftype = 3;
902 if (is_ring31(i)) // cyclopropanone
903 mm3type = 67;
904 else if (is_ring41(i)) // cyclobutanone
905 mm3type = 58;
906 else // carboxylate
907 {
908 for(k=0; k < atom.nconnect[i]; k++)
909 {
910 if (atom.iat[i][k] != 0)
911 {
912 if (atom.atomnum[atom.iat[i][k]] == 8 && atom.iat[i][k] != jatm)
913 {
914 katm = atom.iat[i][k];
915 jjk = atom.nconnect[katm];
916 if (jjk == 1)
917 {
918 mmfftype = 41;
919 break;
920 }
921 }
922 }
923 }
924 }
925 goto L_10;
926 } else if (atom.atomnum[jatm] == 7) // C=N
927 {
928 mmxtype = 2;
929 mm3type = 2;
930 mmfftype = 3;
931 if (jji == 3)
932 {
933 if (atom.iat[i][0] == jatm)
934 {
935 katm = atom.iat[i][1];
936 latm = atom.iat[i][2];
937 } else if (atom.iat[i][1] == jatm)
938 {
939 katm = atom.iat[i][0];
940 latm = atom.iat[i][2];
941 } else if (atom.iat[i][2] == jatm)
942 {
943 katm = atom.iat[i][0];
944 latm = atom.iat[i][1];
945 }
946 if (atom.atomnum[jatm] == 7 && atom.atomnum[katm] == 7 && atom.atomnum[latm] == 7)
947 {
948 jbo = atom.tbo[jatm];
949 kbo = atom.tbo[katm];
950 lbo = atom.tbo[latm];
951 adjn = FALSE;
952 for (j=0; j < atom.nconnect[katm]; j++)
953 {
954 if (atom.bo[katm][j] == 2)
955 adjn = TRUE;
956 if (atom.bo[latm][j] == 2)
957 adjn = TRUE;
958 }
959 if (jbo == 4 && kbo == 3 && lbo == 3 && adjn == FALSE)
960 {
961 mmfftype = 57;
962 goto L_10;
963 }
964 }
965 if (atom.atomnum[jatm] == 7 && atom.atomnum[katm] == 7)
966 {
967 jbo = atom.tbo[jatm];
968 kbo = atom.tbo[katm];
969 adjn = FALSE;
970 for (j=0; j < atom.nconnect[katm]; j++)
971 {
972 if (atom.bo[katm][j] == 2)
973 adjn = TRUE;
974 }
975 if (jbo == 4 && kbo == 3 && adjn == FALSE)
976 {
977 mmfftype = 57;
978 goto L_10;
979 }
980 }
981 if (atom.atomnum[jatm] == 7 && atom.atomnum[latm] == 7)
982 {
983 jbo = atom.tbo[jatm];
984 lbo = atom.tbo[latm];
985 adjn = FALSE;
986 for (j=0; j < atom.nconnect[latm]; j++)
987 {
988 if (atom.bo[latm][j] == 2)
989 adjn = TRUE;
990 }
991 if (jbo == 4 && lbo == 3 && adjn == FALSE)
992 {
993 mmfftype = 57;
994 goto L_10;
995 }
996 }
997 }
998 goto L_10;
999 } else if (atom.atomnum[jatm] == 6) // C=C
1000 {
1001 mmxtype = 2;
1002 mm3type = 2;
1003 mmfftype = 2;
1004 if (is_ring31(i)) // cyclopropene
1005 {
1006 mm3type = 38;
1007 goto L_10;
1008 }
1009 if (is_ring41(i)) // cyclobutene
1010 {
1011 mmxtype = 57;
1012 mm3type = 57;
1013 mmfftype = 30;
1014 goto L_10;
1015 }
1016
1017 goto L_10;
1018 } else // default for cases not dealt with yet
1019 {
1020 mmxtype = 2;
1021 mm3type = 2;
1022 mmfftype = 2;
1023 goto L_10;
1024 }
1025 goto L_10;
1026 }
1027 // get here with only single bonds to carbon
1028 mmxtype = 1;
1029 mm3type = 1;
1030 mmfftype = 1;
1031 if (is_ring31(i))
1032 {
1033 mmxtype = 22;
1034 mm3type = 22;
1035 mmfftype = 22;
1036 goto L_10;
1037 } else if (is_ring41(i))
1038 {
1039 mmxtype = 56;
1040 mm3type = 56;
1041 mmfftype = 20;
1042 goto L_10;
1043 }
1044 goto L_10;
1045 // ============ Nitrogen atom types =================
1046 } else if (atom.atomnum[i] == 7) // nitrogen
1047 {
1048 jji = atom.nconnect[i];
1049 nc = 0;
1050 nh = 0;
1051 jjbo = 0;
1052 ndouble = 0;
1053 ntriple = 0;
1054 nplus = FALSE;
1055 noxide = FALSE;
1056 for (j=0; j < jji; j++)
1057 {
1058 if (atom.atomnum[atom.iat[i][j]] == 1)
1059 nh++;
1060 if (atom.atomnum[atom.iat[i][j]] == 6)
1061 nc++;
1062 }
1063 icycl5 = find_rsize(5,i);
1064 icycl6 = find_rsize(6,i);
1065 //
1066 if (icycl5 >= 1 && atom.flags[i] & aromatic_mask)
1067 {
1068 jjbo = atom.tbo[i];
1069 for (j=0; j < jji; j++)
1070 {
1071 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9 && atom.mmx_type[atom.iat[i][j]] != 20 )
1072 {
1073 if (atom.atomnum[atom.iat[i][j]] == 8)
1074 {
1075 katm = atom.iat[i][j];
1076 jjk = atom.nconnect[katm];
1077 if (jjk == 1)
1078 noxide = TRUE;
1079 }
1080 }
1081 }
1082 get_rsize(i,5,0,array);
1083 for(j=0; j < 5; j++)
1084 {
1085 if (atom.atomnum[array[j]] == 7)
1086 {
1087 jjk = atom.nconnect[array[j]];
1088 jj_bo = atom.tbo[array[j]];
1089 if (jji == 2 && jj_bo == 2) // found divalent anion
1090 {
1091 mmfftype = 76;
1092 goto L_10;
1093 }
1094 }
1095 }
1096 if (jji == 2 && jjbo == 2) // divalent anion
1097 {
1098 // mmxtype = 77;
1099 mmfftype = 76;
1100 goto L_10;
1101 }
1102 if (jjbo == 4 && noxide == TRUE)
1103 {
1104 mmxtype = 41;
1105 mm3type = 39;
1106 mmfftype = 82;
1107 goto L_10;
1108 }
1109 if (jjbo == 4)
1110 {
1111 mmxtype = 41;
1112 mm3type = 39;
1113 mmfftype = 81;
1114 goto L_10;
1115 }
1116 // assume only one ring need to fix this
1117 get_rsize(i,5,0,array);
1118 ndouble = 0;
1119 for (j=0; j < atom.nconnect[i]; j++)
1120 {
1121 if (atom.iat[i][j] != 0 && atom.bo[i][j] == 2)
1122 ndouble++;
1123 }
1124 if (ndouble == 1) // check for alpha or beta N,O,S
1125 {
1126 mmxtype = 37;
1127 mm3type = 37;
1128 icurr = -1;
1129 for (j=0; j < 5; j++)
1130 {
1131 if (array[j] == i)
1132 icurr = j;
1133 }
1134 if (icurr == 0)
1135 {
1136 ia = array[1];
1137 ib = array[4];
1138 } else if (icurr == 4)
1139 {
1140 ia = array[0];
1141 ib = array[3];
1142 } else
1143 {
1144 ia = array[icurr-1];
1145 ib = array[icurr+1];
1146 }
1147
1148 if (atom.atomnum[ia] == 7) // alpha
1149 {
1150 adjn = FALSE;
1151 for (k=0; k < atom.nconnect[ia]; k++)
1152 {
1153 if (atom.iat[ia][k] != 0 && atom.bo[ia][k] == 2)
1154 adjn = TRUE;
1155 }
1156 if (adjn == FALSE)
1157 {
1158 mmfftype = 65;
1159 goto L_10;
1160 }
1161 }
1162 if (atom.atomnum[ib] == 7)
1163 {
1164 adjn = FALSE;
1165 for (k=0; k < atom.nconnect[ib]; k++)
1166 {
1167 if (atom.iat[ib][k] != 0 && atom.bo[ib][k] == 2)
1168 adjn = TRUE;
1169 }
1170 if (adjn == FALSE)
1171 {
1172 mmfftype = 65;
1173 goto L_10;
1174 }
1175 }
1176 if (atom.atomnum[ia] == 8 || atom.atomnum[ia] == 16)
1177 {
1178 mmfftype = 65;
1179 goto L_10;
1180 }
1181 if (atom.atomnum[ib] == 8 || atom.atomnum[ib] == 16)
1182 {
1183 mmfftype = 65;
1184 goto L_10;
1185 }
1186 // now check beta
1187 if (icurr == 0)
1188 {
1189 ia = array[2]; ib = array[3];
1190 } else if (icurr == 1)
1191 {
1192 ia = array[3]; ib = array[4];
1193 } else if (icurr == 2)
1194 {
1195 ia = array[4]; ib = array[0];
1196 } else if (icurr == 3)
1197 {
1198 ia = array[0]; ib = array[1];
1199 } else if (icurr == 4)
1200 {
1201 ia = array[1]; ib = array[2];
1202 }
1203 if (atom.atomnum[ia] == 7)
1204 {
1205 jjk = atom.nconnect[ia];
1206 jj_bo = atom.tbo[ia];
1207 if (jjk == 3 && jj_bo == 3)
1208 {
1209 mmfftype = 66;
1210 goto L_10;
1211 }
1212 }
1213 if (atom.atomnum[ib] == 7)
1214 {
1215 jjk = atom.nconnect[ib];
1216 jj_bo = atom.tbo[ib];
1217 if (jjk == 3 && jj_bo == 3)
1218 {
1219 mmfftype = 66;
1220 goto L_10;
1221 }
1222 }
1223 if (atom.atomnum[ia] == 8 || atom.atomnum[ia] == 16)
1224 {
1225 mmfftype = 66;
1226 goto L_10;
1227 }
1228 if (atom.atomnum[ib] == 8 || atom.atomnum[ib] == 16)
1229 {
1230 mmfftype = 66;
1231 goto L_10;
1232 }
1233 }
1234 // single bonds only
1235 icurr = -1;
1236 nplus = FALSE;
1237 for (j=0; j < 5; j++)
1238 {
1239 if (array[j] == i)
1240 icurr = j;
1241 if (atom.atomnum[array[j]] == 7)
1242 nplus = TRUE;
1243 }
1244 if (nplus == TRUE)
1245 {
1246 if (icurr == 0)
1247 {
1248 ia = array[2]; ib = array[3];
1249 } else if (icurr == 1)
1250 {
1251 ia = array[3]; ib = array[4];
1252 } else if (icurr == 2)
1253 {
1254 ia = array[4]; ib = array[0];
1255 } else if (icurr == 3)
1256 {
1257 ia = array[0]; ib = array[1];
1258 } else if (icurr == 4)
1259 {
1260 ia = array[1]; ib = array[2];
1261 }
1262 if (atom.atomnum[ia] == 7)
1263 {
1264 jj_bo = atom.tbo[ia];
1265 noxide = FALSE;
1266 for (k=0; k < atom.nconnect[ia]; k++)
1267 {
1268 if (atom.atomnum[atom.iat[ia][k]] == 8)
1269 {
1270 katm = atom.iat[ia][k];
1271 jjk = atom.nconnect[katm];
1272 if (jjk == 1)
1273 noxide = TRUE;
1274 }
1275 }
1276 if (jj_bo == 4 && noxide == FALSE)
1277 {
1278 mmfftype = 81; // histidine ??
1279 goto L_10;
1280 }
1281 }
1282 if (atom.atomnum[ib] == 7)
1283 {
1284 jj_bo = atom.tbo[ib];
1285 noxide = FALSE;
1286 for (k=0; k < atom.nconnect[ib]; k++)
1287 {
1288 if (atom.atomnum[atom.iat[ib][k]] == 8)
1289 {
1290 katm = atom.iat[ib][k];
1291 jjk = atom.nconnect[katm];
1292 if (jjk == 1)
1293 noxide = TRUE;
1294 }
1295 }
1296 if (jj_bo == 4 && noxide == FALSE)
1297 {
1298 mmfftype = 81; // histidine ??
1299 goto L_10;
1300 }
1301 }
1302 }
1303 // need test for pyrol here
1304 ndouble = 0;
1305 for (j=0; j < atom.nconnect[i]; j++)
1306 {
1307 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9)
1308 {
1309 katm = atom.iat[i][j];
1310 for (k=0; k < atom.nconnect[katm]; k++)
1311 {
1312 if (atom.iat[katm][k] != 0 && atom.bo[katm][k] == 2)
1313 ndouble++;
1314 }
1315 }
1316 }
1317 if (ndouble >= 1)
1318 {
1319 mmxtype = 9;
1320 mm3type = 9;
1321 }
1322 // failed tests use general type
1323 mmfftype = 39;
1324 goto L_10;
1325 }
1326 if (icycl6 >= 1 && atom.flags[i] & aromatic_mask)
1327 {
1328 mmxtype = 37;
1329 mm3type = 37;
1330 mmfftype = 38;
1331 nnit = 0;
1332 get_rsize(i,6,0,array);
1333 for (j=0; j < 6; j++)
1334 {
1335 if (atom.atomnum[array[j]] == 7)
1336 nnit++;
1337 }
1338 jji = atom.nconnect[i];
1339 jjbo = atom.tbo[i];
1340 for (j=0; j < jji; j++)
1341 {
1342 if (atom.atomnum[atom.iat[i][j]] == 8)
1343 {
1344 katm = atom.iat[i][j];
1345 jjk = atom.nconnect[katm];
1346 if (jjk == 1)
1347 noxide = TRUE;
1348 }
1349 }
1350 if (jjbo == 4 && noxide == TRUE)
1351 {
1352 mmxtype = 41;
1353 mm3type = 143;
1354 mmfftype = 69;
1355 } else if (jjbo == 4)
1356 {
1357 mmxtype = 41;
1358 mm3type = 111;
1359 mmfftype = 58;
1360 }
1361 goto L_10;
1362 }
1363 // non cyclic systems
1364 jji = atom.nconnect[i];
1365 jjbo = atom.tbo[i];
1366 ndouble = 0;
1367 ntriple = 0;
1368 for (j=0; j < jji; j++)
1369 {
1370 if (atom.bo[i][j] == 2)
1371 ndouble++;
1372 if (atom.bo[i][j] == 3)
1373 ntriple++;
1374 }
1375 if (ntriple == 1) // nitriles and isonitriles
1376 {
1377 mmxtype = 10;
1378 mm3type = 10;
1379 if (jji == 1)
1380 mmfftype = 42;
1381 else if (jji == 2)
1382 {
1383 mmfftype = 61;
1384 mmxtype = 68;
1385 // nitrile oxides
1386 if (atom.atomnum[atom.iat[i][0]] == 8 || atom.atomnum[atom.iat[i][1]] == 8)
1387 mmxtype = 41;
1388 }
1389 for (j=0; j < jji; j++)
1390 {
1391 if (atom.mmx_type[atom.iat[i][j]] >= 300)
1392 mmxtype = 65;
1393 }
1394 goto L_10;
1395 }
1396 // two double bonds to N - azides
1397 if (ndouble == 2 && jji == 2)
1398 {
1399 mmxtype = 37;
1400 mm3type = 46;
1401 mmfftype = 53;
1402 goto L_10;
1403 } else if (ndouble == 2 && jji == 3) // nitrate
1404 {
1405 mmxtype = 41;
1406 mm3type = 45;
1407 mmfftype = 45;
1408 goto L_10;
1409 }
1410 // single double bond to N
1411 if (ndouble == 1)
1412 {
1413 mmxtype = 37;
1414 mm3type = 37;
1415 mmfftype = 9;
1416 if (jji == 3 && jjbo == 4) //=N+
1417 {
1418 mmxtype = 41;
1419 mm3type = 39;
1420 // goto L_10;
1421 }
1422 for (j=0; j < jji; j++)
1423 {
1424 if (atom.iat[i][j] != 0 && atom.bo[i][j] == 2)
1425 {
1426 jatm = atom.iat[i][j];
1427 break;
1428 }
1429 }
1430 if (jji == 1 && atom.atomnum[jatm] == 7) // N=N=X azido and diazo
1431 {
1432 mmfftype = 47;
1433 goto L_10;
1434 }
1435 if (atom.atomnum[jatm] == 8) // N=O
1436 {
1437 if (jjbo == 4) // nitro
1438 {
1439 mmxtype = 41;
1440 mm3type = 46;
1441 mmfftype = 45;
1442 goto L_10;
1443 } else if (jjbo == 3) // nitroso
1444 {
1445 mmxtype = 37;
1446 mm3type = 0;
1447 mmfftype = 46;
1448 goto L_10;
1449 }
1450 }else if (atom.atomnum[jatm] == 16) // N=S=O
1451 {
1452 for (k=0; k < atom.nconnect[jatm]; k++)
1453 {
1454 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] != 9 && atom.iat[jatm][k] != i)
1455 {
1456 if (atom.atomnum[atom.iat[jatm][k]] == 8 && atom.bo[jatm][k] == 2)
1457 {
1458 mmfftype = 48;
1459 goto L_10;
1460 }
1461 }
1462 }
1463 } else if (atom.atomnum[jatm] == 7) // N=N
1464 {
1465 mmfftype = 9;
1466 if (jjbo == 4)
1467 {
1468 for (k=0; k < jji; k++)
1469 {
1470 if (atom.iat[i][k] != 0 && atom.iat[i][k] != jatm)
1471 {
1472 if (atom.atomnum[atom.iat[i][k]] == 8) // n=n-o azoxy
1473 {
1474 mmxtype = 37;
1475 mm3type = 37;
1476 mmfftype = 67;
1477 goto L_10;
1478 }
1479 }
1480 }
1481 }
1482 goto L_10;
1483 } else if (atom.atomnum[jatm] == 6) // N=C
1484 {
1485 jjk = atom.nconnect[jatm];
1486 if (jjk == 3)
1487 {
1488 if (atom.iat[jatm][0] == i)
1489 {
1490 katm = atom.iat[jatm][1];
1491 latm = atom.iat[jatm][2];
1492 } else if (atom.iat[jatm][1] == i)
1493 {
1494 katm = atom.iat[jatm][0];
1495 latm = atom.iat[jatm][2];
1496 } else if (atom.iat[jatm][2] == i)
1497 {
1498 katm = atom.iat[jatm][0];
1499 latm = atom.iat[jatm][1];
1500 }
1501 jbo = atom.tbo[jatm];
1502 kbo = atom.tbo[katm];
1503 lbo = atom.tbo[latm];
1504 adjn = FALSE;
1505 if (atom.atomnum[katm] == 7 && atom.atomnum[latm] == 7)
1506 {
1507 for (k=0; k < atom.nconnect[katm]; k++)
1508 {
1509 if (atom.bo[katm][k] == 2)
1510 adjn = TRUE;
1511 }
1512 for (k=0; k < atom.nconnect[latm]; k++)
1513 {
1514 if (atom.bo[latm][k] == 2)
1515 adjn = TRUE;
1516 }
1517 if (jbo == 4 && kbo == 3 && lbo == 3 && adjn == FALSE)
1518 {
1519 mmfftype = 56;
1520 goto L_10;
1521 }
1522 }
1523 if (atom.atomnum[katm] == 7)
1524 {
1525 jbo = atom.tbo[i];
1526 kbo = atom.tbo[katm];
1527 adjn = FALSE;
1528 for (k=0; k < atom.nconnect[katm]; k++)
1529 {
1530 if (atom.bo[katm][k] == 2)
1531 adjn = TRUE;
1532 }
1533 if (jbo == 4 && kbo == 3 && adjn == FALSE)
1534 {
1535 mmfftype = 55;
1536 goto L_10;
1537 }
1538 }
1539 if (atom.atomnum[latm] == 7)
1540 {
1541 jbo = atom.tbo[i];
1542 lbo = atom.tbo[latm];
1543 adjn = FALSE;
1544 for (k=0; k < atom.nconnect[latm]; k++)
1545 {
1546 if (atom.bo[latm][k] == 2)
1547 adjn = TRUE;
1548 }
1549 if (jbo == 4 && lbo == 3 && adjn == FALSE)
1550 {
1551 mmfftype = 55;
1552 goto L_10;
1553 }
1554 }
1555 }
1556 if (jjbo == 4) // c=n+
1557 {
1558 mmxtype = 41;
1559 for (j=0; j < atom.nconnect[i]; j++)
1560 {
1561 if (atom.atomnum[atom.iat[i][j]] == 8) // c=n+-o
1562 {
1563 katm = atom.iat[i][j];
1564 jjk = atom.nconnect[katm];
1565 if (jjk == 1)
1566 mmfftype = 67;
1567 else if (jjk == 2)
1568 mmfftype = 54;
1569 goto L_10;
1570 }
1571 }
1572 mmfftype = 54;
1573 goto L_10;
1574 }
1575 mmxtype = 37;
1576 mm3type = 37;
1577 mmfftype = 9;
1578 goto L_10;
1579 } // got here with not assignment check other side for mmff
1580 for (j=0; j < jji; j++)
1581 {
1582 katm = atom.iat[i][j];
1583 if (atom.atomnum[katm] == 16)
1584 {
1585 for (k=0; k < atom.nconnect[katm]; k++)
1586 {
1587 if (atom.iat[katm][k] != 0 && atom.iat[katm][k] != i && atom.bo[katm][k] == 2)
1588 {
1589 if (atom.atomnum[atom.iat[katm][k]] == 8)
1590 {
1591 mmfftype = 43;
1592 goto L_10;
1593 }
1594 }
1595 }
1596 }
1597 }
1598 goto L_10;
1599 }
1600 // goto here with only single bonds to nitrogen
1601 mmxtype = 8;
1602 mm3type = 8;
1603 mmfftype = 8;
1604 if (jji == 2) // divalent anionic N
1605 {
1606 for (j=0; j < jji; j++)
1607 {
1608 if (atom.mmx_type[atom.iat[i][j]] > 300) // attached metal
1609 {
1610 for (k=0; k < atom.nconnect[i]; k++)
1611 {
1612 if (atom.iat[i][k] != 0 && atom.iat[i][k] != atom.iat[i][j])
1613 {
1614 jatm = atom.iat[i][k];
1615 for (l=0; l < atom.nconnect[jatm]; l++)
1616 {
1617 if (atom.iat[jatm][l] != 0)
1618 {
1619 if (atom.bo[jatm][l] >= 2)
1620 {
1621 mmxtype = 9;
1622 goto L_10;
1623 }
1624 }
1625 }
1626 }
1627 }
1628 }
1629 }
1630 // mmxtype = 77;
1631 mmfftype = 62;
1632 goto L_10;
1633 }
1634 if (jji == 4 && jjbo == 4)
1635 {
1636 mmxtype = 41;
1637 mm3type = 39;
1638 mmfftype = 34;
1639 for (j=0; j < atom.nconnect[i]; j++)
1640 {
1641 if (atom.iat[i][j] != 0 && (atom.mmx_type[atom.iat[i][j]] >= 300))
1642 {
1643 mmxtype = 8;
1644 mm3type = 8;
1645 }
1646 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9)
1647 {
1648 if (atom.atomnum[atom.iat[i][j]] == 8)
1649 mmfftype = 68;
1650 }
1651 }
1652 goto L_10;
1653 }
1654 ndouble = 0;
1655 for (j=0; j < jji; j++)
1656 {
1657 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9)
1658 {
1659 katm = atom.iat[i][j];
1660 for (k=0; k < atom.nconnect[katm]; k++)
1661 {
1662 if (atom.iat[katm][k] != 0 && atom.bo[katm][k] == 2)
1663 ndouble++;
1664 if (atom.iat[katm][k] != 0 && atom.bo[katm][k] == 3)
1665 ndouble++;
1666 }
1667 }
1668 }
1669 if (ndouble >= 1)
1670 {
1671 mmxtype = 9;
1672 mm3type = 9;
1673 mmfftype = 8;
1674 for (j=0; j < jji; j++)
1675 {
1676 if (atom.iat[i][j] != 0 && atom.atomnum[atom.iat[i][j]] == 6)
1677 {
1678 jatm = atom.iat[i][j];
1679 jjk = atom.nconnect[jatm];
1680 if (jjk == 3)
1681 {
1682 if (atom.iat[jatm][0] == i)
1683 {
1684 if (atom.bo[jatm][1] == 2)
1685 {
1686 katm = atom.iat[jatm][1];
1687 latm = atom.iat[jatm][2];
1688 }else
1689 {
1690 latm = atom.iat[jatm][1];
1691 katm = atom.iat[jatm][2];
1692 }
1693 } else if (atom.iat[jatm][1] == i)
1694 {
1695 if (atom.bo[jatm][0] == 2)
1696 {
1697 katm = atom.iat[jatm][0];
1698 latm = atom.iat[jatm][2];
1699 }else
1700 {
1701 latm = atom.iat[jatm][0];
1702 katm = atom.iat[jatm][2];
1703 }
1704 }else if (atom.iat[jatm][2] == i)
1705 {
1706 if (atom.bo[jatm][0] == 2)
1707 {
1708 katm = atom.iat[jatm][0];
1709 latm = atom.iat[jatm][1];
1710 }else
1711 {
1712 latm = atom.iat[jatm][0];
1713 katm = atom.iat[jatm][1];
1714 }
1715 }
1716 if (atom.atomnum[katm] == 7 && atom.atomnum[latm] == 7)
1717 {
1718 jbo = atom.tbo[katm];
1719 kbo = atom.tbo[latm];
1720 adjn = FALSE;
1721 for(k=0; k < atom.nconnect[latm]; k++)
1722 {
1723 if (atom.bo[latm][k] == 2)
1724 adjn = TRUE;
1725 }
1726 if ( jbo == 4 && kbo == 3 && adjn == FALSE)
1727 {
1728 mmfftype =56;
1729 goto L_10;
1730 }
1731 }
1732 if (atom.atomnum[katm] == 7) // N-C=N+
1733 {
1734 jj_bo = atom.tbo[katm];
1735 noxide = FALSE;
1736 for (l=0; l < atom.nconnect[katm]; l++)
1737 {
1738 if (atom.atomnum[atom.iat[katm][l]] == 8)
1739 {
1740 latm = atom.iat[katm][l];
1741 jjk = atom.nconnect[latm];
1742 if (jjk == 1)
1743 noxide = TRUE;
1744 }
1745 }
1746 if (jj_bo == 4 && !(atom.flags[katm] & aromatic_mask && atom.flags[katm] & mask6) && noxide == FALSE) // N-C=N+
1747 {
1748 mmfftype = 55;
1749 goto L_10;
1750 }
1751 }
1752 }
1753 }
1754 if (atom.iat[i][j] != 0 && atom.atomnum[atom.iat[i][j]] == 7) // n-n=n
1755 {
1756 jatm = atom.iat[i][j];
1757 for (k=0; k < atom.nconnect[jatm]; k++)
1758 {
1759 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i)
1760 {
1761 if (atom.bo[jatm][k] == 2 && atom.atomnum[atom.iat[jatm][k]] == 7)
1762 {
1763 jbo = atom.tbo[jatm];
1764 katm = atom.iat[jatm][k];
1765 kbo = atom.tbo[katm];
1766 if (jbo == 3 && kbo == 3)
1767 {
1768 mmfftype = 10;
1769 goto L_10;
1770 }
1771 }
1772 }
1773 }
1774 }
1775
1776 }
1777 for(j=0; j < atom.nconnect[i]; j++)
1778 {
1779 if (atom.iat[i][j] != 0)
1780 {
1781 jatm = atom.iat[i][j];
1782 if (atom.atomnum[jatm] == 16) // sulfonamide - need to check this further
1783 {
1784 jjk = 0;
1785 for (k=0; k < atom.nconnect[jatm]; k++)
1786 {
1787 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] != 9)
1788 {
1789 if (atom.atomnum[atom.iat[jatm][k]] == 8 && atom.bo[jatm][k] == 2)
1790 jjk++;
1791 }
1792 }
1793 if (jjk >= 2)
1794 {
1795 mmxtype = 9;
1796 mm3type = 155;
1797 mmfftype = 43;
1798 goto L_10;
1799 }
1800 }
1801 if (atom.atomnum[jatm] == 5) // boron
1802 {
1803 mmxtype = 9;
1804 mm3type = 9;
1805 mmfftype = 9;
1806 goto L_10;
1807 }
1808 }
1809 }
1810 for(j=0; j < atom.nconnect[i]; j++)
1811 {
1812 if (atom.iat[i][j] != 0)
1813 {
1814 jatm = atom.iat[i][j];
1815 for (k=0; k < atom.nconnect[jatm]; k++)
1816 {
1817 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] == 2)
1818 {
1819 if (atom.atomnum[jatm] == 6 && atom.atomnum[atom.iat[jatm][k]] == 8) // amide
1820 {
1821 mmxtype = 9;
1822 mm3type = 9;
1823 mmfftype = 10;
1824 goto L_10;
1825 }
1826 if (atom.atomnum[jatm] == 6 && atom.atomnum[atom.iat[jatm][k]] == 16) // thioamide
1827 {
1828 mmxtype = 9;
1829 mm3type = 9;
1830 mmfftype = 10;
1831 goto L_10;
1832 }
1833 }
1834 }
1835 }
1836 }
1837 if (jji == 3 && ndouble >= 1 ) // eneamine
1838 {
1839 for (j=0; j < jji; j++)
1840 {
1841 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9)
1842 {
1843 if (atom.atomnum[atom.iat[i][j]] == 6)
1844 {
1845 jatm = atom.iat[i][j];
1846 for (k=0; k < atom.nconnect[jatm]; k++)
1847 {
1848 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] == 2)
1849 {
1850 mmxtype = 9;
1851 mmfftype = 40;
1852 goto L_10;
1853 }
1854 }
1855 }
1856 }
1857 }
1858 }
1859
1860 for(j=0; j < jji; j++)
1861 {
1862 if (atom.iat[i][j] != 0)
1863 {
1864 jatm = atom.iat[i][j];
1865 for (k=0; k < atom.nconnect[jatm]; k++)
1866 {
1867 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] == 2)
1868 {
1869 if (atom.atomnum[jatm] == 15) // n-p=x
1870 {
1871 jjk = atom.nconnect[jatm];
1872 if (jjk > 3)
1873 {
1874 mmxtype = 8;
1875 mm3type = 8;
1876 mmfftype = 8;
1877 goto L_10;
1878 }
1879 }
1880 }
1881 }
1882 }
1883 }
1884
1885 }
1886 // end of ndouble test
1887 for (j=0; j < jji; j++)
1888 {
1889 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9)
1890 {
1891 if (atom.atomnum[atom.iat[i][j]] == 6) // carbon
1892 {
1893 for (k=0; k < atom.nconnect[atom.iat[i][j]]; k++)
1894 {
1895 if (atom.iat[atom.iat[i][j]][k] != 0 && atom.iat[atom.iat[i][j]][k] != i)
1896 {
1897 if (atom.bo[atom.iat[i][j]][k] == 3 && atom.atomnum[atom.iat[atom.iat[i][j]][k]] == 7)
1898 {
1899 mmfftype = 43;
1900 goto L_10;
1901 }
1902 }
1903 }
1904 } else if (atom.atomnum[atom.iat[i][j]] == 7) // nitrogen - n-n bond - n-n-c=o
1905 {
1906 jatm = atom.iat[i][j];
1907 for (k=0; k < atom.nconnect[jatm]; k++)
1908 {
1909 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i)
1910 {
1911 katm = atom.iat[jatm][k];
1912 if (atom.atomnum[katm] == 6)
1913 {
1914 for (l=0; l < atom.nconnect[katm]; l++)
1915 {
1916 if (atom.iat[katm][l] != 0 && atom.iat[katm][l] != jatm)
1917 {
1918 if (atom.atomnum[atom.iat[katm][l]] == 8 && atom.bo[katm][l] == 2)
1919 {
1920 mmxtype = 9;
1921 goto L_10;
1922 }
1923 }
1924 }
1925 }
1926 }
1927 }
1928 }
1929 }
1930 }
1931 if (is_cyclo5(i,array) && atom.flags[i] & aromatic_mask) // heterocycle
1932 {
1933 for (j=1; j < 5; j++)
1934 {
1935 if (atom.atomnum[array[j]] != 6)
1936 {
1937 mmxtype = 8;
1938 mm3type = 8;
1939 mmfftype = 79;
1940 goto L_10;
1941 }
1942 }
1943 }
1944 for (j=0; j < jji; j++) // guanadinium
1945 {
1946 if (atom.iat[i][j] != 0 && atom.atomnum[atom.iat[i][j]] == 6)
1947 {
1948 jatm = atom.iat[i][j];
1949 jjk = atom.nconnect[jatm];
1950 if (jjk == 3 && (atom.atomnum[atom.iat[jatm][0]] == 7 &&
1951 atom.atomnum[atom.iat[jatm][1]] == 7 && atom.atomnum[atom.iat[jatm][2]] == 7) )
1952 {
1953 mmfftype = 56;
1954 goto L_10;
1955 }
1956 }
1957 }
1958 // mmxtypes that should not be changed - set by user
1959 if (atom.mmx_type[i] == 41) // N+
1960 {
1961 mmxtype = 41;
1962 mm3type = 39;
1963 mmfftype = atom.mmff_type[i];
1964 if (mmfftype == 0 && (mmfftype != 34 || mmfftype != 54 || mmfftype != 55 || mmfftype != 56
1965 || mmfftype != 58 || mmfftype != 69 || mmfftype != 80 || mmfftype != 81) )
1966 mmfftype = 34;
1967 goto L_10;
1968 } else if (atom.mmx_type[i] == 55) // TS Nitrogen
1969 {
1970 mmxtype = 55;
1971 mm3type = 0;
1972 mmfftype = 0;
1973 goto L_10;
1974 }
1975 goto L_10;
1976 } else if (atom.atomnum[i] == 8) // oxygen
1977 {
1978 /* ======================== Oxygen ==================================== */
1979 if (atom.mmx_type[i] == 53) // TS Oxygen
1980 {
1981 mmxtype = 53;
1982 mm3type = 0;
1983 mmfftype = 0;
1984 goto L_10;
1985 }
1986 jji = atom.nconnect[i];
1987 jjbo = atom.tbo[i];
1988 if (jjbo == 3) // o+
1989 {
1990 mmxtype = 46;
1991 mmfftype = 49;
1992 mm3type = 0;
1993 for (j=0; j < jji; j++)
1994 {
1995 if (atom.iat[i][j] != 0 && atom.bo[i][j] == 2)
1996 {
1997 mmfftype = 51;
1998 goto L_10;
1999 }
2000 }
2001 goto L_10;
2002 }
2003 mmxtype = atom.mmx_type[i];
2004 if (mmxtype == 66)
2005 {
2006 mm3type = 47;
2007 mmfftype = 32;
2008 gafftype = 14;
2009 }
2010 if (mmxtype == 6 || mmxtype == 7 || mmxtype == 66)
2011 {
2012 for (j=0; j < jji; j++)
2013 {
2014 if (atom.bo[i][j] == 2) // x=0
2015 {
2016 mmxtype = 7;
2017 mm3type = 7;
2018 mmfftype = 7;
2019 gafftype = 14;
2020 jatm = atom.iat[i][j];
2021 if (atom.atomnum[jatm] == 15) // p=o
2022 {
2023 for (k=0; k < atom.nconnect[jatm]; k++)
2024 {
2025 jjk = 0;
2026 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i && atom.atomnum[atom.iat[jatm][k]] == 8)
2027 {
2028 katm = atom.iat[jatm][k];
2029 jjk = atom.nconnect[katm];
2030 if (jjk == 1 && atom.mmx_type[katm] == 42)
2031 {
2032 mmxtype = 66;
2033 mm3type = 47;
2034 }
2035 }
2036 }
2037 mmfftype = 32;
2038 goto L_10;
2039 }
2040 if (atom.atomnum[jatm] == 16) // s=o
2041 {
2042 for (k=0; k < atom.nconnect[jatm]; k++)
2043 {
2044 jjk = 0;
2045 jj_bo = 0;
2046 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i && atom.atomnum[atom.iat[jatm][k]] == 8)
2047 {
2048 katm = atom.iat[jatm][k];
2049 jjk = atom.nconnect[katm];
2050 jj_bo = atom.tbo[katm];
2051 if (jjk == 1 && jj_bo == 1 && atom.mmx_type[katm] == 42)
2052 {
2053 mmxtype = 66;
2054 mm3type = 47;
2055 mmfftype = 32;
2056 goto L_10;
2057 }
2058 }
2059 }
2060 }
2061 if (atom.atomnum[jatm] == 6) // c=o
2062 {
2063 mmfftype = 7;
2064 for (k=0; k < atom.nconnect[jatm]; k++)
2065 {
2066 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i && atom.bo[jatm][k] != 9)
2067 {
2068 if (atom.atomnum[atom.iat[jatm][k]] == 8)
2069 {
2070 katm = atom.iat[jatm][k];
2071 jjk = atom.nconnect[katm];
2072 if (jjk == 1) // carboxylate
2073 {
2074 mmxtype = 66;
2075 mm3type = 47;
2076 mmfftype = 32;
2077 gafftype = 14;
2078 goto L_10;
2079 }
2080 if (jjk == 2) // ester and acids
2081 {
2082 if ( atom.atomnum[atom.iat[katm][0]] != 1 && atom.atomnum[atom.iat[katm][1]] != 1) // ester
2083 {
2084 mm3type = 78;
2085 goto L_10;
2086 } else if ( atom.atomnum[atom.iat[katm][0]] == 1 || atom.atomnum[atom.iat[katm][1]] == 1) // acid
2087 {
2088 mm3type = 77;
2089 goto L_10;
2090 }
2091 }
2092 }
2093 }
2094 }
2095 for (k=0; k < atom.nconnect[jatm]; k++)
2096 {
2097 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i && atom.bo[jatm][k] != 9)
2098 {
2099 if (atom.atomnum[atom.iat[jatm][k]] == 7) // amide
2100 {
2101 mm3type = 7; // should be 79 but database only has 58-79
2102 goto L_10;
2103 }
2104 }
2105 }
2106 for (k=0; k < atom.nconnect[jatm]; k++)
2107 {
2108 if (atom.iat[jatm][k] != 0 && atom.iat[jatm][k] != i && atom.bo[jatm][k] != 9)
2109 {
2110 if (atom.atomnum[atom.iat[jatm][k]] == 6) // vinyl ketone
2111 {
2112 katm = atom.iat[jatm][k];
2113 for (l=0; l < atom.nconnect[katm]; l++)
2114 {
2115 if (atom.iat[katm][l] != 0 && atom.bo[katm][l] == 2)
2116 {
2117 mm3type = 81;
2118 goto L_10;
2119 }
2120 }
2121 }
2122 }
2123 }
2124 }
2125
2126 for (k=0; k < atom.nconnect[jatm]; k++)
2127 {
2128 if (atom.atomnum[atom.iat[jatm][k]] == 8 && atom.iat[jatm][k] != i && atom.bo[jatm][k] == 1)
2129 {
2130 latm = atom.iat[jatm][k];
2131 jjk = atom.nconnect[latm];
2132 if (jjk == 1)
2133 {
2134 mmxtype = 66;
2135 mm3type = 47;
2136 mmfftype = 32;
2137 gafftype = 14;
2138 goto L_10;
2139 }
2140 } else if (atom.atomnum[atom.iat[jatm][k]] == 8 && atom.iat[jatm][k] != i && atom.bo[jatm][k] == 2)
2141 {
2142 mmfftype = 32;
2143 goto L_10;
2144 } else if (atom.atomnum[atom.iat[jatm][k]] == 16 && atom.iat[jatm][k] != i && atom.bo[jatm][k] == 2)
2145 {
2146 jjk = 0;
2147 latm = atom.iat[jatm][k];
2148 jjk = atom.nconnect[latm];
2149 if (jjk == 1)
2150 {
2151 mmxtype = 66;
2152 mm3type = 47;
2153 }
2154 mmfftype = 32;
2155 goto L_10;
2156 } else if (atom.atomnum[atom.iat[jatm][k]] == 7 && atom.iat[jatm][k] != i && atom.bo[jatm][k] == 2)
2157 {
2158 mmfftype = 32;
2159 goto L_10;
2160 }
2161 }
2162 goto L_10;
2163 } else if (atom.bo[i][j] == 3)
2164 {
2165 mmxtype = 46;
2166 mmfftype = 53;
2167 goto L_10;
2168 }
2169 } // got here with only single bonds - don't reset 66
2170 jji = atom.nconnect[i];
2171 nh = 0;
2172 gafftype = 14;
2173 for (j=0; j < jji; j++)
2174 {
2175 if (atom.atomnum[atom.iat[i][j]] == 1)
2176 nh++;
2177 }
2178 if (jji == 1) // only one bond
2179 {
2180 if (atom.atomnum[atom.iat[i][0]] == 6)
2181 {
2182 jatm = atom.iat[i][0];
2183 for (j=0; j < atom.nconnect[jatm]; j++)
2184 {
2185 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
2186 {
2187 if (atom.atomnum[atom.iat[jatm][j]] == 6) // c=c
2188 {
2189 mmfftype = 35;
2190 goto L_10;
2191 }
2192 }
2193 }
2194 }
2195 if (atom.atomnum[atom.iat[i][0]] == 7) // n-o
2196 {
2197 mmxtype = 66;
2198 mm3type = 69;
2199 mmfftype = 32;
2200 goto L_10;
2201 }
2202 if (atom.atomnum[atom.iat[i][0]] == 15 || atom.atomnum[atom.iat[i][0]] == 16) // p-o
2203 {
2204 mmxtype = 66;
2205 mm3type = 7;
2206 mmfftype = 32;
2207 goto L_10;
2208 }
2209
2210 }
2211 // test for epoxides
2212 if (is_ring31(i))
2213 {
2214 gafftype = 16;
2215 mm3type = 49;
2216 mmfftype = 6;
2217 goto L_10;
2218 }
2219 if (is_ring51(i))
2220 {
2221 gafftype = 16;
2222 if (atom.flags[i] & aromatic_mask)
2223 {
2224 mmfftype = 59;
2225 mm3type = 41;
2226 goto L_10;
2227 }
2228 }
2229 if (jji == 2)
2230 {
2231 if (nh == 2) // mmff water
2232 {
2233 mmfftype = 70;
2234 goto L_10;
2235 } else if (nh == 1) // ROH and RCOOH
2236 {
2237 mm3type = 6;
2238 mmfftype = 6;
2239 gafftype = 15;
2240 jatm = atom.iat[i][0];
2241 for (j=0; j < atom.nconnect[jatm]; j++)
2242 {
2243 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
2244 {
2245 if (atom.atomnum[atom.iat[jatm][j]] == 8)
2246 {
2247 mm3type = 75;
2248 break;
2249 }
2250 }
2251 }
2252 goto L_10;
2253 } else
2254 {
2255 mmfftype = 6;
2256 // goto L_10;
2257 }
2258 jatm = atom.iat[i][0];
2259 jtype = 0;
2260 katm = atom.iat[i][1];
2261 ktype = 0;
2262 for (j=0; j < atom.nconnect[jatm]; j++)
2263 {
2264 if (atom.iat[jatm][j] != 0 && atom.bo[jatm][j] == 2)
2265 {
2266 if (atom.atomnum[atom.iat[jatm][j]] == 8)
2267 {
2268 jtype = 3;
2269 break;
2270 } else if (atom.atomnum[atom.iat[jatm][j]] == 6)
2271 {
2272 jtype = 2;
2273 break;
2274 }
2275 }
2276 }
2277 for (j=0; j < atom.nconnect[katm]; j++)
2278 {
2279 if (atom.iat[katm][j] != 0 && atom.bo[katm][j] == 2)
2280 {
2281 if (atom.atomnum[atom.iat[katm][j]] == 8)
2282 {
2283 ktype = 3;
2284 break;
2285 }else if (atom.atomnum[atom.iat[katm][j]] == 6)
2286 {
2287 ktype = 2;
2288 break;
2289 }
2290 }
2291 }
2292 if (jtype == 3 && ktype == 3) // anhydrides
2293 mm3type = 148;
2294 else if (jtype == 3 || ktype == 3) // carboxyl & ester
2295 mm3type = 75;
2296 else if (jtype == 2 && ktype == 2) // furan type ??
2297 mm3type = 41;
2298 else if (jtype == 2 || ktype == 2) // vinyl type ??
2299 mm3type = 41;
2300 else
2301 mm3type = 6;
2302 goto L_10;
2303 }
2304 if (mmxtype != 66)
2305 {
2306 mmxtype = 6;
2307 mm3type = 6;
2308 mmfftype = 6;
2309 gafftype = 16;
2310 }
2311 goto L_10;
2312 } else if (mmxtype == 42)
2313 {
2314 mmfftype = 32;
2315 gafftype = 14;
2316 for (j=0; j < atom.nconnect[i]; j++)
2317 {
2318 if (atom.atomnum[atom.iat[i][j]] == 16 || atom.atomnum[atom.iat[i][j]] == 15)
2319 {
2320 mmxtype = 66;
2321 mm3type = 47;
2322 mmfftype = 32;
2323 goto L_10;
2324 }
2325 if (atom.atomnum[atom.iat[i][j]] == 7)
2326 {
2327 mmxtype = 42;
2328 mm3type = 69;
2329 jatm = atom.iat[i][j];
2330 jj_bo = atom.tbo[jatm];
2331 if (jj_bo >= 4)
2332 {
2333 mmxtype = 66;
2334 mm3type = 69;
2335 mmfftype = 32;
2336 } else
2337 mmfftype = 35;
2338 goto L_10;
2339 }
2340 if (atom.atomnum[atom.iat[i][j]] == 6 )
2341 {
2342 jatm = atom.iat[i][j];
2343 mmfftype = 35;
2344 for (k=0; k < atom.nconnect[jatm]; k++)
2345 {
2346 if (atom.iat[jatm][k] != i && atom.atomnum[atom.iat[jatm][k]] == 8 && atom.bo[jatm][k] == 2)
2347 {
2348 mmxtype = 66;
2349 mm3type = 47;
2350 mmfftype = 32;
2351 goto L_10;
2352 }
2353 }
2354 }
2355 }
2356 goto L_10;
2357 } else
2358 goto L_10;
2359 } else if (atom.atomnum[i] == 13) // aluminum
2360 {
2361 mmxtype = 44;
2362 mm3type = 0;
2363 jji = atom.nconnect[i];
2364 if (jji == 4)
2365 mmxtype = 58;
2366 goto L_10;
2367 } else if (atom.atomnum[i] == 15) // phosphorus
2368 {
2369 mmxtype = 25;
2370 mm3type = 25;
2371 mmfftype = 25;
2372 jji = atom.nconnect[i];
2373 for (j=0; j < atom.nconnect[i]; j++)
2374 {
2375 if (atom.atomnum[atom.iat[i][j]] == 6 && atom.bo[i][j] == 2)
2376 {
2377 mmxtype = 67;
2378 mmfftype = 75;
2379 goto L_10;
2380 }
2381 if (atom.atomnum[atom.iat[i][j]] == 8 && atom.bo[i][j] == 2)
2382 mm3type = 153;
2383 }
2384 if (jji >= 5)
2385 {
2386 mmxtype = 47;
2387 mm3type = 60;
2388 }else if (jji == 3)
2389 {
2390 mmxtype = 25;
2391 mmfftype = 26;
2392 }
2393 goto L_10;
2394 } else if (atom.atomnum[i] == 16) // sulfur
2395 {
2396 mmxtype = 15;
2397 mm3type = 15;
2398 mmfftype = 15;
2399 jji = atom.nconnect[i];
2400 ndouble = 0;
2401 for (j=0; j < jji; j++)
2402 {
2403 if (atom.iat[i][j] != 0 && atom.bo[i][j] != 9 && atom.mmx_type[atom.iat[i][j]] != 20 &&
2404 (atom.mmx_type[atom.iat[i][j]] < 300))
2405 {
2406 if (atom.bo[i][j] == 2)
2407 ndouble++;
2408 }
2409 }
2410 if (jji == 1 && ndouble == 1)
2411 {
2412 if (atom.atomnum[atom.iat[i][0]] == 16) // s=s-
2413 {
2414 mmfftype = 72;
2415 goto L_10;
2416 }
2417 if (atom.atomnum[atom.iat[i][0]] == 6) // s=c
2418 {
2419 mmxtype = 38;
2420 mm3type = 74;
2421 if (atom.bo[i][0] == 2)
2422 {
2423 mmfftype = 16;
2424 jatm = atom.iat[i][0];
2425 for (k=0; k < atom.nconnect[jatm]; k++)
2426 {
2427 if (atom.iat[jatm][k] != 0 && atom.bo[jatm][k] != 9)
2428 {
2429 if (atom.atomnum[atom.iat[jatm][k]] == 16 && atom.iat[jatm][k] != i)
2430 {
2431 katm = atom.iat[jatm][k];
2432 jj_bo = atom.tbo[katm];
2433 if (jj_bo == 1) // s=c-s i-jatm-katm
2434 {
2435 mmfftype = 72;
2436 goto L_10;
2437 }
2438 }
2439 }
2440 }
2441 goto L_10;
2442 }else if (atom.bo[i][0] == 1)
2443 {
2444 mmfftype = 72;
2445 goto L_10;
2446 }
2447 goto L_10;
2448 }
2449 if (atom.atomnum[atom.iat[i][0]] == 15 ) // s=p
2450 {
2451 mmxtype = 38;
2452 mm3type = 74;
2453 mmfftype = 72;
2454 goto L_10;
2455 }
2456 }
2457 if (jji == 2)
2458 {
2459 mmxtype = 15;
2460 mm3type = 15;
2461 mmfftype = 15;
2462 if (is_ring51(i)) // thiophene
2463 {
2464 if (atom.flags[i] & aromatic_mask)
2465 {
2466 mmfftype = 44;
2467 mm3type = 42;
2468 goto L_10;
2469 }
2470 }
2471 if (ndouble == 2)
2472 mmfftype = 74;
2473 goto L_10;
2474 }
2475 if (jji == 3)
2476 {
2477 mmxtype = 17;
2478 mm3type = 17;
2479 mmfftype = 17;
2480 if (ndouble == 2)
2481 mmfftype = 73;
2482 if (ndouble == 3)
2483 mmfftype = 18;
2484 goto L_10;
2485 }
2486 if (jji == 4)
2487 {
2488 mmxtype = 18;
2489 mm3type = 18;
2490 for (j=0; j < jji; j++)
2491 {
2492 if (atom.atomnum[atom.iat[i][j]] == 7 ) // sulfamide
2493 mm3type = 154;
2494 }
2495 mmfftype = 18;
2496 goto L_10;
2497 }
2498 goto L_10;
2499 } else if (atom.atomnum[i] == 17) // chlorine
2500 {
2501 mm3type = 12;
2502 mmxtype = 12;
2503 mmfftype = 12;
2504 gafftype = 33;
2505 jji = atom.nconnect[i];
2506 if (jji == 2)
2507 mmxtype = 74; // bridging chlorine
2508 else if (jji == 4) // perchlorate
2509 mmfftype = 77;
2510 goto L_10;
2511 } else if (atom.atomnum[i] == 34) // selenium
2512 {
2513 mm3type = 34;
2514 mmxtype = 34;
2515 for (j=0; j < jji; j++)
2516 {
2517 if (atom.bo[i][j] == 2)
2518 mmxtype = 39;
2519 }
2520 goto L_10;
2521 } else if (atom.atomnum[i] == 9) // Florine
2522 {
2523 mmxtype = 11;
2524 mm3type = 11;
2525 mmfftype = 11;
2526 gafftype = 32;
2527 goto L_10;
2528 } else if (atom.atomnum[i] == 35) // Bromine
2529 {
2530 mmxtype = 13;
2531 mm3type = 13;
2532 mmfftype = 13;
2533 gafftype = 34;
2534 goto L_10;
2535 } else if (atom.atomnum[i] == 53) // Iodine
2536 {
2537 if (atom.mmx_type[i] == 54) // Sn2 I
2538 {
2539 mmxtype = 54;
2540 mm3type = 0;
2541 mmfftype = 0;
2542 goto L_10;
2543 }
2544 mmxtype = 14;
2545 mm3type = 14;
2546 mmfftype = 14;
2547 gafftype = 35;
2548 goto L_10;
2549 } else if (atom.atomnum[i] == 14 ) // Silicon
2550 {
2551 mmxtype = 19;
2552 mm3type = 19;
2553 mmfftype = 19;
2554 goto L_10;
2555 } else if (atom.atomnum[i] == 50 ) // Tin
2556 {
2557 mmxtype = 32;
2558 mm3type = 32;
2559 mmfftype = 0;
2560 goto L_10;
2561 } else if (mmxtype >= 300) // metal atom - try to assign MMFF type
2562 {
2563 mm3type = mmxtype;
2564 if (mmfftype == 0)
2565 mmfftype = mmxtype;
2566 }
2567 L_10:
2568 set_atomtype(i,mmxtype,mm3type,mmfftype);
2569 L_20:
2570 continue; // do nothing
2571 }
2572 set_atomtypes(get_field());
2573 }
2574 }
2575 /* --------------------------------------------------------- */
2576 /* ================================================== */
2577 // look for ionic types input with bonds and adjust to make ionic
2578 //
2579 void adjust_mmfftypes()
2580 {
2581 int i,j, iatt,jji;
2582
2583 for (i=1; i <= natom; i++)
2584 {
2585 jji = atom.nconnect[i];
2586 if (atom.mmff_type[i] == 89 ) // F-
2587 {
2588 for (j=0; j < jji; j++)
2589 {
2590 if (atom.iat[i][j] != 0)
2591 deletebond(i,atom.iat[i][j]);
2592 }
2593 } else if (atom.mmff_type[i] == 90 ) // CL-
2594 {
2595 for (j=0; j < jji; j++)
2596 {
2597 if (atom.iat[i][j] != 0)
2598 deletebond(i,atom.iat[i][j]);
2599 }
2600 } else if (atom.mmff_type[i] == 91 ) // Br-
2601 {
2602 for (j=0; j < jji; j++)
2603 {
2604 if (atom.iat[i][j] != 0)
2605 deletebond(i,atom.iat[i][j]);
2606 }
2607 } else if (atom.mmff_type[i] == 92 ) // Li+
2608 {
2609 for (j=0; j < jji; j++)
2610 {
2611 if (atom.iat[i][j] != 0)
2612 {
2613 iatt = atom.iat[i][j];
2614 deletebond(i,iatt);
2615 if (atom.atomnum[iatt] == 8)
2616 set_atomtype(iatt,42,0,92);
2617 }
2618 }
2619 } else if (atom.mmff_type[i] == 93 ) // Na+
2620 {
2621 for (j=0; j < jji; j++)
2622 {
2623 if (atom.iat[i][j] != 0)
2624 {
2625 iatt = atom.iat[i][j];
2626 deletebond(i,iatt);
2627 if (atom.atomnum[iatt] == 8)
2628 set_atomtype(iatt,42,0,93);
2629 }
2630 }
2631 } else if (atom.mmff_type[i] == 94 ) // K+
2632 {
2633 for (j=0; j < jji; j++)
2634 {
2635 if (atom.iat[i][j] != 0)
2636 {
2637 iatt = atom.iat[i][j];
2638 deletebond(i,iatt);
2639 if (atom.atomnum[iatt] == 8)
2640 set_atomtype(iatt,42,0,94);
2641 }
2642 }
2643 } else if (atom.mmff_type[i] == 95 ) // Zn+2
2644 {
2645 for (j=0; j < jji; j++)
2646 {
2647 if (atom.iat[i][j] != 0)
2648 {
2649 iatt = atom.iat[i][j];
2650 deletebond(i,iatt);
2651 if (atom.atomnum[iatt] == 8)
2652 set_atomtype(iatt,42,0,95);
2653 }
2654 }
2655 } else if (atom.mmff_type[i] == 96 ) // Ca+2
2656 {
2657 for (j=0; j < jji; j++)
2658 {
2659 if (atom.iat[i][j] != 0)
2660 {
2661 iatt = atom.iat[i][j];
2662 deletebond(i,iatt);
2663 if (atom.atomnum[iatt] == 8)
2664 set_atomtype(iatt,42,0,96);
2665 }
2666 }
2667 }
2668 }
2669 }
2670 // ==============================
2671 // coung number of electron withdrawing groups attached to carbon
2672 int count_ewg(int jatm)
2673 {
2674 int i, newg;
2675
2676 newg = 0;
2677 for (i=0; i < atom.nconnect[jatm]; i++)
2678 {
2679 if (atom.atomnum[jatm] == 7 || atom.atomnum[jatm] == 8 || atom.atomnum[jatm] == 15 || atom.atomnum[jatm] == 16)
2680 newg++;
2681 if (atom.atomnum[jatm] == 9 || atom.atomnum[jatm] == 17 || atom.atomnum[jatm] == 35 || atom.atomnum[jatm] == 53)
2682 newg++;
2683 }
2684 return (newg);
2685 }
2686