I was looking for a simple way to extract the last frame of a GROMACS trajectory. I came up with this script, which I ran to get the last frame of +3000 trajectories fast enough. I overlooked some opinions (here) that suggested dumping the whole thing and selecting the last frame. Instead, I went for an approach that parses out of the md.log file the last step (in my particular case, of the l-BFGS minimisation) and uses this together with trjconv‘s -dump flag.
The script below needs obviously some modifications if you intend to use it, but gives a rough idea of how to. Suggestions? :)
Because WordPress doesn’t support text-wrapping, I’m saving the script in
—-> HERE <——
for whoever needs to peek into it.
The algorithm, if you can call it so, is the following:
1. Iterate each folder with traj.trr and conf.gro files in there
2. Use make_ndx on conf.gro with a pre-written text file with whatever input you would give to make_ndx (don’t forget the q for quit!) * and redirect the output to /dev/null
3. Use trjconv with the traj.trr and the -n flag with the traj.ndx that make_ndx created, redirecting the output to a file if needed so (best).
4. Copy the produced frame somewhere else (optional).
* Check this link for an alternative to that text file.