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