From 1ba341e0abf6ffeaa7fadc709bd6ed87d8adc0d4 Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Thu, 12 Aug 2021 09:51:42 +0000 Subject: [PATCH] Fix bugs in gmx chi and gmx angle Some of these bugs have been present for several years. They were introduced during refactorings in commits aa286ff6, 73b83321, and 89b03397. --- docs/release-notes/2021/2021.3.rst | 22 ++++++++++++++++++++++ src/gromacs/gmxana/anadih.cpp | 4 ++-- src/gromacs/gmxana/gmx_chi.cpp | 9 +++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/docs/release-notes/2021/2021.3.rst b/docs/release-notes/2021/2021.3.rst index ef0cd80ca0..fc8e40e769 100644 --- a/docs/release-notes/2021/2021.3.rst +++ b/docs/release-notes/2021/2021.3.rst @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/gromacs/gmxana/anadih.cpp b/src/gromacs/gmxana/anadih.cpp index 3a3a952f31..5489ffac6f 100644 --- a/src/gromacs/gmxana/anadih.cpp +++ b/src/gromacs/gmxana/anadih.cpp @@ -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; } diff --git a/src/gromacs/gmxana/gmx_chi.cpp b/src/gromacs/gmxana/gmx_chi.cpp index c30d7e641d..d049f74b88 100644 --- a/src/gromacs/gmxana/gmx_chi.cpp +++ b/src/gromacs/gmxana/gmx_chi.cpp @@ -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++) -- 2.22.0