Combining multiple trajectory files into a single trajectory and remove water molecules to save space.
When simulations start to get long, the raw trajectory files can start to get very large. It is also sometimes more convenient (and faster) to perform analysis in a stripped trajectory (i. e. without explicit water molecules). This script first reads the required parameter file, reads in and combines different trajectory files (trajectoryN.nc), executes the autoimage command to re-orient the solute molecules, strips the water moles, performs an RMS fit of the residues from 1 to 24 and writes a new NetCDF trajectory with the name: nowater.nc.
Also, the trajin command which reads each individual trajectory file, is reading from the first frame to the last frame, with an offset of 10 frames (reading every other 10th frame). This also helps saving space and speeding up the trajin command.
parm topology-file.prmtop trajin trajectory01.nc 1 last 10 trajin trajectory02.nc 1 last 10 trajin trajectory03.nc 1 last 10 trajin trajectory04.nc 1 last 10 trajin trajectory05.nc 1 last 10 autoimage strip :WAT rms fit :1-24 trajout nowater.nc go
There are a few short-cuts that can be applied here. For example, if your trajectory files have a sequential number, you can use the file wildcards (*,?).
parm topology-file.prmtop trajin trajectory*.nc 1 last 10 autoimage strip :WAT rms fit :1-24 trajout nowater.nc go
Another example is to use a
for cycle within CPPTRAJ:
for i=1;i<4;i++ trajin trajectory.$i 1 last 10 done
parm topology-file.prmtop parmstrip :WAT parmwrite out topology-no_water.prmtop go