Merge remote-tracking branch 'origin/release-2021' into merge-2021-into-master
[alexxy/gromacs.git] / src / gromacs / gmxana / gmx_chi.cpp
index d049f74b8830713520d80f0c227db4e62bd04455..deed54bfdf0fb50b9b931a4e6d3ff918c0994a5a 100644 (file)
@@ -127,10 +127,9 @@ static gmx_bool bAllowed(real phi, real psi)
                                  "0000000000000000000000000000000000000000000000000000000000000",
                                  "0000000000000000000000000000000000000000000000000000000000000",
                                  "0000000000000000000000000000000000000000000000000000000000000" };
-#define NPP asize(map)
-    int x, y;
+    int                x, y;
 
-#define INDEX(ppp) (((static_cast<int>(360 + (ppp)*RAD2DEG)) % 360) / 6)
+#define INDEX(ppp) (((static_cast<int>(360 + (ppp)*gmx::c_rad2Deg)) % 360) / 6)
     x = INDEX(phi);
     y = INDEX(psi);
 #undef INDEX
@@ -596,8 +595,7 @@ static void histogramming(FILE*                   log,
                     }
                     else if (debug)
                     {
-                        fprintf(debug, "Res. %d has imcomplete occupancy or bfacs > %g\n",
-                                dlist[i].resnr, bfac_max);
+                        fprintf(debug, "Res. %d has imcomplete occupancy or bfacs > %g\n", dlist[i].resnr, bfac_max);
                     }
                 }
                 else
@@ -768,8 +766,7 @@ static void histogramming(FILE*                   log,
                         break;
                     default:
                         sprintf(hisfile, "histo-chi%d%s", Dih - NONCHI + 1, residue_name);
-                        sprintf(title, "\\xc\\f{}\\s%d\\N Distribution for %s", Dih - NONCHI + 1,
-                                residue_name);
+                        sprintf(title, "\\xc\\f{}\\s%d\\N Distribution for %s", Dih - NONCHI + 1, residue_name);
                 }
                 std::strcpy(hhisfile, hisfile);
                 std::strcat(hhisfile, ".xvg");
