Gmx select

GROMACS version: 2020.1
GROMACS modification: No
I have a lamellar system consisting of four bilayers. After the equilibration run, the bilayers get diffused. So now I want to split each bilayer and do a separate analysis. For separating each bilayer I am using gmx select tool, but every time it is giving me a syntax error. Like I have tried - “group 0 30 < z < 40” and also “resname PPG within 40 of PPT” and then “group 0 z > 30 & z < 40”. But none of the selection criteria is working. All of them are giving me the same syntax error. So can anyone can help me in getting the right selection criteria, as I am totally new to using gmx select command. Though I have gone to the manual and read about selection tools and methods it is not helping much. I am attaching a snapshot of my system. I want to select all atoms within the z ranging from 30nm to 40nm.
Screenshot from 2021-08-26 13-11-22

Hi Ezio,

a couple of siggestions:

  • have you tried parsing an auxillary variable?
  • have you tried using ‘and’ instead of ‘&’?

resname PPG and z > 30 and z < 40
or maybe something like:
rdist = res_com distance from ...
resname PPG and rdist < ...

Thanks for the suggestion. I have tried the following:
gmx select -f …/…/npt.xtc -s …/…/npt.tpr -select ‘name GL1 and z>32.257 and z<42.379’ -b 5000000 -e 5000000 -on output.ndx and its working. But one hindrance I am facing is that it is selecting only the GL1 atoms and not the complete molecules which have GL1 as one of the atoms. Can you please comment on that?

Yes, a ‘crude’ selection will indeed split molecules apart.
If you want to select whole molecules instead of single atoms, you should use the res_com directive and parse an auxillary variable

> zc = res_com z
> resname RES and zc>32.257 and zc<42.379

It is probably better in this case to pass a text file via cat <file_name> | gmx select ..., since the selection syntax may become a bit verbose

Thanks for your suggestion. It worked but partly. When using your command it is giving me some broken molecule in the gro file.
So, what I want is that the command should select the whole molecule of lipid which is falling within the given range of Z. I have tried using “whole_res_com”, “whole_mol_com” but it is not giving any the desired result.

Mhh… I wasn’t even aware of the existance of whole_res_com, but is sounds strange to me you are not able to select the whole residue by using res_com.

Maybe you actually want to select more than one residue; you can parse the selection for each residue you want to obtain; I don’t believe you need to re-define the auxillary variable every time.


zc = res_com z
> resname RS1 and zc>32.257 and zc<42.379
> resname RS2 and zc>32.257 and zc<42.379
> ...

Something like that.

I think you want same residue as ... in your selection. That way, any atoms that fall within the specified coordinate range then trigger the selection of the whole molecule to which they belong:

same residue as resname RES and z>32.257 and z<42.379