Gmx select to get index of upper and lower leaflet residues in bilayer

GROMACS version: 2021.4
GROMACS modification: No
Command for getting index of residues in upper and lower leaflet of bilayer.
Assuming there is no before hand information about residues (resid) packed in upper and lower leaflets in initial configuration. I want to get the residue indexes using z-coordinate) criteria, (bilayer normal is in z direction). for example, if I have DPPC bilayer and I know there is P atom in DPPC headgroup. I want use following criteria in gmx select.

  1. get indexes of all P atoms having z coordinate higher than z value of bilayer COM.
  2. get indexes for all the DPPC molecules which has these P atoms (collected in step 1)
  3. last step would be choosing all DPPCs not in index of step 2.

how can we accomplish this using gmx select command?


I think it is possible to create a index group for upper and slower leaflet using z as reference. But maybe that some rethinking on the order of the definition is needed ( Here is selection syntax Selection syntax and usage — GROMACS 2021.4 documentation).

Maybe this conversation is useful