#$AMBERHOME/cpptraj -i pca.cpptraj > pca.out
#
#read in prmtops for each system
parm ol15.prmtop [dna]
parm strip.ol15.prmtop [strip]

#read in traj
trajin bsc1.nc parm [dna]
trajin ol15.nc parm [dna]

#strip H and terminal bp
strip @H=|:1,2,11,12-14,23,24

#rms-fit to first frame
rms first

#create an average structure
average dna-avg.rst7

#save coordinates as 'crd1'
createcrd crd1
run

#fit to average structure
reference dna-avg.rst7 parm strip.ol15.prmtop

#rms-fit to average structure
crdaction crd1 rms ref dna-avg.rst7

#calculate coordinate covariance matrix
crdaction crd1 matrix covar name dna-pca-Covar

#diagonalize coordinate covariance matrix, get first 5 evecs, generate nmwiz file for viewing in VMD
runanalysis diagmatrix dna-pca-Covar name mymodes out dna-pca-evecs.dat vecs 5 nmwiz nmwizvecs 5 nmwizfile dna.nmd parmindex 1

#create projections for the trajectory and histograms, split frames based on P1 for bsc1, P2 for ol15
crdaction crd1 projection P1 modes mymodes beg 1 end 5 crdframes 1,504073
crdaction crd1 projection P2 modes mymodes beg 1 end 5 crdframes 504074,1010811

#histogram the first 5 projections for each
hist P1:1,*,*,*,100 out bsc1-pca.hist.dat.1 norm name P1-1
hist P1:2,*,*,*,100 out bsc1-pca.hist.dat.2 norm name P1-2
hist P1:3,*,*,*,100 out bsc1-pca.hist.dat.3 norm name P1-3
hist P1:4,*,*,*,100 out bsc1-pca.hist.dat.4 norm name P1-4
hist P1:5,*,*,*,100 out bsc1-pca.hist.dat.5 norm name P1-5
#
hist P2:1,*,*,*,100 out ol15-pca.hist.dat.1 norm name P2-1
hist P2:2,*,*,*,100 out ol15-pca.hist.dat.2 norm name P2-2
hist P2:3,*,*,*,100 out ol15-pca.hist.dat.3 norm name P2-3
hist P2:4,*,*,*,100 out ol15-pca.hist.dat.4 norm name P2-4
hist P2:5,*,*,*,100 out ol15-pca.hist.dat.5 norm name P2-5
#