4 |
|
#include "pcmod.h" |
5 |
|
#include "rings.h" |
6 |
|
|
7 |
< |
|
7 |
> |
int have_ring3(void); |
8 |
> |
int have_ring4(void); |
9 |
> |
int have_ring5(void); |
10 |
> |
int have_ring6(void); |
11 |
|
int isbond(int, int); |
12 |
|
int is_ring31(int); |
13 |
|
int is_ring41(int); |
29 |
|
int is_cyclo6(int, int *); |
30 |
|
int find_rsize(int, int); |
31 |
|
void get_rsize(int,int,int,int *); |
32 |
< |
int aromatic_5(int *); |
33 |
< |
int aromatic_6(int *); |
34 |
< |
|
32 |
> |
int aromatic_5(int *array,long int *flags,int *atomnum,int (*)[MAXIAT],int (*)[MAXIAT]); |
33 |
> |
int aromatic_6(int *,long int *flags,int *atomnum,int (*)[MAXIAT],int (*)[MAXIAT]); |
34 |
> |
void get_rings(int natom,int (*)[MAXIAT],long int *flags); |
35 |
> |
// ====================== |
36 |
> |
int have_ring3() |
37 |
> |
{ |
38 |
> |
if (rings.nring3 > 0) |
39 |
> |
return TRUE; |
40 |
> |
else |
41 |
> |
return FALSE; |
42 |
> |
} |
43 |
> |
int have_ring4() |
44 |
> |
{ |
45 |
> |
if (rings.nring4 > 0) |
46 |
> |
return TRUE; |
47 |
> |
else |
48 |
> |
return FALSE; |
49 |
> |
} |
50 |
> |
int have_ring5() |
51 |
> |
{ |
52 |
> |
if (rings.nring5 > 0) |
53 |
> |
return TRUE; |
54 |
> |
else |
55 |
> |
return FALSE; |
56 |
> |
} |
57 |
> |
int have_ring6() |
58 |
> |
{ |
59 |
> |
if (rings.nring6 > 0) |
60 |
> |
return TRUE; |
61 |
> |
else |
62 |
> |
return FALSE; |
63 |
> |
} |
64 |
|
/* --------------------------------------------------------- */ |
65 |
|
// iatom is atom number to search on |
66 |
|
// isize = ring size |
540 |
|
return (FALSE); |
541 |
|
} |
542 |
|
/* -------------------------------------------------------- */ |
543 |
< |
void get_rings() |
543 |
> |
void get_rings(int natom,int iat[MAXATOM][MAXIAT],long int *flags) |
544 |
|
{ |
545 |
|
int i,j, add_ring, k, l, m, n,ij,isix; |
546 |
|
int jatm,katm,latm,matm,xatm; |
558 |
|
{ |
559 |
|
for (j=0; j < MAXIAT; j++) |
560 |
|
{ |
561 |
< |
if (atom[i].iat[j] != 0) |
561 |
> |
if (iat[i][j] != 0) |
562 |
|
{ |
563 |
< |
jatm = atom[i].iat[j]; |
563 |
> |
jatm = iat[i][j]; |
564 |
|
for (k=0; k < MAXIAT; k++) |
565 |
|
{ |
566 |
< |
if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i) |
566 |
> |
if (iat[jatm][k] != 0 && iat[jatm][k] != i) |
567 |
|
{ |
568 |
< |
if (isbond(i,atom[jatm].iat[k])) |
568 |
> |
if (isbond(i,iat[jatm][k])) |
569 |
|
{ |
570 |
|
array[0] = i; |
571 |
|
array[1] = jatm; |
572 |
< |
array[2] = atom[jatm].iat[k]; |
572 |
> |
array[2] = iat[jatm][k]; |
573 |
|
ksort(3,array); |
574 |
|
add_ring = TRUE; |
575 |
|
for (j = 0; j < rings.nring3; j++) |
601 |
|
{ |
602 |
|
for(j=0; j < MAXIAT; j++) |
603 |
|
{ |
604 |
< |
if (atom[i].iat[j] != 0) |
604 |
> |
if (iat[i][j] != 0) |
605 |
|
{ |
606 |
< |
jatm = atom[i].iat[j]; |
606 |
> |
jatm = iat[i][j]; |
607 |
|
for (k=0; k < MAXIAT; k++) |
608 |
|
{ |
609 |
< |
if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i) |
609 |
> |
if (iat[jatm][k] != 0 && iat[jatm][k] != i) |
610 |
|
{ |
611 |
< |
katm = atom[jatm].iat[k]; |
611 |
> |
katm = iat[jatm][k]; |
612 |
|
if (!(isbond(katm,i))) |
613 |
|
{ |
614 |
|
for(l=0; l < MAXIAT; l++) |
615 |
|
{ |
616 |
< |
if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm) |
616 |
> |
if (iat[katm][l] != 0 && iat[katm][l] != jatm) |
617 |
|
{ |
618 |
< |
if (isbond(i,atom[katm].iat[l]) ) |
618 |
> |
if (isbond(i,iat[katm][l]) ) |
619 |
|
{ |
620 |
|
array[0] = i; |
621 |
|
array[1] = jatm; |
622 |
|
array[2] = katm; |
623 |
< |
array[3] = atom[katm].iat[l]; |
623 |
> |
array[3] = iat[katm][l]; |
624 |
|
ksort(4, array); |
625 |
|
if ( is_ring44(array) == FALSE ) |
626 |
|
{ |
646 |
|
{ |
647 |
|
for(j=0; j < MAXIAT; j++) |
648 |
|
{ |
649 |
< |
if (atom[i].iat[j] != 0) |
649 |
> |
if (iat[i][j] != 0) |
650 |
|
{ |
651 |
< |
jatm = atom[i].iat[j]; |
651 |
> |
jatm = iat[i][j]; |
652 |
|
for (k=0; k < MAXIAT; k++) |
653 |
|
{ |
654 |
< |
if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i) |
654 |
> |
if (iat[jatm][k] != 0 && iat[jatm][k] != i) |
655 |
|
{ |
656 |
< |
katm = atom[jatm].iat[k]; |
656 |
> |
katm = iat[jatm][k]; |
657 |
|
if (!(isbond(katm,i))) |
658 |
|
{ |
659 |
|
for(l=0; l < MAXIAT; l++) |
660 |
|
{ |
661 |
< |
if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm) |
661 |
> |
if (iat[katm][l] != 0 && iat[katm][l] != jatm) |
662 |
|
{ |
663 |
< |
latm = atom[katm].iat[l]; |
663 |
> |
latm = iat[katm][l]; |
664 |
|
for (m=0; m < MAXIAT; m++) |
665 |
|
{ |
666 |
< |
if (atom[latm].iat[m] != 0 && atom[latm].iat[m] != katm && atom[latm].iat[m] != jatm) |
666 |
> |
if (iat[latm][m] != 0 && iat[latm][m] != katm && iat[latm][m] != jatm) |
667 |
|
{ |
668 |
< |
if (isbond(i,atom[latm].iat[m])) |
668 |
> |
if (isbond(i,iat[latm][m])) |
669 |
|
{ |
670 |
|
array[0] = i; |
671 |
|
array[1] = jatm; |
672 |
|
array[2] = katm; |
673 |
|
array[3] = latm; |
674 |
< |
array[4] = atom[latm].iat[m]; |
674 |
> |
array[4] = iat[latm][m]; |
675 |
|
ksort(5,array); |
676 |
|
if (is_ring55(array) == FALSE) |
677 |
|
{ |
683 |
|
rings.nring5++; |
684 |
|
if (rings.nring5 >= MAXATOM/5) |
685 |
|
message_alert("Error. Too many 5 membered rings!","ERROR"); |
686 |
< |
isix = aromatic_5(array); |
686 |
> |
isix = aromatic_5(array,atom.flags,atom.atomnum,atom.iat,atom.bo); |
687 |
|
if (isix == TRUE) |
688 |
|
{ |
689 |
|
for (ij = 0; ij < 5; ij++) |
690 |
< |
atom[array[ij]].flags |= aromatic_mask; |
690 |
> |
flags[array[ij]] |= aromatic_mask; |
691 |
|
} |
692 |
|
} |
693 |
|
} |
706 |
|
{ |
707 |
|
for(j=0; j < MAXIAT; j++) |
708 |
|
{ |
709 |
< |
if (atom[i].iat[j] != 0) |
709 |
> |
if (iat[i][j] != 0) |
710 |
|
{ |
711 |
< |
jatm = atom[i].iat[j]; |
711 |
> |
jatm = iat[i][j]; |
712 |
|
for (k=0; k < MAXIAT; k++) |
713 |
|
{ |
714 |
< |
if (atom[jatm].iat[k] != 0 && atom[jatm].iat[k] != i) |
714 |
> |
if (iat[jatm][k] != 0 && iat[jatm][k] != i) |
715 |
|
{ |
716 |
< |
katm = atom[jatm].iat[k]; |
716 |
> |
katm = iat[jatm][k]; |
717 |
|
if (!(isbond(katm,i))) |
718 |
|
{ |
719 |
|
for(l=0; l < MAXIAT; l++) |
720 |
|
{ |
721 |
< |
if (atom[katm].iat[l] != 0 && atom[katm].iat[l] != jatm) |
721 |
> |
if (iat[katm][l] != 0 && iat[katm][l] != jatm) |
722 |
|
{ |
723 |
< |
latm = atom[katm].iat[l]; |
723 |
> |
latm = iat[katm][l]; |
724 |
|
for (m=0; m < MAXIAT; m++) |
725 |
|
{ |
726 |
< |
if (atom[latm].iat[m] != 0 && atom[latm].iat[m] != katm && atom[latm].iat[m] != jatm) |
726 |
> |
if (iat[latm][m] != 0 && iat[latm][m] != katm && iat[latm][m] != jatm) |
727 |
|
{ |
728 |
< |
xatm = atom[latm].iat[m]; |
728 |
> |
xatm = iat[latm][m]; |
729 |
|
for (n = 0; n < MAXIAT; n++) |
730 |
|
{ |
731 |
< |
if (atom[xatm].iat[n] != 0 && atom[xatm].iat[n] != latm && atom[xatm].iat[n] != katm) |
732 |
< |
if (isbond(i,atom[xatm].iat[n])) |
731 |
> |
if (iat[xatm][n] != 0 && iat[xatm][n] != latm && iat[xatm][n] != katm) |
732 |
> |
if (isbond(i,iat[xatm][n])) |
733 |
|
{ |
734 |
|
array[0] = i; |
735 |
|
array[1] = jatm; |
736 |
|
array[2] = katm; |
737 |
|
array[3] = latm; |
738 |
|
array[4] = xatm; |
739 |
< |
array[5] = atom[xatm].iat[n]; |
739 |
> |
array[5] = iat[xatm][n]; |
740 |
|
ksort(6,array); |
741 |
|
if (is_ring66(array) == FALSE) |
742 |
|
{ |
749 |
|
rings.nring6++; |
750 |
|
if (rings.nring6 >= MAXATOM/6) |
751 |
|
message_alert("Error. Too many 6 membered rings!","ERROR"); |
752 |
< |
isix = aromatic_6(array); |
752 |
> |
isix = aromatic_6(array,atom.flags,atom.atomnum,atom.iat,atom.bo); |
753 |
|
if (isix == TRUE) |
754 |
|
{ |
755 |
|
for (ij = 0; ij < 6; ij++) |
756 |
< |
atom[array[ij]].flags |= aromatic_mask; |
756 |
> |
flags[array[ij]] |= aromatic_mask; |
757 |
|
} |
758 |
|
} |
759 |
|
} |
791 |
|
goto L_1; |
792 |
|
} |
793 |
|
/* --------------------------------------------------------- */ |
794 |
< |
int aromatic_5(int *array) |
794 |
> |
int aromatic_5(int *array,long int *flags,int *atomnum,int iat[MAXATOM][MAXIAT],int bo[MAXATOM][MAXIAT]) |
795 |
|
{ |
796 |
|
int i,j,k, jatm, katm; |
797 |
|
int nodbl, npi; |
815 |
|
{ |
816 |
|
for (k=0; k < MAXIAT; k++) |
817 |
|
{ |
818 |
< |
if (atom[jatm].iat[k] == katm) |
818 |
> |
if (iat[jatm][k] == katm) |
819 |
|
{ |
820 |
< |
if (atom[jatm].bo[k] == 2) |
820 |
> |
if (bo[jatm][k] == 2) |
821 |
|
{ |
822 |
|
db[npi] = i+j; |
823 |
|
npi++; |
824 |
< |
}else if ( (atom[jatm].flags & aromatic_mask && atom[jatm].flags & mask6 ) |
825 |
< |
&& (atom[katm].flags & aromatic_mask && atom[katm].flags & mask6 )) |
824 |
> |
}else if ( (flags[jatm] & aromatic_mask && flags[jatm] & mask6 ) |
825 |
> |
&& (flags[katm] & aromatic_mask && flags[katm] & mask6 )) |
826 |
|
{ |
827 |
|
db[npi] = i+j; |
828 |
|
npi++; |
835 |
|
for (i=0; i < 5; i++) |
836 |
|
{ |
837 |
|
jatm = array[i]; |
838 |
< |
if (atom[jatm].atomnum != 6) |
838 |
> |
if (atomnum[jatm] != 6) |
839 |
|
{ |
840 |
|
nodbl = FALSE; |
841 |
|
for(j=0; j < MAXIAT; j++) |
842 |
|
{ |
843 |
< |
if (atom[jatm].iat[j] != 0) |
843 |
> |
if (iat[jatm][j] != 0) |
844 |
|
{ |
845 |
< |
if (atom[jatm].bo[j] > 1 && atom[jatm].bo[j] != 9) |
845 |
> |
if (bo[jatm][j] > 1 && bo[jatm][j] != 9) |
846 |
|
nodbl = TRUE; |
847 |
|
} |
848 |
|
} |
895 |
|
{ |
896 |
|
if (rings.r16[i][j] == ib) |
897 |
|
{ |
898 |
< |
if (atom[ib].flags & aromatic_mask) |
898 |
> |
if (flags[ib] & aromatic_mask) |
899 |
|
return TRUE; |
900 |
|
} |
901 |
|
if (rings.r16[i][j] == ic) |
902 |
|
{ |
903 |
< |
if (atom[ic].flags & aromatic_mask) |
903 |
> |
if (flags[ic] & aromatic_mask) |
904 |
|
return TRUE; |
905 |
|
} |
906 |
|
} |
913 |
|
{ |
914 |
|
if (rings.r16[i][j] == ia) |
915 |
|
{ |
916 |
< |
if (atom[ia].flags & aromatic_mask) |
916 |
> |
if (flags[ia] & aromatic_mask) |
917 |
|
return TRUE; |
918 |
|
} |
919 |
|
if (rings.r16[i][j] == ic) |
920 |
|
{ |
921 |
< |
if (atom[ic].flags & aromatic_mask) |
921 |
> |
if (flags[ic] & aromatic_mask) |
922 |
|
return TRUE; |
923 |
|
} |
924 |
|
} |
931 |
|
{ |
932 |
|
if (rings.r16[i][j] == ib) |
933 |
|
{ |
934 |
< |
if (atom[ib].flags & aromatic_mask) |
934 |
> |
if (flags[ib] & aromatic_mask) |
935 |
|
return TRUE; |
936 |
|
} |
937 |
|
if (rings.r16[i][j] == ia) |
938 |
|
{ |
939 |
< |
if (atom[ia].flags & aromatic_mask) |
939 |
> |
if (flags[ia] & aromatic_mask) |
940 |
|
return TRUE; |
941 |
|
} |
942 |
|
} |
946 |
|
return FALSE; |
947 |
|
} |
948 |
|
/* --------------------------------------------------------- */ |
949 |
< |
int aromatic_6(int *array) |
949 |
> |
int aromatic_6(int *array,long int *flags,int *atomnum,int iat[MAXATOM][MAXIAT],int bo[MAXATOM][MAXIAT]) |
950 |
|
{ |
951 |
|
int i,j,k, ia,ib, idbl,kdbl; |
952 |
|
int num, inarray[10]; |
965 |
|
{ |
966 |
|
for (k=0; k < MAXIAT; k++) |
967 |
|
{ |
968 |
< |
if (atom[ia].iat[k] == array[j]) |
968 |
> |
if (iat[ia][k] == array[j]) |
969 |
|
{ |
970 |
< |
if (atom[ia].bo[k] == 2) |
970 |
> |
if (bo[ia][k] == 2) |
971 |
|
{ |
972 |
|
num++; |
973 |
|
inarray[i] = TRUE; |
992 |
|
if (inarray[j] == FALSE) |
993 |
|
{ |
994 |
|
ib = array[j]; |
995 |
< |
if ( (atom[ia].flags & aromatic_mask) && (atom[ib].flags & aromatic_mask)) |
995 |
> |
if ( (flags[ia] & aromatic_mask) && (flags[ib] & aromatic_mask)) |
996 |
|
{ |
997 |
|
num++; |
998 |
|
if (num == 3) |
1003 |
|
kdbl = FALSE; |
1004 |
|
for(k=0; k < MAXIAT; k++) |
1005 |
|
{ |
1006 |
< |
if (atom[ia].iat[k] !=0 && atom[ia].bo[k] == 2) |
1006 |
> |
if (iat[ia][k] !=0 && bo[ia][k] == 2) |
1007 |
|
{ |
1008 |
< |
if (atom[atom[ia].iat[k]].atomnum == 6 || atom[atom[ia].iat[k]].atomnum == 7) |
1008 |
> |
if (atomnum[iat[ia][k]] == 6 || atomnum[iat[ia][k]] == 7) |
1009 |
|
{ |
1010 |
< |
if (atom[atom[ia].iat[k]].flags & mask6) |
1010 |
> |
if (flags[iat[ia][k]] & mask6) |
1011 |
|
idbl = TRUE; |
1012 |
|
} |
1013 |
|
} |
1014 |
< |
if (atom[ib].iat[k] !=0 && atom[ib].bo[k] == 2) |
1014 |
> |
if (iat[ib][k] !=0 && bo[ib][k] == 2) |
1015 |
|
{ |
1016 |
< |
if (atom[atom[ib].iat[k]].atomnum == 6 || atom[atom[ib].iat[k]].atomnum == 7) |
1016 |
> |
if (atomnum[iat[ib][k]] == 6 || atomnum[iat[ib][k]] == 7) |
1017 |
|
{ |
1018 |
< |
if (atom[atom[ib].iat[k]].flags & mask6) |
1018 |
> |
if (flags[iat[ib][k]] & mask6) |
1019 |
|
kdbl = TRUE; |
1020 |
|
} |
1021 |
|
} |