Project

General

Profile

Bug #1976

make_ndx "AND" keyword seems broken

Added by Chris Neale over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
analysis tools
Target version:
Affected version - extra info:
Affected version:
Difficulty:
uncategorized
Close

Description

I have tried using the 'AND' keyword, which is noted in the gmx make_ndx -h output. Indeed, the word "AND" replaces the ampersand in the index group in this case. However, the selection seems broken to me. Details are below. Specifically, with the '&' between selection of one atom name and one residue number, I get one atom in the group, as expected. However, when I use the 'AND' keyword, "r" seems to get promoted to "R" and then (for this or other reasons) the selection of one particular residue is not honored.

NOTE: same behaviour if using "AND" or "and"

In the following, note that there are 128 lipids and that each lipid has a single atom names C316. Therefore selecting a single residue and a name of C316 should give a single atom.

$ echo -e "aC316 AND r1 \n aC316 & r1 \n q \n" | gmx make_ndx -f start.gro -o rdf.ndx
                 :-) GROMACS - gmx make_ndx, VERSION 5.1.2 (-:

                            GROMACS is written by:
     Emile Apol      Rossen Apostolov  Herman J.C. Berendsen    Par Bjelkmar   
 Aldert van Buuren   Rudi van Drunen     Anton Feenstra   Sebastian Fritsch 
  Gerrit Groenhof   Christoph Junghans   Anca Hamuraru    Vincent Hindriksen
 Dimitrios Karkoulis    Peter Kasson        Jiri Kraus      Carsten Kutzner  
    Per Larsson      Justin A. Lemkul   Magnus Lundborg   Pieter Meulenhoff 
   Erik Marklund      Teemu Murtola       Szilard Pall       Sander Pronk   
   Roland Schulz     Alexey Shvetsov     Michael Shirts     Alfons Sijbers  
   Peter Tieleman    Teemu Virolainen  Christian Wennberg    Maarten Wolf   
                           and the project leaders:
        Mark Abraham, Berk Hess, Erik Lindahl, and David van der Spoel

Copyright (c) 1991-2000, University of Groningen, The Netherlands.
Copyright (c) 2001-2015, The GROMACS development team at
Uppsala University, Stockholm University and
the Royal Institute of Technology, Sweden.
check out http://www.gromacs.org for more information.

GROMACS is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1
of the License, or (at your option) any later version.

GROMACS:      gmx make_ndx, VERSION 5.1.2
Executable:   /home/cneale/exec/GROMACS/exec/gromacs-5.1.2/serial/bin/gmx
Data prefix:  /home/cneale/exec/GROMACS/exec/gromacs-5.1.2/serial
Command line:
  gmx make_ndx -f start.gro -o rdf.ndx

Reading structure file
Going to read 0 old index file(s)
Analysing residue names:
There are:   128      Other residues
There are:  6396      Water residues
There are:    34        Ion residues
Analysing residues not classified as Protein/DNA/RNA/Water and splitting into groups...
Analysing residues not classified as Protein/DNA/RNA/Water and splitting into groups...

  0 System              : 35862 atoms
  1 Other               : 16640 atoms
  2 DPPC                : 16640 atoms
  3 K                   :    17 atoms
  4 CL                  :    17 atoms
  5 Water               : 19188 atoms
  6 SOL                 : 19188 atoms
  7 non-Water           : 16674 atoms
  8 Ion                 :    34 atoms
  9 DPPC                : 16640 atoms
 10 K                   :    17 atoms
 11 CL                  :    17 atoms
 12 Water_and_ions      : 19222 atoms

 nr : group       !   'name' nr name   'splitch' nr    Enter: list groups
 'a': atom        &   'del' nr         'splitres' nr   'l': list residues
 't': atom type   |   'keep' nr        'splitat' nr    'h': help
 'r': residue         'res' nr         'chain' char
 "name": group        'case': case sensitive           'q': save and quit
 'ri': residue index

> 
Found 128 atoms with names C316 AND R1

 13 C316_AND_R1         :   128 atoms

> 
Found 128 atoms with name C316
Merged two groups with AND: 128 130 -> 1

 14 C316_&_r_1          :     1 atoms

> 
###

I did not test the "NOT" or OR" keywords, but they are probably suspect as well.

Thank you,
Chris.

Associated revisions

Revision 13e0dc71 (diff)
Added by Teemu Murtola over 3 years ago

Improve make_ndx help text

Clarify the use of boolean operators. The old help text could
incorrectly hint that AND, OR, and NOT would work as keywords.
Add a reference to gmx select that in most cases can serve as a
replacement.

Fixes #1976.

Change-Id: I0284c849c398e5b09569453d7d0f19b9639a6d0c

History

#1 Updated by Teemu Murtola over 3 years ago

It seems that the help text is just misleading. Looking at your output, make_ndx just treats AND as a string, and finds atoms that have one of the three atom names it was provided. To use an and operation, only & seems to be supported (and this is the only thing mentioned in the inline list of commands in the prompt).

#2 Updated by Chris Neale over 3 years ago

So the idea is that AND, OR, and NOT operations are supported but that these words are not interpreted as such and that to get an AND operation one has to use & ? That seems fair enough, though I then suggest that this is documented as such (suggested modification between double stars):

You can use NOT, AND and OR by using the symbols !, & and |, you can split groups into chains, residues
or atoms.

When you say "the inline list of commands in the prompt", I presume you refer to this:

 nr : group       !   'name' nr name   'splitch' nr    Enter: list groups
 'a': atom        &   'del' nr         'splitres' nr   'l': list residues
 't': atom type   |   'keep' nr        'splitat' nr    'h': help
 'r': residue         'res' nr         'chain' char
 "name": group        'case': case sensitive           'q': save and quit
 'ri': residue index

and though I agree that those symbols are included there, there is no definition of them. Here is what I get from gmx make_ndx -h and it would be easier to understand if that information was complete since "-h" is frequently where one turns when they want to know how to use a tool:

$ gmx make_ndx -h
                 :-) GROMACS - gmx make_ndx, VERSION 5.1.2 (-:

                            GROMACS is written by:
     Emile Apol      Rossen Apostolov  Herman J.C. Berendsen    Par Bjelkmar
 Aldert van Buuren   Rudi van Drunen     Anton Feenstra   Sebastian Fritsch
  Gerrit Groenhof   Christoph Junghans   Anca Hamuraru    Vincent Hindriksen
 Dimitrios Karkoulis    Peter Kasson        Jiri Kraus      Carsten Kutzner
    Per Larsson      Justin A. Lemkul   Magnus Lundborg   Pieter Meulenhoff
   Erik Marklund      Teemu Murtola       Szilard Pall       Sander Pronk
   Roland Schulz     Alexey Shvetsov     Michael Shirts     Alfons Sijbers
   Peter Tieleman    Teemu Virolainen  Christian Wennberg    Maarten Wolf
                           and the project leaders:
        Mark Abraham, Berk Hess, Erik Lindahl, and David van der Spoel

Copyright (c) 1991-2000, University of Groningen, The Netherlands.
Copyright (c) 2001-2015, The GROMACS development team at
Uppsala University, Stockholm University and
the Royal Institute of Technology, Sweden.
check out http://www.gromacs.org for more information.

GROMACS is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1
of the License, or (at your option) any later version.

GROMACS:      gmx make_ndx, VERSION 5.1.2
Executable:   /oasis/scratch/comet/cneale/temp_project/exec/gromacs-5.1.2/exec_serial/bin/gmx
Data prefix:  /oasis/scratch/comet/cneale/temp_project/exec/gromacs-5.1.2/exec_serial
Command line:
  gmx make_ndx -h

SYNOPSIS

gmx make_ndx [-f [<.gro/.g96/...>]] [-n [<.ndx> [...]]] [-o [<.ndx>]]
             [-natoms <int>] [-[no]twin]

DESCRIPTION

Index groups are necessary for almost every GROMACS program. All these
programs can generate default index groups. You ONLY have to use gmx make_ndx
when you need SPECIAL index groups. There is a default index group for the
whole system, 9 default index groups for proteins, and a default index group
is generated for every other residue name.

When no index file is supplied, also gmx make_ndx will generate the default
groups. With the index editor you can select on atom, residue and chain names
and numbers. When a run input file is supplied you can also select on atom
type. You can use NOT, AND and OR, you can split groups into chains, residues
or atoms. You can delete and rename groups.

The atom numbering in the editor and the index file starts at 1.

The -twin switch duplicates all index groups with an offset of -natoms, which
is useful for Computational Electrophysiology double-layer membrane setups.

OPTIONS

Options to specify input files:

 -f      [<.gro/.g96/...>]  (conf.gro)       (Opt.)
           Structure file: gro g96 pdb brk ent esp tpr
 -n      [<.ndx> [...]]     (index.ndx)      (Opt.)
           Index file

Options to specify output files:

 -o      [<.ndx>]           (index.ndx)
           Index file

Other options:

 -natoms <int>              (0)
           set number of atoms (default: read from coordinate or index file)
 -[no]twin                  (no)
           Duplicate all index groups with an offset of -natoms

#3 Updated by Chris Neale over 3 years ago

PS: this was not a pedantic tirade. I was actually looking for an alternative to the '&' character, which gave me pains when piping:

https://mailman-1.sys.kth.se/pipermail/gromacs.org_gmx-users/2016-May/105817.html

Justin's suggestion to rename based on group numbers (see further in the same gmx-users thread) was pretty good but I also find that some versions of gromacs make duplicate group for non-protein atoms (it's own pain) so the version-specifics of group numbers make_ndx can not be predicted in scripts that are intended to function from one version of gromacs to the next.

