[gmx-users] Invalid selection near '&' syntax error -- easy way to avoid?

Teemu Murtola teemu.murtola at gmail.com
Tue May 24 21:00:06 CEST 2016


Hi,

On Tue, May 24, 2016 at 8:22 PM Christopher Neale <
chris.neale at alum.utoronto.ca> wrote:

> Thank you for the help. After a but of fiddling your suggestion did lead
> to the solution:
>
> echo -e "\"group_&_1\"\n\"group_&_2\" | gmx ...
>
> Is this really what you had in mind?


That will work, although you will have less escaping if you use single
quotes like

echo -e '"group_&_1"\n"group_&_2"' | gmx ...

or

gmx rdf -ref '"group_&_1"' -sel '"group_&_2"' ...


> If so, I think I'll still submit a feature request since I doubt we can
> expect all users to come up with that on their own.


This is documented in the help that you can access with 'help syntax' in
the interactive selection prompt, or, e.g., here: <
http://manual.gromacs.org/documentation/5.1.2/onlinehelp/selections.html#selection-syntax
>

"Strings that contain non-alphanumeric characters should be enclosed in
double quotes as in the examples."

It is impractical to write a parser that can guess what the user tries to
mean with all kinds of weird strings that can have other meanings; what
would you, for example, expect to happen if you create an index group named
"x-y<3" or "resname GLY", and then just type that as the selection, without
quotes? Treating some punctuation characters differently from others would
not provide a very intuitive syntax, either...

I think a reasonable resolution for such a feature request would be to add
an explicit example of selecting such a group in the selection examples.

And if you think make_ndx creates groups that are inconveniently named and
you cannot robustly rename them, you can use gmx select to create exactly
the same groups (with the exception of the splitting options in make_ndx),
and also provide names for them in one go.


> Also, interactive selection is not available with all tools (see e.g. gmx
> traj).
>

I'm not sure what you are referring to with this. Yes, the selection syntax
is not available for all tools, and that is a valid reason to use index
files. But for tools that support them, I think it is still clearer to pass
the selections as command-line arguments instead of piping them. And there
are cases where it is very difficult to pipe the proper selections.

Best regards,
Teemu


More information about the gromacs.org_gmx-users mailing list