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