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