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_pp2shift_c
= "$Id$";
49 static real
interpolate(real phi
,real psi
,t_shiftdata
*sd
)
51 int iphi
,ipsi
,iphi1
,ipsi1
;
52 real fphi
,fpsi
,wx0
,wx1
,wy0
,wy1
;
55 if (phi > 2*M_PI) phi -= 2*M_PI;
57 if (psi > 2*M_PI) psi -= 2*M_PI;
70 fphi
-= iphi
; /* Fraction (offset from gridpoint) */
79 iphi1
= (iphi
+1) % sd
->nx
;
80 ipsi1
= (ipsi
+1) % sd
->ny
;
82 return (sd
->data
[iphi
] [ipsi
] * wx0
*wy0
+
83 sd
->data
[iphi1
] [ipsi
] * wx1
*wy0
+
84 sd
->data
[iphi
] [ipsi1
] * wx0
*wy1
+
85 sd
->data
[iphi1
] [ipsi1
] * wx1
*wy1
);
88 static void dump_sd(char *fn
,t_shiftdata
*sd
)
93 int nnx
,nny
,nfac
=4,nlevels
=20;
94 real phi
,psi
,*x_phi
,*y_psi
,**newdata
;
96 t_rgb rlo
= { 1, 0, 0 }, rhi
= { 0, 0, 1 };
105 for(i
=0; (i
<nnx
); i
++) {
106 snew(newdata
[i
],nny
);
107 phi
= i
*2*M_PI
/(nnx
-1);
108 x_phi
[i
] =phi
*RAD2DEG
-180;
109 for(j
=0; (j
<nny
); j
++) {
110 psi
= j
*2*M_PI
/(nny
-1);
112 y_psi
[j
] = psi
*RAD2DEG
-180;
113 /*if (((i % nfac) == 0) && ((j % nfac) == 0))
114 newdata[i][j] = sd->data[i/nfac][j/nfac];
116 newdata
[i
][j
] = interpolate(phi
,psi
,sd
);
117 lo
= min(lo
,newdata
[i
][j
]);
118 hi
= max(hi
,newdata
[i
][j
]);
121 sprintf(buf
,"%s.xpm",fn
);
123 write_xpm(fp
,fn
,fn
,"Phi","Psi",nnx
,nny
,
124 x_phi
,y_psi
,newdata
,lo
,hi
,rlo
,rhi
,&nlevels
);
125 for(i
=0; (i
<nnx
); i
++)
132 static t_shiftdata
*read_shifts(char *fn
)
141 fscanf(fp
,"%d%d",&nx
,&ny
);
144 sd
->dx
= nx
/(2*M_PI
);
145 sd
->dy
= ny
/(2*M_PI
);
147 for(i
=0; (i
<=nx
); i
++) {
148 snew(sd
->data
[i
],ny
+1);
149 for(j
=0; (j
<ny
); j
++) {
151 sd
->data
[i
][j
] = sd
->data
[0][j
];
153 fscanf(fp
,"%lf",&xx
);
157 sd
->data
[i
][j
] = sd
->data
[i
][0];
168 static void done_shifts(t_shiftdata
*sd
)
172 for(i
=0; (i
<=sd
->nx
); i
++)
178 void do_pp2shifts(FILE *fp
,int nf
,int nlist
,t_dlist dlist
[],real
**dih
)
180 t_shiftdata
*ca_sd
,*co_sd
,*ha_sd
,*cb_sd
;
185 /* Read the shift files */
186 ca_sd
= read_shifts("ca-shift.dat");
187 cb_sd
= read_shifts("cb-shift.dat");
188 ha_sd
= read_shifts("ha-shift.dat");
189 co_sd
= read_shifts("co-shift.dat");
191 fprintf(fp
,"\n *** Chemical shifts from the chemical shift index ***\n");
192 please_cite(fp
,"Wishart98a");
193 fprintf(fp
,"%12s %10s %10s %10s %10s\n",
194 "Residue","delta Ca","delta Ha","delta CO","delta Cb");
195 for(i
=0; (i
<nlist
); i
++) {
196 if ((has_dihedral(edPhi
,&(dlist
[i
]))) &&
197 (has_dihedral(edPsi
,&(dlist
[i
])))) {
198 Phi
= dlist
[i
].j0
[edPhi
];
199 Psi
= dlist
[i
].j0
[edPsi
];
200 ca
= cb
= co
= ha
= 0;
201 for(j
=0; (j
<nf
); j
++) {
205 ca
+= interpolate(phi
,psi
,ca_sd
);
206 cb
+= interpolate(phi
,psi
,cb_sd
);
207 co
+= interpolate(phi
,psi
,co_sd
);
208 ha
+= interpolate(phi
,psi
,ha_sd
);
210 fprintf(fp
,"%12s %10g %10g %10g %10g\n",
211 dlist
[i
].name
,ca
/nf
,ha
/nf
,co
/nf
,cb
/nf
);