*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/utility/pleasecite.h"
#include "gromacs/utility/smalloc.h"
-typedef struct {
+typedef struct
+{
int nx, ny;
real dx, dy;
- real **data;
+ real** data;
} t_shiftdata;
-static real interpolate(real phi, real psi, t_shiftdata *sd)
+static real interpolate(real phi, real psi, t_shiftdata* sd)
{
int iphi, ipsi, iphi1, ipsi1;
real fphi, fpsi, wx0, wx1, wy0, wy1;
*/
while (phi < 0)
{
- phi += 2*M_PI;
+ phi += 2 * M_PI;
}
while (psi < 0)
{
- psi += 2*M_PI;
+ psi += 2 * M_PI;
}
- phi = 2*M_PI-phi;
+ phi = 2 * M_PI - phi;
- fphi = phi*sd->dx;
- fpsi = psi*sd->dy;
+ fphi = phi * sd->dx;
+ fpsi = psi * sd->dy;
- iphi = static_cast<int>(fphi);
- ipsi = static_cast<int>(fpsi);
+ iphi = static_cast<int>(fphi);
+ ipsi = static_cast<int>(fpsi);
fphi -= iphi; /* Fraction (offset from gridpoint) */
fpsi -= ipsi;
- wx0 = 1.0-fphi;
+ wx0 = 1.0 - fphi;
wx1 = fphi;
- wy0 = 1.0-fpsi;
+ wy0 = 1.0 - fpsi;
wy1 = fpsi;
iphi = iphi % sd->nx;
ipsi = ipsi % sd->ny;
- iphi1 = (iphi+1) % sd->nx;
- ipsi1 = (ipsi+1) % sd->ny;
+ iphi1 = (iphi + 1) % sd->nx;
+ ipsi1 = (ipsi + 1) % sd->ny;
- return (sd->data[iphi] [ipsi] * wx0*wy0 +
- sd->data[iphi1] [ipsi] * wx1*wy0 +
- sd->data[iphi] [ipsi1] * wx0*wy1 +
- sd->data[iphi1] [ipsi1] * wx1*wy1);
+ return (sd->data[iphi][ipsi] * wx0 * wy0 + sd->data[iphi1][ipsi] * wx1 * wy0
+ + sd->data[iphi][ipsi1] * wx0 * wy1 + sd->data[iphi1][ipsi1] * wx1 * wy1);
}
-static void dump_sd(const char *fn, t_shiftdata *sd)
+static void dump_sd(const char* fn, t_shiftdata* sd)
{
- FILE *fp;
- int i, j;
- char buf[256];
- int nnx, nny, nfac = 4, nlevels = 20;
- real phi, psi, *x_phi, *y_psi, **newdata;
- real lo, hi;
- t_rgb rlo = { 1, 0, 0 }, rhi = { 0, 0, 1 };
-
- nnx = sd->nx*nfac+1;
- nny = sd->ny*nfac+1;
+ FILE* fp;
+ int i, j;
+ char buf[256];
+ int nnx, nny, nfac = 4, nlevels = 20;
+ real phi, psi, *x_phi, *y_psi, **newdata;
+ real lo, hi;
+ t_rgb rlo = { 1, 0, 0 }, rhi = { 0, 0, 1 };
+
+ nnx = sd->nx * nfac + 1;
+ nny = sd->ny * nfac + 1;
snew(x_phi, nnx);
snew(y_psi, nny);
snew(newdata, nnx);
- lo = 100000;
+ lo = 100000;
hi = -100000;
for (i = 0; (i < nnx); i++)
{
snew(newdata[i], nny);
- phi = i*2*M_PI/(nnx-1);
- x_phi[i] = phi*RAD2DEG-180;
+ phi = i * 2 * M_PI / (nnx - 1);
+ x_phi[i] = phi * RAD2DEG - 180;
for (j = 0; (j < nny); j++)
{
- psi = j*2*M_PI/(nny-1);
+ psi = j * 2 * M_PI / (nny - 1);
if (i == 0)
{
- y_psi[j] = psi*RAD2DEG-180;
+ y_psi[j] = psi * RAD2DEG - 180;
}
/*if (((i % nfac) == 0) && ((j % nfac) == 0))
newdata[i][j] = sd->data[i/nfac][j/nfac];
}
sprintf(buf, "%s.xpm", fn);
fp = gmx_ffopen(buf, "w");
- write_xpm(fp, 0, fn, fn, "Phi", "Psi", nnx, nny,
- x_phi, y_psi, newdata, lo, hi, rlo, rhi, &nlevels);
+ write_xpm(fp, 0, fn, fn, "Phi", "Psi", nnx, nny, x_phi, y_psi, newdata, lo, hi, rlo, rhi, &nlevels);
for (i = 0; (i < nnx); i++)
{
sfree(newdata[i]);
sfree(y_psi);
}
-static t_shiftdata *read_shifts(const char *fn)
+static t_shiftdata* read_shifts(const char* fn)
{
double xx;
int i, j, nx, ny;
- t_shiftdata *sd;
+ t_shiftdata* sd;
snew(sd, 1);
gmx::FilePtr fp = gmx::openLibraryFile(fn);
GMX_ASSERT(nx > 0, "");
sd->nx = nx;
sd->ny = ny;
- sd->dx = nx/(2*M_PI);
- sd->dy = ny/(2*M_PI);
- snew(sd->data, nx+1);
+ sd->dx = nx / (2 * M_PI);
+ sd->dy = ny / (2 * M_PI);
+ snew(sd->data, nx + 1);
for (i = 0; (i <= nx); i++)
{
- snew(sd->data[i], ny+1);
+ snew(sd->data[i], ny + 1);
for (j = 0; (j < ny); j++)
{
if (i == nx)
}
-static void done_shifts(t_shiftdata *sd)
+static void done_shifts(t_shiftdata* sd)
{
int i;
sfree(sd);
}
-void do_pp2shifts(FILE *fp, int nf, int nlist, t_dlist dlist[], real **dih)
+void do_pp2shifts(FILE* fp, int nf, int nlist, t_dlist dlist[], real** dih)
{
t_shiftdata *ca_sd, *co_sd, *ha_sd, *cb_sd;
int i, j, Phi, Psi;
fprintf(fp, "\n *** Chemical shifts from the chemical shift index ***\n");
please_cite(fp, "Wishart98a");
- fprintf(fp, "%12s %10s %10s %10s %10s\n",
- "Residue", "delta Ca", "delta Ha", "delta CO", "delta Cb");
+ fprintf(fp, "%12s %10s %10s %10s %10s\n", "Residue", "delta Ca", "delta Ha", "delta CO",
+ "delta Cb");
for (i = 0; (i < nlist); i++)
{
- if ((has_dihedral(edPhi, &(dlist[i]))) &&
- (has_dihedral(edPsi, &(dlist[i]))))
+ if ((has_dihedral(edPhi, &(dlist[i]))) && (has_dihedral(edPsi, &(dlist[i]))))
{
Phi = dlist[i].j0[edPhi];
Psi = dlist[i].j0[edPsi];
- ca = cb = co = ha = 0;
+ ca = cb = co = ha = 0;
for (j = 0; (j < nf); j++)
{
phi = dih[Phi][j];
co += interpolate(phi, psi, co_sd);
ha += interpolate(phi, psi, ha_sd);
}
- fprintf(fp, "%12s %10g %10g %10g %10g\n",
- dlist[i].name, ca/nf, ha/nf, co/nf, cb/nf);
+ fprintf(fp, "%12s %10g %10g %10g %10g\n", dlist[i].name, ca / nf, ha / nf, co / nf,
+ cb / nf);
}
}
fprintf(fp, "\n");