Anyway to remove first frame from .trr without specifying the time?

GROMACS version:2020.4
GROMACS modification: No


I am having problems using trjcat with chunks of a long simulation, where it seems to drop a handful (tens) of frames at the boundaries between chunks, leaving gaps in the trajectory .trr. Since this problem does not occur for shorter simulations, I suspect that the problem is that trjcat uses the timestamps to match up frames, but the recorded times become unstable for trajectories with large numbers of steps. All I really need to do is manually remove the first frame from each chunk and then I could just do an ordinary cat. But looking at the options for gmx trjconv, I see no way to simply remove the first frame without specifying it’s time, which as I noted is iffy. I should note that I need to work with the .trr format as I am recording velocities and forces.

Is there any simple way to remove the first frame from a trajectory without knowing it’s timestamp? I could of course try to gmx dump the output and then do it manually, but that seems clunky and I would like to avoid unnecessary duplication of data since I have large files.


I think a trjcat from a double precision trjcat should do the right thing. The only issue is that you then get a double precision output trr. A single precision trjconv can convert that back again.

I am preparing a fix for this. It should just be a matter of changing the time variables from single to double precision.

If all your frames have equal size, all only x or all both x and v, you can manually do it. You can compute the number of bytes in s single frame, by dumping a single frame or dividing the size of the trajectory by the number of frames. Then you can use a command line tool (forgot which) to en extract the last numbytes_total - numbytes_frame bytes.

Could you try the modified trjcat below? It is for version 2021. I renamed it to .log to be able to attach the file here. You should copy it to src/gromacs/tools/trjcat.cpp and make and install.

trjcat.log (33.2 KB)