Project

General

Profile

Bug #2785

Inconsistent and erroneous behaviour of trjconv when writing a partial TNG

Added by Jonathan Barnoud 12 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Affected version - extra info:
2019-beta3, 2018, 2016
Affected version:
Difficulty:
uncategorized
Close

Description

I try to convert a trajectory to a TNG file, but keeping only a selection of atoms. Depending on the format of my input files, I get inconsistent behaviours.

  • If I work from a TRR or GRO file and a TPR file, then I get the expected particles written, but I loose the connectivity in the same manner as in convert-tpr. All the particles are fit in the same molecule.

With the attached input files, running the following commands

echo 2 | gmx trjconv -f input.gro -s input.tpr -o output.tng
gmx dump -f output.tng | head -n 20

results in the following output (annotations added afterwards):

...  # <- skip the copyright notice
Command line:
  gmx dump -f output.tng

Molecule: DOPC, count: 1  # <- there are 504 DOPC molecules
    Chain: 
        Residue: DOPC
            Atom: NC3 (Q0)
            Atom: PO4 (Qa)
            Atom: GL1 (Na)
            Atom: GL2 (Na)
            Atom: C1A (C1)
            Atom: D2A (C3)
            Atom: C3A (C1)
            Atom: C4A (C1)
            Atom: C1B (C1)
            Atom: D2B (C3)
            Atom: C3B (C1)
            Atom: C4B (C1)
            Atom: NC3 (Q0)  # <- The molecule definition should end
            Atom: PO4 (Qa)  #    before this line
            Atom: GL1 (Na)
            Atom: GL2 (Na)
            Atom: C1A (C1)
  • If I work from a TNG file and a TPR or a NDX file, then all the atoms are written in the resulting TNG file, regardless of the selection.

Running the following commands:

# Build a TNG with the whole system. This works as expected and outputs
# a TNG with the full topology including the connectivity.
echo 0 | gmx trjconv -f input.gro -s input.tpr -o input.tng

# Select some atoms from the TNG file
echo 2 | gmx trjconv -f input.tng -n input.ndx -o output.tng
gmx dump -f output.tng | head -n 20

results in the following output:

...  # <- skip the copyright notice
Command line:
  gmx dump -f output.tng

Molecule: DOPC, count: 504  # <- this is what is expected
    Chain: 
        Residue: DOPC
            Atom: NC3 (Q0)
            Atom: PO4 (Qa)
            Atom: GL1 (Na)
            Atom: GL2 (Na)
            Atom: C1A (C1)
            Atom: D2A (C3)
            Atom: C3A (C1)
            Atom: C4A (C1)
            Atom: C1B (C1)
            Atom: D2B (C3)
            Atom: C3B (C1)
            Atom: C4B (C1)
Molecule: W, count: 2634  # <- this was not part of the selection
    Chain: 
        Residue: W
            Atom: W (P4)
output.tng frame 0:
   natoms=      8682  step=         0  time=0.0000000e+00  prec=      1000
   POSITIONS (8682x3):  # <- I asked for only 6048 particles, 8682 is the whole system

The TPR is old (2018.1) but I experienced these issues with gromacs 2019-beta3. I can reproduce the first behaviour with older versions of gromacs (2018.1, 2016.3), I cannot reproduce the second issue on older versions because of #2187.

I always get the expected behaviour when I write the whole system in the TNG file.

input.ndx (154 KB) input.ndx Jonathan Barnoud, 11/30/2018 02:32 PM
input.gro (585 KB) input.gro Jonathan Barnoud, 11/30/2018 02:32 PM
input.tpr (280 KB) input.tpr Jonathan Barnoud, 11/30/2018 02:32 PM

Also available in: Atom PDF