ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/smi23d/src/mengine/type_mmx.c
Revision: 3
Committed: Mon Jun 9 21:38:26 2008 UTC (11 years, 4 months ago) by tjod
File size: 160547 byte(s)
Log Message:
test

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