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 * Great Red Oystrich Makes All Chemists Sane
29 static char *SRCID_hxprops_c
= "$Id$";
41 int nhelix(int nres
,t_bb bb
[])
45 for(i
=n
=0; (i
<nres
); i
++)
51 real
ellipticity(int nres
,t_bb bb
[])
57 static const t_ppwstr ppw
[] = {
71 #define NPPW asize(ppw)
78 for(i
=0; (i
<nres
); i
++) {
81 for(j
=0; (j
<NPPW
); j
++) {
82 pp2
=sqr(phi
-ppw
[j
].phi
)+sqr(psi
-ppw
[j
].psi
);
93 real
ahx_len(int gnx
,atom_id index
[],rvec x
[],matrix box
)
94 /* Assume we have a list of Calpha atoms only! */
98 rvec_sub(x
[index
[0]],x
[index
[gnx
-1]],dx
);
103 real
radius(FILE *fp
,int nca
,atom_id ca_index
[],rvec x
[])
104 /* Assume we have all the backbone */
110 for(i
=0; (i
<nca
); i
++) {
112 dl2
=sqr(x
[ai
][XX
])+sqr(x
[ai
][YY
]);
115 fprintf(fp
," %10g",dl2
);
122 return sqrt(dlt
/nca
);
125 static real
rot(rvec x1
,rvec x2
)
127 real phi1
,dphi
,cp
,sp
;
130 phi1
=atan2(x1
[YY
],x1
[XX
]);
133 xx
= cp
*x2
[XX
]+sp
*x2
[YY
];
134 yy
=-sp
*x2
[XX
]+cp
*x2
[YY
];
136 dphi
=RAD2DEG
*atan2(yy
,xx
);
141 real
twist(FILE *fp
,int nca
,atom_id caindex
[],rvec x
[])
148 for(i
=1; (i
<nca
); i
++) {
151 dphi
=rot(x
[a0
],x
[a1
]);
161 real
ca_phi(int gnx
,atom_id index
[],rvec x
[],matrix box
)
162 /* Assume we have a list of Calpha atoms only! */
166 rvec r_ij
,r_kj
,r_kl
,m
,n
;
173 for(i
=0; (i
<gnx
-4); i
++) {
180 x
[ai
],x
[aj
],x
[ak
],x
[al
],
186 return (phitot
/(gnx
-4.0));
189 real
dip(int nbb
,atom_id bbind
[],rvec x
[],t_atom atom
[])
196 for(i
=0; (i
<nbb
); i
++) {
199 for(m
=0; (m
<DIM
); m
++)
200 dipje
[m
]+=x
[ai
][m
]*q
;
205 real
rise(int gnx
,atom_id index
[],rvec x
[])
206 /* Assume we have a list of Calpha atoms only! */
214 for(i
=1; (i
<gnx
); i
++) {
221 return (ztot
/(gnx
-1.0));
224 void av_hblen(FILE *fp3
,FILE *fp3a
,
225 FILE *fp4
,FILE *fp4a
,
226 FILE *fp5
,FILE *fp5a
,
227 real t
,int nres
,t_bb bb
[])
229 int i
,n3
=0,n4
=0,n5
=0;
232 for(i
=0; (i
<nres
-3); i
++)
234 fprintf(fp3a
, "%10g",bb
[i
].d3
);
238 fprintf(fp4a
,"%10g",bb
[i
].d4
);
243 fprintf(fp5a
,"%10g",bb
[i
].d5
);
248 fprintf(fp3
,"%10g %10g\n",t
,d3
/n3
);
249 fprintf(fp4
,"%10g %10g\n",t
,d4
/n4
);
250 fprintf(fp5
,"%10g %10g\n",t
,d5
/n5
);
257 void av_phipsi(FILE *fphi
,FILE *fpsi
,FILE *fphi2
,FILE *fpsi2
,
258 real t
,int nres
,t_bb bb
[])
263 fprintf(fphi2
,"%10g",t
);
264 fprintf(fpsi2
,"%10g",t
);
265 for(i
=0; (i
<nres
); i
++)
269 fprintf(fphi2
," %10g",bb
[i
].phi
);
270 fprintf(fpsi2
," %10g",bb
[i
].psi
);
273 fprintf(fphi
,"%10g %10g\n",t
,(phi
/n
));
274 fprintf(fpsi
,"%10g %10g\n",t
,(psi
/n
));
279 static void set_ahcity(int nbb
,t_bb bb
[])
284 for(n
=0; (n
<nbb
); n
++) {
285 pp2
=sqr(bb
[n
].phi
-PHI_AHX
)+sqr(bb
[n
].psi
-PSI_AHX
);
289 if ((bb
[n
].d4
< 0.36) || ((n
> 0) && bb
[n
-1].bHelix
))
295 t_bb
*mkbbind(char *fn
,int *nres
,int *nbb
,int res0
,
296 int *nall
,atom_id
**index
,
297 char ***atomname
,t_atom atom
[],
300 static char * bb_nm
[] = { "N", "H", "CA", "C", "O" };
301 #define NBB asize(bb_nm)
304 int ai
,i
,i0
,i1
,j
,k
,ri
,rnr
,gnx
,r0
,r1
;
306 fprintf(stderr
,"Please select a group containing the entire backbone\n");
307 rd_index(fn
,1,&gnx
,index
,&grpname
);
309 fprintf(stderr
,"Checking group %s\n",grpname
);
310 r0
=r1
=atom
[(*index
)[0]].resnr
;
311 for(i
=1; (i
<gnx
); i
++) {
312 r0
=min(r0
,atom
[(*index
)[i
]].resnr
);
313 r1
=max(r1
,atom
[(*index
)[i
]].resnr
);
316 fprintf(stderr
,"There are %d residues\n",rnr
);
318 for(i
=0; (i
<rnr
); i
++)
319 bb
[i
].N
=bb
[i
].H
=bb
[i
].CA
=bb
[i
].C
=bb
[i
].O
=-1,bb
[i
].resno
=res0
+i
;
321 for(i
=j
=0; (i
<gnx
); i
++) {
323 ri
=atom
[ai
].resnr
-r0
;
324 if (strcmp(*(resname
[ri
]),"PRO") == 0) {
325 if (strcmp(*(atomname
[ai
]),"CD") == 0)
328 for(k
=0; (k
<NBB
); k
++)
329 if (strcmp(bb_nm
[k
],*(atomname
[ai
])) == 0) {
354 for(i0
=0; (i0
<rnr
); i0
++) {
355 if ((bb
[i0
].N
!= -1) && (bb
[i0
].H
!= -1) &&
357 (bb
[i0
].C
!= -1) && (bb
[i0
].O
!= -1))
360 for(i1
=rnr
-1; (i1
>=0); i1
--) {
361 if ((bb
[i1
].N
!= -1) && (bb
[i1
].H
!= -1) &&
363 (bb
[i1
].C
!= -1) && (bb
[i1
].O
!= -1))
371 for(i
=i0
; (i
<i1
); i
++) {
372 bb
[i
].Cprev
=bb
[i
-1].C
;
373 bb
[i
].Nnext
=bb
[i
+1].N
;
376 fprintf(stderr
,"There are %d complete backbone residues (from %d to %d)\n",
377 rnr
,bb
[i0
].resno
,bb
[i1
].resno
);
379 fatal_error(0,"rnr==0");
380 for(i
=0; (i
<rnr
); i
++,i0
++)
384 for(i
=0; (i
<rnr
); i
++) {
385 ri
=atom
[bb
[i
].CA
].resnr
;
386 sprintf(bb
[i
].label
,"%s%d",*(resname
[ri
]),ri
+res0
);
390 *nbb
=rnr
*asize(bb_nm
);
395 real
pprms(FILE *fp
,int nbb
,t_bb bb
[])
401 for(i
=n
=0; (i
<nbb
); i
++) {
403 rms
=sqrt(bb
[i
].pprms2
);
406 fprintf(fp
,"%10g ",rms
);
411 rms
=sqrt(rms2
/n
-sqr(rmst
/n
));
416 void calc_hxprops(int nres
,t_bb bb
[],rvec x
[],matrix box
)
419 rvec dx
,r_ij
,r_kj
,r_kl
,m
,n
;
422 for(i
=0; (i
<nres
); i
++) {
424 bb
[i
].d4
=bb
[i
].d3
=bb
[i
].d5
=0;
427 rvec_sub(x
[ao
],x
[an
],dx
);
432 rvec_sub(x
[ao
],x
[an
],dx
);
437 rvec_sub(x
[ao
],x
[an
],dx
);
443 x
[bb
[i
].Cprev
],x
[bb
[i
].N
],x
[bb
[i
].CA
],x
[bb
[i
].C
],
448 x
[bb
[i
].N
],x
[bb
[i
].CA
],x
[bb
[i
].C
],x
[bb
[i
].Nnext
],
451 bb
[i
].pprms2
=sqr(bb
[i
].phi
-PHI_AHX
)+sqr(bb
[i
].psi
-PSI_AHX
);
454 1.4*sin((bb
[i
].psi
+138.0)*DEG2RAD
) -
455 4.1*cos(2.0*DEG2RAD
*(bb
[i
].psi
+138.0)) +
456 2.0*cos(2.0*DEG2RAD
*(bb
[i
].phi
+30.0));
460 static void check_ahx(int nres
,t_bb bb
[],rvec x
[],
461 int *hstart
,int *hend
)
463 int h0
,h1
,h0sav
,h1sav
;
468 for(; (!bb
[h0
].bHelix
) && (h0
<nres
-4); h0
++)
470 for(h1
=h0
; bb
[h1
+1].bHelix
&& (h1
<nres
-1); h1
++)
473 /*fprintf(stderr,"Helix from %d to %d\n",h0,h1);*/
474 if (h1
-h0
> h1sav
-h0sav
) {
480 } while (h1
< nres
-1);
485 void do_start_end(int nres
,t_bb bb
[],rvec x
[],int *nbb
,atom_id bbindex
[],
486 int *nca
,atom_id caindex
[],
487 bool bRange
,int rStart
,int rEnd
)
492 for(i
=0; (i
<nres
); i
++) {
493 if ((bb
[i
].resno
>= rStart
) && (bb
[i
].resno
<= rEnd
))
495 if (bb
[i
].resno
== rStart
)
497 if (bb
[i
].resno
== rEnd
)
502 /* Find start and end of longest helix fragment */
503 check_ahx(nres
,bb
,x
,&hstart
,&hend
);
505 fprintf(stderr
,"helix from: %d thru %d\n",
506 bb
[hstart
].resno
,bb
[hend
].resno
);
508 for(j
=0,i
=hstart
; (i
<=hend
); i
++) {
509 bbindex
[j
++]=bb
[i
].N
;
510 bbindex
[j
++]=bb
[i
].H
;
511 bbindex
[j
++]=bb
[i
].CA
;
512 bbindex
[j
++]=bb
[i
].C
;
513 bbindex
[j
++]=bb
[i
].O
;
514 caindex
[i
-hstart
]=bb
[i
].CA
;
517 *nca
=(hend
-hstart
+1);
520 void pr_bb(FILE *fp
,int nres
,t_bb bb
[])
525 fprintf(fp
,"%3s %3s %3s %3s %3s %7s %7s %7s %7s %7s %3s\n",
526 "AA","N","Ca","C","O","Phi","Psi","D3","D4","D5","Hx?");
527 for(i
=0; (i
<nres
); i
++) {
528 fprintf(fp
,"%3d %3d %3d %3d %3d %7.2f %7.2f %7.3f %7.3f %7.3f %3s\n",
529 bb
[i
].resno
,bb
[i
].N
,bb
[i
].CA
,bb
[i
].C
,bb
[i
].O
,
530 bb
[i
].phi
,bb
[i
].psi
,bb
[i
].d3
,bb
[i
].d4
,bb
[i
].d5
,
531 bb
[i
].bHelix
? "Yes" : "No");