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

In order to visualize this new trajectory (nowater.nc) now we need a topology file with no waters.  We can create a new topology using the parmstrip and parmwrite commands:

parm topology-file.prmtop
parmstrip :WAT
parmwrite out topology-no_water.prmtop
go

We can also combine the preprocess of the trajectories and the creation of a new stripped topology in a single step. With the parmout keyword in the strip command, we can write the stripped topology:

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
## Use strip command. Write out stripped topology
strip :WAT nobox parmout topology-no_water.prmtop
rms fit :1-24 
trajout nowater.nc go