X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=blobdiff_plain;f=src%2Fgromacs%2Fgmxana%2Fgmx_chi.cpp;fp=src%2Fgromacs%2Fgmxana%2Fgmx_chi.c;h=e49878148f5e9b053a639f40e55357640759bd8b;hb=3a5934fccd489925ab5e80aeb4bf703040137071;hp=0b12224e2e98d91dd060b57cd2234bd4f4b744d1;hpb=6ecd5d46bf94b6ef898e8fac4a7770bd7b2ee5d5;p=alexxy%2Fgromacs.git diff --git a/src/gromacs/gmxana/gmx_chi.c b/src/gromacs/gmxana/gmx_chi.cpp similarity index 97% rename from src/gromacs/gmxana/gmx_chi.c rename to src/gromacs/gmxana/gmx_chi.cpp index 0b12224e2e..e49878148f 100644 --- a/src/gromacs/gmxana/gmx_chi.c +++ b/src/gromacs/gmxana/gmx_chi.cpp @@ -36,9 +36,11 @@ */ #include "gmxpre.h" -#include -#include -#include +#include +#include +#include + +#include #include "gromacs/commandline/pargs.h" #include "gromacs/correlationfunctions/autocorr.h" @@ -130,11 +132,12 @@ static gmx_bool bAllowed(real phi, real psi) #define NPP asize(map) int x, y; -#define INDEX(ppp) ((((int) (360+ppp*RAD2DEG)) % 360)/6) +#define INDEX(ppp) (((static_cast (360+ppp*RAD2DEG)) % 360)/6) x = INDEX(phi); y = INDEX(psi); #undef INDEX - return (gmx_bool) map[x][y]; + + return (map[x][y] == '1') ? TRUE : FALSE; } atom_id *make_chi_ind(int nl, t_dlist dl[], int *ndih) @@ -214,7 +217,7 @@ int bin(real chi, int mult) { mult = 3; - return (int) (chi*mult/360.0); + return static_cast(chi*mult/360.0); } @@ -311,11 +314,11 @@ static void dump_em_all(int nlist, t_dlist dlist[], int nf, real time[], snew(data, nf); if (bRAD) { - strcpy(ystr, "Angle (rad)"); + std::strcpy(ystr, "Angle (rad)"); } else { - strcpy(ystr, "Angle (degrees)"); + std::strcpy(ystr, "Angle (degrees)"); } /* Dump em all */ @@ -477,7 +480,7 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt, real *normhisto; real **Jc, **Jcsig; int ****his_aa_ss = NULL; - int ***his_aa, **his_aa1, *histmp; + int ***his_aa, *histmp; int i, j, k, m, n, nn, Dih, nres, hindex, angle; gmx_bool bBfac, bOccup; char hisfile[256], hhisfile[256], sshisfile[256], title[256], *ss_str = NULL; @@ -563,7 +566,7 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt, } if (bOccup && ((bfac_max <= 0) || ((bfac_max > 0) && bBfac))) { - hindex = ((dih[j][0]+M_PI)*nbin)/(2*M_PI); + hindex = static_cast(((dih[j][0]+M_PI)*nbin)/(2*M_PI)); range_check(hindex, 0, nbin); /* Assign dihedral to either of the structure determined @@ -761,8 +764,8 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt, sprintf(title, "\\xc\\f{}\\s%d\\N Distribution for %s", Dih-NONCHI+1, residue_name); } - strcpy(hhisfile, hisfile); - strcat(hhisfile, ".xvg"); + std::strcpy(hhisfile, hisfile); + std::strcat(hhisfile, ".xvg"); fp = xvgropen(hhisfile, title, "Degrees", "", oenv); if (output_env_get_print_xvgr_codes(oenv)) { @@ -927,12 +930,12 @@ static void do_rama(int nf, int nlist, t_dlist dlist[], real **dih, fprintf(fp, "%10g %10g\n", phi, psi); if (bViol) { - fprintf(gp, "%d\n", !bAllowed(dih[Phi][j], RAD2DEG*dih[Psi][j])); + fprintf(gp, "%d\n", (bAllowed(dih[Phi][j], RAD2DEG*dih[Psi][j]) == FALSE) ); } if (bOm) { omega = RAD2DEG*dih[Om][j]; - mat[(int)((phi*NMAT)/360)+NMAT/2][(int)((psi*NMAT)/360)+NMAT/2] + mat[static_cast(((phi*NMAT)/360)+NMAT/2)][static_cast(((psi*NMAT)/360)+NMAT/2)] += omega; } } @@ -951,12 +954,12 @@ static void do_rama(int nf, int nlist, t_dlist dlist[], real **dih, for (k = 0; (k < NMAT); k++) { mat[j][k] /= nf; - lo = min(mat[j][k], lo); - hi = max(mat[j][k], hi); + lo = std::min(mat[j][k], lo); + hi = std::max(mat[j][k], hi); } } /* Symmetrise */ - if (fabs(lo) > fabs(hi)) + if (std::abs(lo) > std::abs(hi)) { hi = -lo; } @@ -1013,7 +1016,6 @@ static void print_transitions(const char *fn, int maxchi, int nlist, { /* based on order_params below */ FILE *fp; - int nh[edMax]; int i, Dih, Xi; /* must correspond with enum in pp2shift.h:38 */ @@ -1035,11 +1037,6 @@ static void print_transitions(const char *fn, int maxchi, int nlist, oenv); xvgr_legend(fp, NONCHI+maxchi, (const char**)leg, oenv); - for (Dih = 0; (Dih < edMax); Dih++) - { - nh[Dih] = 0; - } - fprintf(fp, "%5s ", "#Res."); fprintf(fp, "%10s %10s %10s ", leg[edPhi], leg[edPsi], leg[edOmega]); for (Xi = 0; Xi < maxchi; Xi++) @@ -1174,9 +1171,9 @@ static void order_params(FILE *log, x0 = y0 = z0 = 1000.0; for (i = 0; (i < atoms->nr); i++) { - x0 = min(x0, x[i][XX]); - y0 = min(y0, x[i][YY]); - z0 = min(z0, x[i][ZZ]); + x0 = std::min(x0, x[i][XX]); + y0 = std::min(y0, x[i][YY]); + z0 = std::min(z0, x[i][ZZ]); } x0 *= 10.0; /* nm -> angstrom */ y0 *= 10.0; /* nm -> angstrom */ @@ -1370,7 +1367,7 @@ int gmx_chi(int argc, char *argv[]) atom_id isize, *index; int ndih, nactdih, nf; real **dih, *trans_frac, *aver_angle, *time; - int i, j, **chi_lookup, *multiplicity; + int i, **chi_lookup, *multiplicity; t_filenm fnm[] = { { efSTX, "-s", NULL, ffREAD }, @@ -1504,23 +1501,23 @@ int gmx_chi(int argc, char *argv[]) snew(multiplicity, ndih); mk_multiplicity_lookup(multiplicity, maxchi, nlist, dlist, ndih); - strcpy(grpname, "All residues, "); + std::strcpy(grpname, "All residues, "); if (bPhi) { - strcat(grpname, "Phi "); + std::strcat(grpname, "Phi "); } if (bPsi) { - strcat(grpname, "Psi "); + std::strcat(grpname, "Psi "); } if (bOmega) { - strcat(grpname, "Omega "); + std::strcat(grpname, "Omega "); } if (bChi) { - strcat(grpname, "Chi 1-"); - sprintf(grpname + strlen(grpname), "%i", maxchi); + std::strcat(grpname, "Chi 1-"); + sprintf(grpname + std::strlen(grpname), "%i", maxchi); }