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