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