@@ -935,16 +932,18 @@ static void do_rama(int                     nf,
             Psi = dlist[i].j0[edPsi];
             for (j = 0; (j < nf); j++)
             {
-                phi = RAD2DEG * dih[Phi][j];
-                psi = RAD2DEG * dih[Psi][j];
+                phi = gmx::c_rad2Deg * dih[Phi][j];
+                psi = gmx::c_rad2Deg * dih[Psi][j];
                 fprintf(fp, "%10g  %10g\n", phi, psi);
                 if (bViol)
                 {
-                    fprintf(gp, "%d\n", static_cast<int>(!bAllowed(dih[Phi][j], RAD2DEG * dih[Psi][j])));
+                    fprintf(gp,
+                            "%d\n",
+                            static_cast<int>(!bAllowed(dih[Phi][j], gmx::c_rad2Deg * dih[Psi][j])));
                 }
                 if (bOm)
                 {
-                    omega = RAD2DEG * dih[Om][j];
+                    omega = gmx::c_rad2Deg * dih[Om][j];
                     mat[static_cast<int>(((phi * NMAT) / 360) + gmx::exactDiv(NMAT, 2))]
                        [static_cast<int>(((psi * NMAT) / 360) + gmx::exactDiv(NMAT, 2))] += omega;
                 }
@@ -988,8 +987,24 @@ static void do_rama(int                     nf,
                 lo += 180;
                 hi += 180;
                 nlevels = 20;
-                write_xpm3(fp, 0, "Omega/Ramachandran Plot", "Deg", "Phi", "Psi", NMAT, NMAT, axis,
-                           axis, mat, lo, 180.0, hi, rlo, rmid, rhi, &nlevels);
+                write_xpm3(fp,
+                           0,
+                           "Omega/Ramachandran Plot",
+                           "Deg",
+                           "Phi",
+                           "Psi",
+                           NMAT,
+                           NMAT,
+                           axis,
+                           axis,
+                           mat,
+                           lo,
+                           180.0,
+                           hi,
+                           rlo,
+                           rmid,
+                           rhi,
+                           &nlevels);
                 gmx_ffclose(fp);
                 for (j = 0; (j < NMAT); j++)
                 {
@@ -1001,13 +1016,16 @@ static void do_rama(int                     nf,
         if ((has_dihedral(edChi1, &(dlist[i]))) && (has_dihedral(edChi2, &(dlist[i]))))
         {
             sprintf(fn, "ramaX1X2%s.xvg", dlist[i].name);
-            fp  = rama_file(fn, "\\8c\\4\\s1\\N-\\8c\\4\\s2\\N Ramachandran Plot",
-                           "\\8c\\4\\s1\\N (deg)", "\\8c\\4\\s2\\N (deg)", oenv);
+            fp  = rama_file(fn,
+                           "\\8c\\4\\s1\\N-\\8c\\4\\s2\\N Ramachandran Plot",
+                           "\\8c\\4\\s1\\N (deg)",
+                           "\\8c\\4\\s2\\N (deg)",
+                           oenv);
             Xi1 = dlist[i].j0[edChi1];
             Xi2 = dlist[i].j0[edChi2];
             for (j = 0; (j < nf); j++)
             {
-                fprintf(fp, "%10g  %10g\n", RAD2DEG * dih[Xi1][j], RAD2DEG * dih[Xi2][j]);
+                fprintf(fp, "%10g  %10g\n", gmx::c_rad2Deg * dih[Xi1][j], gmx::c_rad2Deg * dih[Xi2][j]);
             }
             xvgrclose(fp);
         }
@@ -1027,7 +1045,6 @@ static void print_transitions(const char* fn, int maxchi, int nlist, t_dlist dli
 
     /*  must correspond with enum in pp2shift.h:38 */
     char* leg[edMax];
-#define NLEG asize(leg)
 
     leg[0] = gmx_strdup("Phi");
     leg[1] = gmx_strdup("Psi");
@@ -1196,8 +1213,20 @@ static void order_params(FILE*                   log,
         z0 *= 10.0; /* nm -> angstrom */
         for (i = 0; (i < 10); i++)
         {
-            gmx_fprintf_pdb_atomline(fp, epdbATOM, atoms->nr + 1 + i, "CA", ' ', "LEG", ' ',
-                                     atoms->nres + 1, ' ', x0, y0, z0 + (1.2 * i), 0.0, -0.1 * i,
+            gmx_fprintf_pdb_atomline(fp,
+                                     PdbRecordType::Atom,
+                                     atoms->nr + 1 + i,
+                                     "CA",
+                                     ' ',
+                                     "LEG",
+                                     ' ',
+                                     atoms->nres + 1,
+                                     ' ',
+                                     x0,
+                                     y0,
+                                     z0 + (1.2 * i),
+                                     0.0,
+                                     -0.1 * i,
                                      "");
         }
         gmx_ffclose(fp);
@@ -1436,8 +1465,8 @@ int gmx_chi(int argc, char* argv[])
 
     npargs = asize(pa);
     ppa    = add_acf_pargs(&npargs, pa);
-    if (!parse_common_args(&argc, argv, PCA_CAN_VIEW | PCA_CAN_TIME, NFILE, fnm, npargs, ppa,
-                           asize(desc), desc, asize(bugs), bugs, &oenv))
+    if (!parse_common_args(
+                &argc, argv, PCA_CAN_VIEW | PCA_CAN_TIME, NFILE, fnm, npargs, ppa, asize(desc), desc, asize(bugs), bugs, &oenv))
     {
         sfree(ppa);
         return 0;
@@ -1514,8 +1543,8 @@ int gmx_chi(int argc, char* argv[])
     snew(dih, ndih);
 
     /* COMPUTE ALL DIHEDRALS! */
-    read_ang_dih(ftp2fn(efTRX, NFILE, fnm), FALSE, TRUE, FALSE, bPBC, 1, &idum, &nf, &time, isize,
-                 index, &trans_frac, &aver_angle, dih, oenv);
+    read_ang_dih(
+            ftp2fn(efTRX, NFILE, fnm), FALSE, TRUE, FALSE, bPBC, 1, &idum, &nf, &time, isize, index, &trans_frac, &aver_angle, dih, oenv);
 
     dt = (time[nf - 1] - time[0]) / (nf - 1); /* might want this for corr or n. transit*/
     if (bCorr)
@@ -1537,9 +1566,27 @@ int gmx_chi(int argc, char* argv[])
     }
 
     /* Histogramming & J coupling constants & calc of S2 order params */
-    histogramming(log, nbin, &rt, nf, maxchi, dih, nlist, dlist, index, bPhi, bPsi, bOmega, bChi,
-                  bNormHisto, bSSHisto, ftp2fn(efDAT, NFILE, fnm), bfac_max, &atoms, bDo_jc,
-                  opt2fn("-jc", NFILE, fnm), oenv);
+    histogramming(log,
+                  nbin,
+                  &rt,
+                  nf,
+                  maxchi,
+                  dih,
+                  nlist,
+                  dlist,
+                  index,
+                  bPhi,
+                  bPsi,
+                  bOmega,
+                  bChi,
+                  bNormHisto,
+                  bSSHisto,
+                  ftp2fn(efDAT, NFILE, fnm),
+                  bfac_max,
+                  &atoms,
+                  bDo_jc,
+                  opt2fn("-jc", NFILE, fnm),
+                  oenv);
 
     /* transitions
      *
@@ -1568,12 +1615,39 @@ int gmx_chi(int argc, char* argv[])
     }
 
 
-    low_ana_dih_trans(bDo_ot, opt2fn("-ot", NFILE, fnm), bDo_oh, opt2fn("-oh", NFILE, fnm), maxchi, dih,
-                      nlist, dlist, nf, nactdih, grpname, multiplicity, time, FALSE, core_frac, oenv);
+    low_ana_dih_trans(bDo_ot,
+                      opt2fn("-ot", NFILE, fnm),
+                      bDo_oh,
+                      opt2fn("-oh", NFILE, fnm),
+                      maxchi,
+                      dih,
+                      nlist,
+                      dlist,
+                      nf,
+                      nactdih,
+                      grpname,
+                      multiplicity,
+                      time,
+                      FALSE,
+                      core_frac,
+                      oenv);
 
     /* Order parameters */
-    order_params(log, opt2fn("-o", NFILE, fnm), maxchi, nlist, dlist, ftp2fn_null(efPDB, NFILE, fnm),
-                 bfac_init, &atoms, x, pbcType, box, bPhi, bPsi, bChi, oenv);
+    order_params(log,
+                 opt2fn("-o", NFILE, fnm),
+                 maxchi,
+                 nlist,
+                 dlist,
+                 ftp2fn_null(efPDB, NFILE, fnm),
+                 bfac_init,
+                 &atoms,
+                 x,
+                 pbcType,
+                 box,
+                 bPhi,
+                 bPsi,
+                 bChi,
+                 oenv);
 
     /* Print ramachandran maps! */
     if (bRama)
@@ -1607,8 +1681,20 @@ int gmx_chi(int argc, char* argv[])
         }
         mk_chi_lookup(chi_lookup, maxchi, nlist, dlist);
 
-        get_chi_product_traj(dih, nf, nlist, maxchi, dlist, time, chi_lookup, multiplicity, FALSE,
-                             bNormHisto, core_frac, bAll, opt2fn("-cp", NFILE, fnm), oenv);
+        get_chi_product_traj(dih,
+                             nf,
+                             nlist,
+                             maxchi,
+                             dlist,
+                             time,
+                             chi_lookup,
+                             multiplicity,
+                             FALSE,
+                             bNormHisto,
+                             core_frac,
+                             bAll,
+                             opt2fn("-cp", NFILE, fnm),
+                             oenv);
 
         for (i = 0; i < nlist; i++)
         {
@@ -1619,8 +1705,7 @@ int gmx_chi(int argc, char* argv[])
     /* Correlation comes last because it messes up the angles */
     if (bCorr)
     {
-        do_dihcorr(opt2fn("-corr", NFILE, fnm), nf, ndih, dih, dt, nlist, dlist, time, maxchi, bPhi,
-                   bPsi, bChi, bOmega, oenv);
+        do_dihcorr(opt2fn("-corr", NFILE, fnm), nf, ndih, dih, dt, nlist, dlist, time, maxchi, bPhi, bPsi, bChi, bOmega, oenv);
     }