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

Line File contents
1 #define EXTERN extern
2
3 #include "pcwin.h"
4 #include "pcmod.h"
5 #include "utility.h"
6 #include "gmmx.h"
7
8
9 void find_rings(void);
10 void find_bonds(void);
11 int check_bond(int,int,int *);
12 void message_alert(char *, char *);
13
14 EXTERN struct t_rotbond {
15 int nbonds, bond[200][2], bond_res[200];
16 int incl_amide, incl_alkene;
17 } rotbond;
18 /* ================================================================= */
19 int check_bond(int ia1, int ia2, int *ibres)
20 {
21 int i;
22 int is_bond;
23 int it1, it2, it;
24
25 if (ia1 == 0 || ia2 == 0)
26 return FALSE;
27 is_bond = FALSE;
28 for (i=0; i < MAXIAT; i++)
29 {
30 if (atom[ia1].iat[i] == ia2)
31 {
32 is_bond = TRUE;
33 break;
34 }
35 }
36 if (is_bond == FALSE)
37 return FALSE;
38
39 // need to check that it is not part of a ring
40 // need to determine bond resolution
41 it1 = atom[ia1].mmx_type;
42 it2 = atom[ia2].mmx_type;
43 if (it1 <= it2)
44 it = it1*100 + it2;
45 else
46 it = it2*100 + it1;
47
48 if (it == 203 || it == 322)
49 *ibres = 30;
50 else if (it == 606 || it == 615 || it == 634 ||
51 it == 635 || it == 1515 || it == 1534 ||
52 it == 3434 || it == 3435 || it == 3535 )
53 *ibres = 30;
54 else if (it == 309 || it == 306 )
55 *ibres = 180;
56 else if (it == 202)
57 *ibres = 30;
58 else if (it == 102)
59 *ibres = 30;
60 else
61 *ibres = 120;
62 return TRUE;
63 }
64 // =======================================
65 void find_bonds()
66 {
67 int i,j,jji, ia1, ia2, k, l, found1, found2, ibres, nRc;
68 int jj1, bondorder, bondres;
69
70 rotbond.nbonds = 0;
71 for (i=0; i < 200; i++)
72 {
73 rotbond.bond[i][0] = 0;
74 rotbond.bond[i][1] = 0;
75 }
76
77 find_rings();
78
79 bondorder = 1;
80 if (rotbond.incl_alkene == TRUE)
81 bondorder = 2;
82 bondres = 180;
83 if (rotbond.incl_amide == TRUE)
84 bondres = 1000;
85
86 for (i=1; i <= natom; i++)
87 {
88 jji = 0;
89 for (j=0; j < MAXIAT; j++)
90 {
91 if (atom[i].iat[j] != 0 && atom[i].bo[j] != 9)
92 jji++;
93 }
94 if (jji > 1)
95 {
96 for (j=0; j < MAXIAT; j++)
97 {
98 if (atom[i].iat[j] != 0 && atom[i].bo[j] <= bondorder)
99 {
100 ia1 = atom[i].iat[j];
101 jj1 = 0;
102 for (k=0; k < MAXIAT; k++)
103 {
104 if (atom[ia1].iat[k] != 0 && atom[ia1].bo[k] != 9)
105 jj1++;
106 }
107 if (jj1 > 1)
108 {
109 if (i < atom[i].iat[j])
110 {
111 ia1 = i;
112 ia2 = atom[i].iat[j];
113 }else
114 {
115 ia1 = atom[i].iat[j];
116 ia2 = i;
117 }
118 if (atom[ia1].atomnum == 1)
119 goto L_10;
120 if (atom[ia2].atomnum == 1)
121 goto L_10;
122 // check to see if we have this bond
123 for (k=0; k < rotbond.nbonds; k++)
124 {
125 if (ia1 == rotbond.bond[k][0] && ia2 == rotbond.bond[k][1])
126 goto L_10;
127 }
128 // check to see if part of ring
129 for (k=0; k < gmmxring.nrings; k++)
130 {
131 found1 = FALSE;
132 found2 = FALSE;
133 for (l=0; l < gmmxring.nring_atoms[k]; l++)
134 {
135 if (ia1 == gmmxring.ring_atoms[k][l])
136 found1 = TRUE;
137 if (ia2 == gmmxring.ring_atoms[k][l])
138 found2 = TRUE;
139 }
140 if (found1 == TRUE && found2 == TRUE)
141 goto L_10;
142 }
143 // got here with new bond
144 nRc = check_bond(ia1,ia2,&ibres);
145 if (nRc == TRUE && ibres != bondres)
146 {
147 rotbond.bond[rotbond.nbonds][0] = ia1;
148 rotbond.bond[rotbond.nbonds][1] = ia2;
149 rotbond.bond_res[rotbond.nbonds] = ibres;
150 rotbond.nbonds++;
151 if (rotbond.nbonds > 200)
152 {
153 message_alert("Too many rotatable bonds","Find Bond Setup");
154 return;
155 }
156 }
157 }
158 }
159 L_10:
160 continue;
161 }
162 }
163 }
164 }