CPPTRAJ one-liners

Detailed description for most of these examples is available in the Running CPPTRAJ page.

Create a PDB file from a topology and a coordinate file. cpptraj -p topology-file.prmtop -y coordinate-file.coords -x output-file.pdb
Review how many frames are in a trajectory file cpptraj -p topology-file.prmtop -y coordinate-file.coords -tl
To read a file that contains CPPTRAJ commands cpptraj -i INPUTFILE
To inspect residue number one from a topology.
This also works for atoms using @1 instead of :1
cpptraj -p topology-file.prmtop --mask :1
To extract the charge from a residue. cpptraj -p topology-file.prmtop --charge :1

 Do RMSD analysis of the first molecule (which presumably is chain A)
use the ^ operator.
Then do RMSD of chain B (molecule 2) but still using the previous fit
(to molecule 1) you would add the nofit keyword

rms R0 first ^1&@C,CA,N out rms.R0.dat

rms R1 first ^2&@C,CA,N nofit out rms.R1.dat
To view more information (#Res, Name, First atom, Last atom, number of atoms, #Orig and #Mol) for residues one through ten. cpptraj -p topology-file.prmtop --resmask :1-10
To extract a single frame from a trajectory file, use the -ya keyword to send arguments to trajin cpptraj -p topology-file.prmtop -y trajectory-file.nc -ya 'lastframe' -x output-file.pdb
Quickly print the residues that are in a topology file cpptraj -p topology-file.prmtop --resmask \* This will print all the residues in the topology file

cpptraj -p topology-file.prmtop --resmask :100 This will print information about residue ID 100

Run a loop inside CPPTRAJ – Example 1
parm A.prmtop
for FRAME in 1,78,100,101,170
  trajin A.nc $FRAME $FRAME
done
Run a loop inside CPPTRAJ – Example 2
parm structure.psf

for i=1;i<2;i++
   trajin prod$i/output.xtc 1 250 1
   strip :SOD,CLA,TIP3,TIP,POPC
   autoimage
   rms first F$i @CA
   dataset F$i legend Rep$i
   distance A$i :1088@CA :1370@CA
   distance B$i :1116@CA :1157@CA
   distance C$i :1162@CA :1189@CA
   distance D$i :1268@CA :1306@CA
   distance E$i :1330@CA :1350@CA
   # Execute trajectory processing to actually calculate the distances
   go
   # Calculate a parameter from the distances
   A100.$i = -14.43 (A$i)-7.62*(B$i)+9.11*(C$i)-6.32* \(D$i)-5.22*(E$i)+278.88
   clear trajin
done
writedata test.dat A100.*