Fix bugs in gmx chi and gmx angle
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 12 Aug 2021 09:51:42 +0000 (09:51 +0000)
committerAndrey Alekseenko <al42and@gmail.com>
Thu, 12 Aug 2021 09:51:42 +0000 (09:51 +0000)
Some of these bugs have been present for several years. They were
introduced during refactorings in commits aa286ff673b83321, and
89b03397.

docs/release-notes/2021/2021.3.rst
src/gromacs/gmxana/anadih.cpp
src/gromacs/gmxana/gmx_chi.cpp

index ef0cd80ca0c82c12a4f980659addf78a65080f4d..fc8e40e7692d76d1d28281120ef2423fb45ce0cb 100644 (file)
@@ -62,6 +62,28 @@ calculate the number of remaining steps correctly.
 
 :issue:`4056`
 
+Fixed dihedral transition counting in gmx chi and gmx angle
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+When a trajectory of only 1 frame is passed, transition counting is
+avoided (formerly it was attempted and crashed).
+
+When a trajectory of multiple frames is passed, transition counting is
+correct (formerly it did not take place).
+
+Fixed possible crash in gmx chi histogramming
+"""""""""""""""""""""""""""""""""""""""""""""
+
+Formerly an invalid reference to a temporary string was used for a
+residue name, which might have caused a crash.
+
+Fixed gmx chi -chi_prod
+"""""""""""""""""""""""
+
+Formerly it could crash or produce garbage results when the number of
+relevant dihedrals differed from the number of residues
+with dihedrals.
+
 Fixes that affect portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index 3a3a952f312d2fe0d68ae31e6e6c7ae50f6c57e8..5489ffac6f4ee0e0bb392491ef8dbd91e9306b4a 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -194,7 +194,7 @@ void low_ana_dih_trans(gmx_bool                bTrans,
     int (*calc_bin)(real, int, real);
     real dt;
 
-    if (1 <= nframes)
+    if (nframes <= 1)
     {
         return;
     }
index c30d7e641d61fd4e1668b4e998d8ece1b046e2f0..d049f74b8830713520d80f0c227db4e62bd04455 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, 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.
@@ -750,7 +750,8 @@ static void histogramming(FILE*                   log,
                     normalize_histo(nbin, his_aa[Dih][i], (360.0 / nbin), normhisto);
                 }
 
-                residue_name = rt->nameFromResidueIndex(i).c_str();
+                std::string residueName = rt->nameFromResidueIndex(i);
+                residue_name            = residueName.c_str();
                 switch (Dih)
                 {
                     case edPhi:
@@ -1526,7 +1527,7 @@ int gmx_chi(int argc, char* argv[])
     }
 
     /* put angles in -M_PI to M_PI ! and correct phase factor for phi and psi
-     * pass nactdih instead of ndih to low_ana_dih_trans and get_chi_product_traj
+     * pass nactdih instead of ndih to low_ana_dih_trans
      * to prevent accessing off end of arrays when maxchi < 5 or 6. */
     nactdih = reset_em_all(nlist, dlist, nf, dih, maxchi);
 
@@ -1606,7 +1607,7 @@ int gmx_chi(int argc, char* argv[])
         }
         mk_chi_lookup(chi_lookup, maxchi, nlist, dlist);
 
-        get_chi_product_traj(dih, nf, nactdih, maxchi, dlist, time, chi_lookup, multiplicity, FALSE,
+        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++)