ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/freemol/trunk/src/mengine/src/rings.c
Revision: 102
Committed: Tue Jan 20 18:02:33 2009 UTC (12 years, 5 months ago) by gilbertke
File size: 27128 byte(s)
Log Message:
combine rings and srings to eliminate duplication
Line File contents
1 #define EXTERN extern
2
3 #include "pcwin.h"
4 #include "pcmod.h"
5 #include "rings.h"
6
7
8 int isbond(int, int);
9 int is_ring31(int);
10 int is_ring41(int);
11 int is_ring42(int,int);
12 int is_ring43(int, int, int);
13 int is_ring44(int *);
14 int is_ring51(int);
15 int is_ring52(int, int);
16 int is_ring53(int, int, int);
17 int is_ring54(int, int, int, int);
18 int is_ring55(int *);
19 int is_ring61(int);
20 int is_ring62(int, int);
21 int is_ring63(int,int,int);
22 int is_ring66(int *);
23 int is_cyclo5(int, int *);
24 void ksort(int, int *);
25 void message_alert(char *, char *);
26 int is_cyclo6(int, int *);
27 int find_rsize(int, int);
28 void get_rsize(int,int,int,int *);
29 int aromatic_5(int *);
30 int aromatic_6(int *);
31
32 /* --------------------------------------------------------- */
33 // iatom is atom number to search on
34 // isize = ring size
35 // num = number of ring if more than one ring containing atom iatom
36 // array = array of ring atoms
37 //
38 void get_rsize(int iatom, int isize, int num, int *array)
39 {
40 int i, j, k, icount;
41 icount = -1;
42
43 if (isize == 3)
44 {
45 for (i=0; i < rings.nring3; i++)
46 {
47 for (j=0; j < 3; j++)
48 {
49 if (iatom == rings.r13[i][j])
50 icount++;
51 if (icount == num)
52 {
53 for (k=0; k < isize; k++)
54 array[k] = rings.r13[i][k];
55 return;
56 }
57 }
58 }
59 } else if (isize == 4)
60 {
61 for (i=0; i < rings.nring4; i++)
62 {
63 for (j=0; j < 4; j++)
64 {
65 if (iatom == rings.r14[i][j])
66 icount++;
67 if (icount == num)
68 {
69 for (k=0; k < isize; k++)
70 array[k] = rings.r14[i][k];
71 return;
72 }
73 }
74 }
75 } else if (isize == 5)
76 {
77 for (i=0; i < rings.nring5; i++)
78 {
79 for (j=0; j < 5; j++)
80 {
81 if (iatom == rings.r15[i][j])
82 icount++;
83 if (icount == num)
84 {
85 for (k=0; k < isize; k++)
86 array[k] = rings.r15[i][k];
87 return;
88 }
89 }
90 }
91 } else if (isize == 6)
92 {
93 for (i=0; i < rings.nring6; i++)
94 {
95 for (j=0; j < 6; j++)
96 {
97 if (iatom == rings.r16[i][j])
98 icount++;
99 if (icount == num)
100 {
101 for (k=0; k < isize; k++)
102 array[k] = rings.r16[i][k];
103 return;
104 }
105 }
106 }
107 }
108 }
109 /* --------------------------------------------------------- */
110 int find_rsize(int isize,int iatom)
111 {
112 int i, j, icount;
113
114 icount = 0;
115 if (isize == 3)
116 {
117 for (i=0; i < rings.nring3; i++)
118 {
119 for(j=0; j < 3; j++)
120 {
121 if (rings.r13[i][j] == iatom)
122 icount++;
123 }
124 }
125 return(icount);
126 }else if (isize == 4)
127 {
128 for (i=0; i < rings.nring4; i++)
129 {
130 for(j=0; j < 4; j++)
131 {
132 if (rings.r14[i][j] == iatom)
133 icount++;
134 }
135 }
136 return(icount);
137 }else if (isize == 5)
138 {
139 for (i=0; i < rings.nring5; i++)
140 {
141 for(j=0; j < 5; j++)
142 {
143 if (rings.r15[i][j] == iatom)
144 icount++;
145 }
146 }
147 return(icount);
148 }else if (isize == 6)
149 {
150 for (i=0; i < rings.nring6; i++)
151 {
152 for(j=0; j < 6; j++)
153 {
154 if (rings.r16[i][j] == iatom)
155 icount++;
156 }
157 }
158 return(icount);
159 }
160 return(icount);
161 }
162 // =======================
163 int is_ring31(int ia)
164 {
165 int i,j;
166
167 for (i=0; i < rings.nring3; i++)
168 {
169 for (j=0; j < 3; j++)
170 {
171 if (ia == rings.r13[i][j])
172 {
173 return(TRUE);
174 }
175 }
176 }
177 return FALSE;
178 }
179 /* ============================ */
180 int is_ring41(int ia)
181 {
182 int i,j, found;
183
184 found = FALSE;
185 for (i=0; i < rings.nring4; i++)
186 {
187 for (j=0; j < 4; j++)
188 {
189 if (ia == rings.r14[i][j])
190 {
191 found = TRUE;
192 return (found);
193 }
194 }
195 }
196 return (found);
197 }
198 /* -------------------------------------------------------- */
199 int is_ring42(int ia, int ib)
200 {
201 int i,j, k, itmp, jtmp;
202 if (ia < ib )
203 {
204 itmp = ia;
205 jtmp = ib;
206 }else
207 {
208 itmp = ib;
209 jtmp = ia;
210 }
211 for (i=0; i < rings.nring4; i++)
212 {
213 for (j = 0; j < 3; j++)
214 {
215 if ( itmp == rings.r14[i][j])
216 {
217 for (k=j+1; k < 4; k++)
218 {
219 if (jtmp == rings.r14[i][k])
220 return(TRUE);
221 }
222 }
223 }
224 }
225 return(FALSE);
226 }
227 /* -------------------------------------------------------- */
228 int is_ring43(int ia, int ib, int ic)
229 {
230 int i, found;
231 int array[5];
232
233 found = FALSE;
234 array[0] = ia;
235 array[1] = ib;
236 array[2] = ic;
237 ksort(3,array);
238 for (i=0; i < rings.nring4; i++)
239 {
240 if ( array[0] == rings.r14[i][0] && rings.r14[i][1] == array[1] && rings.r14[i][2] == array[2])
241 {
242 found = TRUE;
243 return(found);
244 }
245 if ( rings.r14[i][0] == array[0] && rings.r14[i][1] == array[1] && rings.r14[i][3] == array[2])
246 {
247 found = TRUE;
248 return(found);
249 }
250 if ( rings.r14[i][0] == array[0] && rings.r14[i][2] == array[1] && rings.r14[i][3] == array[2])
251 {
252 found = TRUE;
253 return(found);
254 }
255 if ( rings.r14[i][1] == array[0] && rings.r14[i][2] == array[1] && rings.r14[i][3] == array[2])
256 {
257 found = TRUE;
258 return(found);
259 }
260 }
261 return(found);
262 }
263 /* -------------------------------------------------------- */
264 int is_ring44(int *array)
265 {
266 int i;
267 for (i=0; i < rings.nring4; i++)
268 {
269 if (array[0] == rings.r14[i][0] && array[1] == rings.r14[i][1] &&
270 array[2] == rings.r14[i][2] && array[3] == rings.r14[i][3])
271 return(TRUE);
272 }
273 return FALSE;
274 }
275 /* -------------------------------------------------------- */
276 int is_ring51(int ia)
277 {
278 int i,j;
279
280 for(i=0; i < rings.nring5; i++)
281 {
282 for (j=0; j < 5; j++)
283 {
284 if (rings.r15[i][j] == ia)
285 {
286 return(TRUE);
287 }
288 }
289 }
290 return(FALSE);
291 }
292 // ======================================
293 int is_cyclo5(int ia, int *array)
294 {
295 int i,j;
296
297 for(i=0; i < rings.nring5; i++)
298 {
299 for (j=0; j < 5; j++)
300 {
301 if (rings.r15[i][j] == ia)
302 {
303 array[0] = rings.r15[i][0];
304 array[1] = rings.r15[i][1];
305 array[2] = rings.r15[i][2];
306 array[3] = rings.r15[i][3];
307 array[4] = rings.r15[i][4];
308 return(TRUE);
309 }
310 }
311 }
312 return(FALSE);
313 }
314 /* -------------------------------------------------------- */
315 int is_ring52(int ia, int ib)
316 {
317 int i, j,k, itmp, jtmp;
318 if (ia < ib)
319 {
320 itmp = ia;
321 jtmp = ib;
322 }else
323 {
324 itmp = ib;
325 jtmp = ia;
326 }
327 for (i=0; i < rings.nring5; i++)
328 {
329 for (j=0; j < 4; j++)
330 {
331 if (itmp == rings.r15[i][j])
332 {
333 for (k=j+1; k < 5; k++)
334 {
335 if (jtmp == rings.r15[i][k])
336 return(TRUE);
337 }
338 }
339 }
340 }
341 return(FALSE);
342 }
343 /* -------------------------------------------------------- */
344 int is_ring53(int ia, int ib, int ic)
345 {
346 int i, j,k,l;
347 int array[5];
348
349 array[0] = ia;
350 array[1] = ib;
351 array[2] = ic;
352 ksort(3,array);
353 for (i=0; i < rings.nring5; i++)
354 {
355 for (j=0; j < 3; j++)
356 {
357 if (array[0] == rings.r15[i][j])
358 {
359 for (k=j+1; k < 4; k++)
360 {
361 if (array[1] == rings.r15[i][k])
362 {
363 for (l=j+1; l < 5; l++)
364 {
365 if (array[2] == rings.r15[i][l])
366 return(TRUE);
367 }
368 }
369 }
370 }
371 }
372 }
373 return(FALSE);
374 }
375 /* -------------------------------------------------------- */
376 int is_ring54(int ia, int ib, int ic, int id)
377 {
378 int i;
379 int array[5];
380 array[0] = ia;
381 array[1] = ib;
382 array[2] = ic;
383 array[3] = id;
384 ksort(4,array);
385 for (i=0; i < rings.nring5; i++)
386 {
387 if (array[0] == rings.r15[i][0])
388 {
389 if (array[1] == rings.r15[i][1])
390 {
391 if (array[2] == rings.r15[i][2])
392 {
393 if (array[3] == rings.r15[i][3])
394 return(TRUE);
395 else if (array[3] == rings.r15[i][4])
396 return(TRUE);
397 else
398 return(FALSE);
399 } else if (array[2] == rings.r15[i][3] && array[3] == rings.r15[i][4])
400 return(TRUE);
401 } else if (array[1] == rings.r15[i][2] &&
402 array[2] == rings.r15[i][3] && array[3] == rings.r15[i][4])
403 return(TRUE);
404
405 } else if (array[0] == rings.r15[i][1] && array[1] == rings.r15[i][2] &&
406 array[2] == rings.r15[i][3] && array[3] == rings.r15[i][4])
407 return(TRUE);
408 }
409 return (FALSE);
410 }
411 /* -------------------------------------------------------- */
412 int is_ring55(int *array)
413 {
414 int i;
415 for(i=0; i < rings.nring5; i++)
416 {
417 if ( array[0] == rings.r15[i][0] && array[1] == rings.r15[i][1] && array[2] == rings.r15[i][2] &&
418 array[3] == rings.r15[i][3] && array[4] == rings.r15[i][4])
419 return(TRUE);
420 }
421 return (FALSE);
422 }
423 /* -------------------------------------------------------- */
424 int is_ring61(int ia)
425 {
426 int i, j;
427 for(i=0; i < rings.nring6; i++)
428 {
429 for(j=0; j < 6; j++)
430 {
431 if (ia == rings.r16[i][j])
432 return (TRUE);
433 }
434 }
435 return (FALSE);
436 }
437 /* -------------------------------------------------------- */
438 int is_ring62(int ia, int ib)
439 {
440 int i, j,k, itmp, jtmp;
441 if (ia < ib)
442 {
443 itmp = ia;
444 jtmp = ib;
445 }else
446 {
447 itmp = ib;
448 jtmp = ia;
449 }
450 for (i=0; i < rings.nring6; i++)
451 {
452 for (j=0; j < 5; j++)
453 {
454 if (itmp == rings.r16[i][j])
455 {
456 for (k=j+1; k < 6; k++)
457 {
458 if (jtmp == rings.r16[i][k])
459 return(TRUE);
460 }
461 }
462 }
463 }
464 return(FALSE);
465 }
466 /* -------------------------------------------------------- */
467 int is_ring63(int ia, int ib, int ic)
468 {
469 int i, j, k, l;
470 int array[5];
471
472 array[0] = ia;
473 array[1] = ib;
474 array[2] = ic;
475 ksort(3,array);
476 for (i=0; i < rings.nring6; i++)
477 {
478 for (j=0; j < 4; j++)
479 {
480 if (array[0] == rings.r16[i][j])
481 {
482 for (k=j+1; k < 5; k++)
483 {
484 if (array[1] == rings.r16[i][k])
485 {
486 for (l=k+1; l < 6; l++)
487 {
488 if (array[2] == rings.r16[i][l])
489 return(TRUE);
490 }
491 }
492 }
493 }
494 }
495 }
496 return(FALSE);
497 }
498 /* -------------------------------------------------------- */
499 int is_ring66(int *array)
500 {
501 int i;
502 for(i=0; i < rings.nring6; i++)
503 {
504 if ( array[0] == rings.r16[i][0] && array[1] == rings.r16[i][1] && array[2] == rings.r16[i][2] &&
505 array[3] == rings.r16[i][3] && array[4] == rings.r16[i][4] && array[5] == rings.r16[i][5])
506 return(TRUE);
507 }
508 return (FALSE);
509 }
510 /* -------------------------------------------------------- */
511 void get_rings()
512 {
513 int i,j, add_ring, k, l, m, n,ij,isix;
514 int jatm,katm,latm,matm,xatm;
515 int array[6];
516 long int aromatic_mask;
517
518 rings.nring3 = 0;
519 rings.nring4 = 0;
520 rings.nring5 = 0;
521 rings.nring6 = 0;
522 aromatic_mask = (1L << AROMATIC_MASK);
523
524 // get three membered rings
525 for (i=1; i <= natom; i++)
526 {
527 for (j=0; j < MAXIAT; j++)
528 {
529 if (atom[i].iat[j] != 0)
530 {
531 jatm = atom[i].iat[j];
532 for (k=0; k < MAXIAT; k++)
533 {
534 if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i)
535 {
536 if (isbond(i,atom[jatm].iat[k]))
537 {
538 array[0] = i;
539 array[1] = jatm;
540 array[2] = atom[jatm].iat[k];
541 ksort(3,array);
542 add_ring = TRUE;
543 for (j = 0; j < rings.nring3; j++)
544 {
545 if (array[0] == rings.r13[j][0] && array[1] == rings.r13[j][1]
546 && array[2] == rings.r13[j][2])
547 {
548 add_ring = FALSE;
549 break;
550 }
551 }
552 if (add_ring == TRUE)
553 {
554 rings.r13[rings.nring3][0] = array[0];
555 rings.r13[rings.nring3][1] = array[1];
556 rings.r13[rings.nring3][2] = array[2];
557 rings.nring3++;
558 if (rings.nring3 >= MAXATOM/3)
559 message_alert("Error. Too many 3 membered rings!","ERROR");
560 }
561 }
562 }
563 }
564 }
565 }
566 }
567 // get four membered rings
568 for(i=1; i <= natom; i++)
569 {
570 for(j=0; j < MAXIAT; j++)
571 {
572 if (atom[i].iat[j] != 0)
573 {
574 jatm = atom[i].iat[j];
575 for (k=0; k < MAXIAT; k++)
576 {
577 if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i)
578 {
579 katm = atom[jatm].iat[k];
580 if (!(isbond(katm,i)))
581 {
582 for(l=0; l < MAXIAT; l++)
583 {
584 if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm)
585 {
586 if (isbond(i,atom[katm].iat[l]) )
587 {
588 array[0] = i;
589 array[1] = jatm;
590 array[2] = katm;
591 array[3] = atom[katm].iat[l];
592 ksort(4, array);
593 if ( is_ring44(array) == FALSE )
594 {
595 rings.r14[rings.nring4][0] = array[0];
596 rings.r14[rings.nring4][1] = array[1];
597 rings.r14[rings.nring4][2] = array[2];
598 rings.r14[rings.nring4][3] = array[3];
599 rings.nring4++;
600 if (rings.nring4 >= MAXATOM/4)
601 message_alert("Error. Too many 4 membered rings!","ERROR");
602 }
603 }
604 }
605 }
606 }
607 }
608 }
609 }
610 }
611 }
612 // get five membered rings i-jatm-katm-latm-
613 for(i=1; i <= natom; i++)
614 {
615 for(j=0; j < MAXIAT; j++)
616 {
617 if (atom[i].iat[j] != 0)
618 {
619 jatm = atom[i].iat[j];
620 for (k=0; k < MAXIAT; k++)
621 {
622 if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i)
623 {
624 katm = atom[jatm].iat[k];
625 if (!(isbond(katm,i)))
626 {
627 for(l=0; l < MAXIAT; l++)
628 {
629 if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm)
630 {
631 latm = atom[katm].iat[l];
632 for (m=0; m < MAXIAT; m++)
633 {
634 if (atom[latm].iat[m] != 0 && atom[latm].iat[m] != katm && atom[latm].iat[m] != jatm)
635 {
636 if (isbond(i,atom[latm].iat[m]))
637 {
638 array[0] = i;
639 array[1] = jatm;
640 array[2] = katm;
641 array[3] = latm;
642 array[4] = atom[latm].iat[m];
643 ksort(5,array);
644 if (is_ring55(array) == FALSE)
645 {
646 rings.r15[rings.nring5][0] = array[0];
647 rings.r15[rings.nring5][1] = array[1];
648 rings.r15[rings.nring5][2] = array[2];
649 rings.r15[rings.nring5][3] = array[3];
650 rings.r15[rings.nring5][4] = array[4];
651 rings.nring5++;
652 if (rings.nring5 >= MAXATOM/5)
653 message_alert("Error. Too many 5 membered rings!","ERROR");
654 isix = aromatic_5(array);
655 if (isix == TRUE)
656 {
657 for (ij = 0; ij < 5; ij++)
658 atom[array[ij]].flags |= aromatic_mask;
659 }
660 }
661 }
662 }
663 }
664 }
665 }
666 }
667 }
668 }
669 }
670 }
671 }
672 // get six membered rings
673 for(i=1; i <= natom; i++)
674 {
675 for(j=0; j < MAXIAT; j++)
676 {
677 if (atom[i].iat[j] != 0)
678 {
679 jatm = atom[i].iat[j];
680 for (k=0; k < MAXIAT; k++)
681 {
682 if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i)
683 {
684 katm = atom[jatm].iat[k];
685 if (!(isbond(katm,i)))
686 {
687 for(l=0; l < MAXIAT; l++)
688 {
689 if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm)
690 {
691 latm = atom[katm].iat[l];
692 for (m=0; m < MAXIAT; m++)
693 {
694 if (atom[latm].iat[m] != 0 && atom[latm].iat[m] != katm && atom[latm].iat[m] != jatm)
695 {
696 xatm = atom[latm].iat[m];
697 for (n = 0; n < MAXIAT; n++)
698 {
699 if (atom[xatm].iat[n] != 0 && atom[xatm].iat[n] != latm && atom[xatm].iat[n] != katm)
700 if (isbond(i,atom[xatm].iat[n]))
701 {
702 array[0] = i;
703 array[1] = jatm;
704 array[2] = katm;
705 array[3] = latm;
706 array[4] = xatm;
707 array[5] = atom[xatm].iat[n];
708 ksort(6,array);
709 if (is_ring66(array) == FALSE)
710 {
711 rings.r16[rings.nring6][0] = array[0];
712 rings.r16[rings.nring6][1] = array[1];
713 rings.r16[rings.nring6][2] = array[2];
714 rings.r16[rings.nring6][3] = array[3];
715 rings.r16[rings.nring6][4] = array[4];
716 rings.r16[rings.nring6][5] = array[5];
717 rings.nring6++;
718 if (rings.nring6 >= MAXATOM/6)
719 message_alert("Error. Too many 6 membered rings!","ERROR");
720 isix = aromatic_6(array);
721 if (isix == TRUE)
722 {
723 for (ij = 0; ij < 6; ij++)
724 atom[array[ij]].flags |= aromatic_mask;
725 }
726 }
727 }
728 }
729 }
730 }
731 }
732 }
733 }
734 }
735 }
736 }
737 }
738 }
739 }
740 /* =================================================== */
741 void ksort(int num, int array[])
742 {
743 int i,temp;
744 int found;
745
746 L_1:
747 found = FALSE;
748 for (i=0; i < num-1; i++)
749 {
750 if (array[i+1] < array[i])
751 {
752 temp = array[i];
753 array[i] = array[i+1];
754 array[i+1] = temp;
755 found = TRUE;
756 }
757 }
758 if (found == TRUE)
759 goto L_1;
760 }
761 /* --------------------------------------------------------- */
762 int aromatic_5(int *array)
763 {
764 int i,j,k, jatm, katm;
765 int nodbl, npi;
766 int ia, ib, ic;
767 int db[10];
768 int ihetero;
769 long int aromatic_mask, mask6;
770
771 aromatic_mask = (1 << AROMATIC_MASK);
772 mask6 = (1L << RING6);
773
774 npi = 0;
775 ihetero = 0;
776 for (i=0; i < 4; i++)
777 {
778 jatm = array[i];
779 for (j=i+1;j < 5; j++)
780 {
781 katm = array[j];
782 if (isbond(jatm,katm))
783 {
784 for (k=0; k < MAXIAT; k++)
785 {
786 if (atom[jatm].iat[k] == katm)
787 {
788 if (atom[jatm].bo[k] == 2)
789 {
790 db[npi] = i+j;
791 npi++;
792 }else if ( (atom[jatm].flags & aromatic_mask && atom[jatm].flags & mask6 )
793 && (atom[katm].flags & aromatic_mask && atom[katm].flags & mask6 ))
794 {
795 db[npi] = i+j;
796 npi++;
797 }
798 }
799 }
800 }
801 }
802 }
803 for (i=0; i < 5; i++)
804 {
805 jatm = array[i];
806 if (atom[jatm].atomnum != 6)
807 {
808 nodbl = FALSE;
809 for(j=0; j < MAXIAT; j++)
810 {
811 if (atom[jatm].iat[j] != 0)
812 {
813 if (atom[jatm].bo[j] > 1 && atom[jatm].bo[j] != 9)
814 nodbl = TRUE;
815 }
816 }
817 if (nodbl == FALSE)
818 ihetero = jatm;
819 }
820 }
821 if (npi >= 2 && ihetero != 0) // got an aromatic ring with heteroatom
822 return TRUE;
823
824 if (npi == 0) // no double bonds in ring
825 return FALSE;
826
827 if (npi == 1 && ihetero == 0)
828 return FALSE;
829
830 if (npi == 1)
831 {
832 if (db[0] == 1)
833 {
834 ia = array[2];
835 ib = array[3];
836 ic = array[4];
837 } else if (db[0] == 3)
838 {
839 ia = array[0];
840 ib = array[3];
841 ic = array[4];
842 } else if (db[0] == 4)
843 {
844 ia = array[1];
845 ib = array[2];
846 ic = array[3];
847 } else if (db[0] == 5)
848 {
849 ia = array[0];
850 ib = array[1];
851 ic = array[4];
852 } else if (db[0] == 7)
853 {
854 ia = array[0];
855 ib = array[1];
856 ic = array[2];
857 }
858 if (ia == ihetero)
859 {
860 for(i=0; i < rings.nring6; i++)
861 {
862 for (j=0; j < 6; j++)
863 {
864 if (rings.r16[i][j] == ib)
865 {
866 if (atom[ib].flags & aromatic_mask)
867 return TRUE;
868 }
869 if (rings.r16[i][j] == ic)
870 {
871 if (atom[ic].flags & aromatic_mask)
872 return TRUE;
873 }
874 }
875 }
876 } else if (ib == ihetero)
877 {
878 for(i=0; i < rings.nring6; i++)
879 {
880 for (j=0; j < 6; j++)
881 {
882 if (rings.r16[i][j] == ia)
883 {
884 if (atom[ia].flags & aromatic_mask)
885 return TRUE;
886 }
887 if (rings.r16[i][j] == ic)
888 {
889 if (atom[ic].flags & aromatic_mask)
890 return TRUE;
891 }
892 }
893 }
894 } else if (ic == ihetero)
895 {
896 for(i=0; i < rings.nring6; i++)
897 {
898 for (j=0; j < 6; j++)
899 {
900 if (rings.r16[i][j] == ib)
901 {
902 if (atom[ib].flags & aromatic_mask)
903 return TRUE;
904 }
905 if (rings.r16[i][j] == ia)
906 {
907 if (atom[ia].flags & aromatic_mask)
908 return TRUE;
909 }
910 }
911 }
912 }
913 }
914 return FALSE;
915 }
916 /* --------------------------------------------------------- */
917 int aromatic_6(int *array)
918 {
919 int i,j,k, ia,ib, idbl,kdbl;
920 int num, inarray[10];
921 long int aromatic_mask, mask6;
922
923 aromatic_mask = (1 << AROMATIC_MASK);
924 mask6 = (1L << RING6);
925 num = 0;
926 for (i=0; i < 10; i++)
927 inarray[i] = FALSE;
928
929 for (i=0; i < 5; i++)
930 {
931 ia = array[i];
932 for (j=i+1; j < 6; j++)
933 {
934 for (k=0; k < MAXIAT; k++)
935 {
936 if (atom[ia].iat[k] == array[j])
937 {
938 if (atom[ia].bo[k] == 2)
939 {
940 num++;
941 inarray[i] = TRUE;
942 inarray[j] = TRUE;
943 }
944 }
945 }
946 }
947 }
948 if (num == 3)
949 return TRUE;
950
951 if (num >= 1)
952 {
953 for(i=0; i < 5; i++)
954 {
955 if (inarray[i] == FALSE)
956 {
957 ia = array[i];
958 for(j=i+1;j < 6; j++)
959 {
960 if (inarray[j] == FALSE)
961 {
962 ib = array[j];
963 if ( (atom[ia].flags & aromatic_mask) && (atom[ib].flags & aromatic_mask))
964 {
965 num++;
966 if (num == 3)
967 return TRUE;
968 } else if (isbond(ia,ib))
969 {
970 idbl = FALSE;
971 kdbl = FALSE;
972 for(k=0; k < MAXIAT; k++)
973 {
974 if (atom[ia].iat[k] !=0 && atom[ia].bo[k] == 2)
975 {
976 if (atom[atom[ia].iat[k]].atomnum == 6 || atom[atom[ia].iat[k]].atomnum == 7)
977 {
978 if (atom[atom[ia].iat[k]].flags & mask6)
979 idbl = TRUE;
980 }
981 }
982 if (atom[ib].iat[k] !=0 && atom[ib].bo[k] == 2)
983 {
984 if (atom[atom[ib].iat[k]].atomnum == 6 || atom[atom[ib].iat[k]].atomnum == 7)
985 {
986 if (atom[atom[ib].iat[k]].flags & mask6)
987 kdbl = TRUE;
988 }
989 }
990 }
991 if (idbl == TRUE && kdbl == TRUE)
992 {
993 num++;
994 if (num == 3)
995 return TRUE;
996 }
997 }
998 inarray[i] = TRUE;
999 inarray[j] = TRUE;
1000 }
1001 }
1002 }
1003 }
1004 }
1005 return FALSE;
1006 }