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