From 28a95c8a6c24e9e6e38c961879b3f024684fcb6d Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Tue, 7 Sep 2021 07:21:36 +0200 Subject: [PATCH] Remove ResidueTypeMap dependency from gmx chi This dependency had the sole effect of making the tool harder to use when residue names unknown to GROMACS were used. The dihedrals are found from the atom names, and the residue name is used only for reporting results, so there is no reason to require the user to add the name to an arbitrary list. --- docs/release-notes/2022/major/tools.rst | 12 ++++++++--- src/gromacs/gmxana/dlist.cpp | 27 ++++++++----------------- src/gromacs/gmxana/gmx_chi.cpp | 10 ++------- src/gromacs/gmxana/gstat.h | 18 ++++++++--------- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/docs/release-notes/2022/major/tools.rst b/docs/release-notes/2022/major/tools.rst index fdc5086b69..e35b1f3e8f 100644 --- a/docs/release-notes/2022/major/tools.rst +++ b/docs/release-notes/2022/major/tools.rst @@ -7,8 +7,8 @@ Improvements to |Gromacs| tools Also, please use the syntax :issue:`number` to reference issues on GitLab, without the a space between the colon and number! -gmx msd has been migrated to the trajectoryanalysis framework -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +``gmx msd`` has been migrated to the trajectoryanalysis framework +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" The tool now uses the |Gromacs| selection syntax. Rather than piping selections via stdin, selections are now made using the "-sel" option. @@ -23,4 +23,10 @@ Some rarely used features have yet to be migrated, including: - System COM removal with -rmcomm has not yet been implemented. - B-factor writing using the -pdb option is not yet supported. -:issue:`2368` \ No newline at end of file +:issue:`2368` + +``gmx chi`` no longer needs ``residuetypes.dat`` entries for custom residues +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +The need to add the names of custom residues to ``residuetypes.dat`` has been +removed, because it served no purpose. This makes ``gmx chi`` easier to use. diff --git a/src/gromacs/gmxana/dlist.cpp b/src/gromacs/gmxana/dlist.cpp index c6536b8aa5..d4fe29fc64 100644 --- a/src/gromacs/gmxana/dlist.cpp +++ b/src/gromacs/gmxana/dlist.cpp @@ -46,15 +46,14 @@ #include "gromacs/topology/topology.h" #include "gromacs/utility/fatalerror.h" -std::vector mk_dlist(FILE* log, - const t_atoms* atoms, - gmx_bool bPhi, - gmx_bool bPsi, - gmx_bool bChi, - gmx_bool bHChi, - int maxchi, - int r0, - const ResidueTypeMap& residueTypeMap) +std::vector mk_dlist(FILE* log, + const t_atoms* atoms, + gmx_bool bPhi, + gmx_bool bPsi, + gmx_bool bChi, + gmx_bool bHChi, + int maxchi, + int r0) { int i, j, ii; t_dihatms atm, prev; @@ -227,16 +226,6 @@ std::vector mk_dlist(FILE* log, nc[6]++; } - /* Prevent use of unknown residues. If one adds a custom residue to - * residuetypes.dat but somehow loses it, changes it, or does analysis on - * another machine, the residue type will be unknown. */ - if (residueTypeMap.find(thisres) == residueTypeMap.end()) - { - gmx_fatal(FARGS, - "Unknown residue %s when searching for residue type.\n" - "Maybe you need to add a custom residue in residuetypes.dat.", - thisres); - } dl[nl].residueName = thisres; sprintf(dl[nl].name, "%s%d", thisres, ires + r0); diff --git a/src/gromacs/gmxana/gmx_chi.cpp b/src/gromacs/gmxana/gmx_chi.cpp index 0ca1075c6e..515224cd04 100644 --- a/src/gromacs/gmxana/gmx_chi.cpp +++ b/src/gromacs/gmxana/gmx_chi.cpp @@ -60,7 +60,6 @@ #include "gromacs/math/units.h" #include "gromacs/math/utilities.h" #include "gromacs/math/vec.h" -#include "gromacs/topology/residuetypes.h" #include "gromacs/topology/topology.h" #include "gromacs/utility/arraysize.h" #include "gromacs/utility/cstringutil.h" @@ -519,10 +518,7 @@ static void histogramming(FILE* log, } // Build a list of unique residue names found in the dihedral - // list, so we can loop over those unique names conveniently. The - // names are the same as the residue names found in residueTypeMap in the - // caller, but ResidueTypeMap doesn't yet have a way to loop over its - // contents. + // list, so we can loop over those unique names conveniently. std::unordered_set uniqueResidueNames; for (const auto& dihedral : dlist) { @@ -1530,9 +1526,7 @@ int gmx_chi(int argc, char* argv[]) } fprintf(log, "Title: %s\n", name); - ResidueTypeMap residueTypeMap = residueTypeMapFromLibraryFile("residuetypes.dat"); - std::vector dlist = - mk_dlist(log, &atoms, bPhi, bPsi, bChi, bHChi, maxchi, r0, residueTypeMap); + std::vector dlist = mk_dlist(log, &atoms, bPhi, bPsi, bChi, bHChi, maxchi, r0); fprintf(stderr, "%zu residues with dihedrals found\n", dlist.size()); if (dlist.empty()) diff --git a/src/gromacs/gmxana/gstat.h b/src/gromacs/gmxana/gstat.h index 3207566063..ec13293808 100644 --- a/src/gromacs/gmxana/gstat.h +++ b/src/gromacs/gmxana/gstat.h @@ -42,7 +42,6 @@ #include "gromacs/commandline/pargs.h" #include "gromacs/topology/index.h" -#include "gromacs/topology/residuetypes.h" struct gmx_output_env_t; @@ -255,15 +254,14 @@ gmx_bool has_dihedral(int Dih, const t_dlist& dlist); * the residues, and a mapping from chemical peptide atom names to * atom indices based on the atom names. Many fields of t_dlist are * not yet filled. */ -std::vector mk_dlist(FILE* log, - const t_atoms* atoms, - gmx_bool bPhi, - gmx_bool bPsi, - gmx_bool bChi, - gmx_bool bHChi, - int maxchi, - int r0, - const ResidueTypeMap& rt); +std::vector mk_dlist(FILE* log, + const t_atoms* atoms, + gmx_bool bPhi, + gmx_bool bPsi, + gmx_bool bChi, + gmx_bool bHChi, + int maxchi, + int r0); void pr_dlist(FILE* fp, gmx::ArrayRef dlist, -- 2.22.0