4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_dlist_c
= "$Id$";
36 t_dlist
*mk_dlist(FILE *log
,
37 t_atoms
*atoms
, int *nlist
,
38 bool bPhi
, bool bPsi
, bool bChi
, int maxchi
,
39 int r0
,int naa
,char **aa
)
43 int nl
=0,nc
[edMax
],ndih
;
48 snew(dl
,atoms
->nres
+1);
50 for(i
=0; (i
<edMax
); i
++)
55 ires
=atoms
->atom
[i
].resnr
;
57 /* Initiate all atom numbers to -1 */
58 atm
.minC
=atm
.H
=atm
.N
=atm
.C
=atm
.O
=-1;
59 for(j
=0; (j
<MAXCHI
+3); j
++)
62 /* Look for atoms in this residue */
63 while ((i
<atoms
->nr
) && (atoms
->atom
[i
].resnr
== ires
)) {
64 if ((strcmp(*(atoms
->atomname
[i
]),"H") == 0) ||
65 (strcmp(*(atoms
->atomname
[i
]),"H1") == 0) )
67 else if (strcmp(*(atoms
->atomname
[i
]),"N") == 0)
69 else if (strcmp(*(atoms
->atomname
[i
]),"C") == 0)
71 else if ((strcmp(*(atoms
->atomname
[i
]),"O") == 0) ||
72 (strcmp(*(atoms
->atomname
[i
]),"O1") == 0))
74 else if (strcmp(*(atoms
->atomname
[i
]),"CA") == 0)
76 else if (strcmp(*(atoms
->atomname
[i
]),"CB") == 0)
78 else if ((strcmp(*(atoms
->atomname
[i
]),"CG") == 0) ||
79 (strcmp(*(atoms
->atomname
[i
]),"CG1") == 0) ||
80 (strcmp(*(atoms
->atomname
[i
]),"OG") == 0) ||
81 (strcmp(*(atoms
->atomname
[i
]),"OG1") == 0) ||
82 (strcmp(*(atoms
->atomname
[i
]),"SG") == 0))
84 else if ((strcmp(*(atoms
->atomname
[i
]),"CD") == 0) ||
85 (strcmp(*(atoms
->atomname
[i
]),"CD1") == 0) ||
86 (strcmp(*(atoms
->atomname
[i
]),"SD") == 0) ||
87 (strcmp(*(atoms
->atomname
[i
]),"OD1") == 0) ||
88 (strcmp(*(atoms
->atomname
[i
]),"ND1") == 0) ||
89 (strcmp(*(atoms
->atomname
[i
]),"HG") == 0) ||
90 (strcmp(*(atoms
->atomname
[i
]),"HG1") == 0))
92 else if ((strcmp(*(atoms
->atomname
[i
]),"CE") == 0) ||
93 (strcmp(*(atoms
->atomname
[i
]),"CE1") == 0) ||
94 (strcmp(*(atoms
->atomname
[i
]),"OE1") == 0) ||
95 (strcmp(*(atoms
->atomname
[i
]),"NE") == 0))
97 else if ((strcmp(*(atoms
->atomname
[i
]),"CZ") == 0) ||
98 (strcmp(*(atoms
->atomname
[i
]),"NZ") == 0))
100 else if (strcmp(*(atoms
->atomname
[i
]),"NH1") == 0)
105 /* Special case for Pro, has no H */
106 if (strcmp(*(atoms
->resname
[ires
]),"PRO") == 0)
108 /* Carbon from previous residue */
115 thisres
=*(atoms
->resname
[ires
]);
117 /* Check how many dihedrals we have */
118 if ((atm
.N
!= -1) && (atm
.Cn
[1] != -1) && (atm
.C
!= -1) &&
119 (atm
.O
!= -1) && ((atm
.H
!= -1) || (atm
.minC
!= -1))) {
120 dl
[nl
].resnr
= ires
+1;
122 dl
[nl
].atm
.Cn
[0] = atm
.N
;
123 if ((atm
.Cn
[3] != -1) && (atm
.Cn
[2] != -1) && (atm
.Cn
[1] != -1)) {
125 if (atm
.Cn
[4] != -1) {
127 if (atm
.Cn
[5] != -1) {
129 if (atm
.Cn
[6] != -1) {
131 if (atm
.Cn
[7] != -1) {
133 if (atm
.Cn
[8] != -1) {
141 if ((atm
.minC
!= -1) && (atm
.minO
!= -1))
143 for(k
=0; (k
<naa
); k
++) {
144 if (strcasecmp(aa
[k
],thisres
) == 0)
149 sprintf(dl
[nl
].name
,"%s%d",thisres
,ires
+r0
);
153 fprintf(debug
,"Could not find N atom but could find other atoms"
154 " in residue %s%d\n",thisres
,ires
+r0
);
156 fprintf(stderr
,"\n");
158 fprintf(log
,"There are %d residues with dihedrals\n",nl
);
163 for(i
=0; (i
<maxchi
); i
++)
165 fprintf(log
,"There are %d dihedrals\n",j
);
166 fprintf(log
,"Dihedral: ");
168 fprintf(log
," Phi ");
170 fprintf(log
," Psi ");
172 for(i
=0; (i
<maxchi
); i
++)
173 fprintf(log
,"Chi%d ",i
+1);
174 fprintf(log
,"\nNumber: ");
176 fprintf(log
,"%4d ",nl
);
178 fprintf(log
,"%4d ",nl
);
180 for(i
=0; (i
<maxchi
); i
++)
181 fprintf(log
,"%4d ",nc
[i
]);
189 bool has_dihedral(int Dih
,t_dlist
*dl
)
194 #define BBB(x) (dl->atm.##x != -1)
197 b
= (BBB(H
) && BBB(N
) && BBB(Cn
[1]) && BBB(C
));
200 b
= (BBB(N
) && BBB(Cn
[1]) && BBB(C
) && BBB(O
));
203 b
= (BBB(minO
) && BBB(minC
) && BBB(N
) && BBB(Cn
[1]));
212 b
= (BBB(Cn
[ddd
]) && BBB(Cn
[ddd
+1]) && BBB(Cn
[ddd
+2]) && BBB(Cn
[ddd
+3]));
215 pr_dlist(stdout
,1,dl
,1);
216 fatal_error(0,"Non existant dihedral %d in file %s, line %d",
217 Dih
,__FILE__
,__LINE__
);
222 static void pr_props(FILE *fp
,t_dlist
*dl
,int nDih
,real dt
)
224 fprintf(fp
," %6.2f %6.2f\n",dl
->ntr
[nDih
]/dt
,dl
->S2
[nDih
]);
227 void pr_dlist(FILE *fp
,int nl
,t_dlist dl
[],real dt
)
231 for(i
=0; (i
<nl
); i
++) {
232 fprintf(fp
,"Residue %s\n",dl
[i
].name
);
233 fprintf(fp
," Angle [ AI, AJ, AK, AL] #tr/ns S^2D \n"
234 "--------------------------------------------\n");
235 fprintf(fp
," Phi [%4d,%4d,%4d,%4d]",
236 (dl
[i
].atm
.H
== -1) ? dl
[i
].atm
.minC
: dl
[i
].atm
.H
,
237 dl
[i
].atm
.N
,dl
[i
].atm
.Cn
[1],dl
[i
].atm
.C
);
238 pr_props(fp
,&dl
[i
],edPhi
,dt
);
239 fprintf(fp
," Psi [%4d,%4d,%4d,%4d]",dl
[i
].atm
.N
,dl
[i
].atm
.Cn
[1],
240 dl
[i
].atm
.C
,dl
[i
].atm
.O
);
241 pr_props(fp
,&dl
[i
],edPsi
,dt
);
242 fprintf(fp
," Omega [%4d,%4d,%4d,%4d]",dl
[i
].atm
.minO
,dl
[i
].atm
.minC
,
243 dl
[i
].atm
.N
,dl
[i
].atm
.Cn
[1]);
244 pr_props(fp
,&dl
[i
],edOmega
,dt
);
245 for(Xi
=0; Xi
<MAXCHI
; Xi
++)
246 if (dl
[i
].atm
.Cn
[Xi
+3] != -1) {
247 fprintf(fp
," Chi%d[%4d,%4d,%4d,%4d]",Xi
+1,dl
[i
].atm
.Cn
[Xi
],
248 dl
[i
].atm
.Cn
[Xi
+1],dl
[i
].atm
.Cn
[Xi
+2],
250 pr_props(fp
,&dl
[i
],Xi
+2,dt
);
256 int pr_trans(FILE *fp
,int nl
,t_dlist dl
[],real dt
,int Xi
)
261 fprintf(fp
,"\\begin{table}[h]\n");
262 fprintf(fp
,"\\caption{Number of dihedral transitions per nanosecond}\n");
263 fprintf(fp
,"\\begin{tabular}{|l|l|}\n");
264 fprintf(fp
,"\\hline\n");
265 fprintf(fp
,"Residue\t&$\\chi_%d$\t\\\\\n",Xi
+1);
266 for(i
=0; (i
<nl
); i
++) {
270 fprintf(fp
,"%s\t&\\HL{%d}\t\\\\\n",dl
[i
].name
,nn
);
274 fprintf(fp
,"%s\t&\\%d\t\\\\\n",dl
[i
].name
,nn
);
276 fprintf(fp
,"\\hline\n");
277 fprintf(fp
,"\\end{tabular}\n");
278 fprintf(fp
,"\\end{table}\n\n");