Fix chain ID handling in make_ndx
authorPaul Bauer <paul.bauer.q@gmail.com>
Wed, 25 Sep 2019 14:36:01 +0000 (16:36 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 1 Oct 2019 10:02:39 +0000 (12:02 +0200)
The tool was still using the oldest possible way to read in structure
files, leading to issues with the chain IDs being overwritten and
replaced with the default id.

Fixes #3070
Refs #3113

Change-Id: I25112103a043d0266fe64c7619fe8e4abc56ffa5

docs/release-notes/2019/2019.4.rst
src/gromacs/gmxana/gmx_make_ndx.cpp

index 087c8c32f1197ef6760f98f18af8717a6c754d88..ec0a89d4fc20f5152a5efcf81240a610ccc97230 100644 (file)
@@ -128,6 +128,14 @@ indices in the index file.
 
 :issue:`3107`
 
+Made gmx make_ndx keep chain IDs
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+Old style structure file reading caused the chain IDs to be overwritten with
+default values.
+
+:issue:`3070`
+
 Fixes that affect portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index a1ece34082621009d40c838364865a44fc426472..f479eefd806a8db5474cb632a82a742b33f8dd1b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -47,6 +47,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/topology/block.h"
 #include "gromacs/topology/index.h"
+#include "gromacs/topology/mtop_util.h"
 #include "gromacs/topology/topology.h"
 #include "gromacs/utility/arraysize.h"
 #include "gromacs/utility/cstringutil.h"
@@ -1557,7 +1558,7 @@ int gmx_make_ndx(int argc, char *argv[])
     const char       *ndxoutfile;
     gmx_bool          bNatoms;
     int               j;
-    t_atoms          *atoms;
+    t_atoms           atoms;
     rvec             *x, *v;
     int               ePBC;
     matrix            box;
@@ -1586,23 +1587,23 @@ int gmx_make_ndx(int argc, char *argv[])
         gmx_fatal(FARGS, "No input files (structure or index)");
     }
 
+    gmx_mtop_t mtop;
     if (stxfile)
     {
-        t_topology *top;
-        snew(top, 1);
+        bool haveFullTopology = false;
         fprintf(stderr, "\nReading structure file\n");
-        read_tps_conf(stxfile, top, &ePBC, &x, &v, box, FALSE);
-        atoms = &top->atoms;
-        if (atoms->pdbinfo == nullptr)
+        readConfAndTopology(stxfile, &haveFullTopology, &mtop,
+                            &ePBC, &x, &v, box);
+        atoms = gmx_mtop_global_atoms(&mtop);
+        if (atoms.pdbinfo == nullptr)
         {
-            snew(atoms->pdbinfo, atoms->nr);
+            snew(atoms.pdbinfo, atoms.nr);
         }
-        natoms  = atoms->nr;
+        natoms  = atoms.nr;
         bNatoms = TRUE;
     }
     else
     {
-        atoms = nullptr;
         x     = nullptr;
     }
 
@@ -1631,7 +1632,7 @@ int gmx_make_ndx(int argc, char *argv[])
     else
     {
         snew(gnames, 1);
-        analyse(atoms, block, &gnames, FALSE, TRUE);
+        analyse(&atoms, block, &gnames, FALSE, TRUE);
     }
 
     if (!bNatoms)
@@ -1640,7 +1641,7 @@ int gmx_make_ndx(int argc, char *argv[])
         printf("Counted atom numbers up to %d in index file\n", natoms);
     }
 
-    edit_index(natoms, atoms, x, block, &gnames, bVerbose);
+    edit_index(natoms, &atoms, x, block, &gnames, bVerbose);
 
     write_index(ndxoutfile, block, gnames, bDuplicate, natoms);