#4 Updated by Mark Abraham over 3 years ago

  • Description updated (diff)

#5 Updated by Teemu Murtola over 3 years ago

Chris Neale wrote:

PS: this was not a pedantic tirade. I was actually looking for an alternative to the '&' character, which gave me pains when piping:

https://mailman-1.sys.kth.se/pipermail/gromacs.org_gmx-users/2016-May/105817.html

Justin's suggestion to rename based on group numbers (see further in the same gmx-users thread) was pretty good but I also find that some versions of gromacs make duplicate group for non-protein atoms (it's own pain) so the version-specifics of group numbers make_ndx can not be predicted in scripts that are intended to function from one version of gromacs to the next.

I seem to recall that gmx select was also mentioned there as an alternative to make _ndx. Is there something wrong with, e.g., the below command?

gmx select -on -select '"MyGroupName" name C316 and resnr 1'

That said, I agree that the help text could be improved.

#6 Updated by Chris Neale over 3 years ago

I have nothing against gmx select. Just reporting to try to improve the tools that exist.

#7 Updated by Gerrit Code Review Bot over 3 years ago

Gerrit received a related patchset '1' for Issue #1976.
Uploader: Teemu Murtola ()
Change-Id: I0284c849c398e5b09569453d7d0f19b9639a6d0c
Gerrit URL: https://gerrit.gromacs.org/5916

#8 Updated by Teemu Murtola over 3 years ago

  • Category set to analysis tools
  • Status changed from New to Fix uploaded
  • Assignee set to Teemu Murtola
  • Target version set to 2016

#9 Updated by Teemu Murtola over 3 years ago

  • Status changed from Fix uploaded to Resolved

#10 Updated by Erik Lindahl over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF