Removing non-interacting waters from a trajectory

GROMACS version: 2020.6
GROMACS modification: PLUMED patched

I tried searching for what would seem like a fairly common topic but couldn’t quite find the answer to this.

In the past I have just discarded water from my trajectories before visualising, but in this case I want to keep those waters which interact with a ligand in my system. I can use gmx select (“NearbyWaters” same resindex as (group “TIP3” and within 0.5 of group “LIG”)) but this gives me an index group for every frame. What I want instead is an index group containing all the waters that come within X distance of the ligand during the simulation. How do I turn this dynamic selection into a single index group?

If you just wanted to visualize the results, then you can use VMD to select water nearby (dynamic selection in each frame). In Gromacs, is it possible to convert to a trajectory with a different number of atoms in different frames? Of course, you can do it frame by frame and combine them, but when you visualize, it may not be able to do so as the number of atoms is not the same across frames.

I have VMD but am not very practiced in Tk scripting. I would prefer to convert to PDB and visualise in PyMol. I don’t mind if the frames themselves contain waters which are not currently interacting, I just want to create an index group which has all the waters which interact with the ligand during the simulation.

I’ve found a workaround which is to use a script to generate a “0 | 1 | 2 | 3 | 4 … etc.” string I can pipe to make_ndx, but I have to do it in segments of no more than ~150 groups otherwise the buffer overflows. I was just wondering if there’s a way to use gmx select to turn the n index groups into one single index group.

There is not. Support for dynamic indices is very limited at present and the limiting issue, as noted above, is that there isn’t a trajectory file format that supports frames with dissimilar numbers of atoms. I believe TNG was intended for that but I’m not sure where things stand in that regard.

I’m not sure if I’ve properly conveyed what I’m looking to do.

I don’t mind if the resulting trajectory contains frames in which there are non-interacting waters. I’m happy for the trajectory file to contain the same number of atoms in each frame. I’m just wondering if gmx select can output one index group containing all the waters that ever interact with the ligand, instead of an index group for each frame. i.e. some way to “OR” all the index groups into one in gmx select, without doing it manually with make_ndx

Probably the only way to do what you’re seeking is to use gmx trjorder to order the water molecules by their proximity to the protein and then create an index group with gmx make_ndx for the N closest water molecules (which are simply the first N water molecules in all frames).