#!/bin/tcsh
module load vmd
set mypdb = ${1}
set mync = ${2}
set mytrr = `echo ${1} | sed -e 's/.pdb/.trr/'`
#set protein = `echo ${1} | sed -e 's/.prm/_protein_prm.prm/'`

cat > nc2trr_${mypdb}.tcl <<EOF
# VMD for LINUX, version 1.8.7a37 (October 9, 2008)
menu files off
menu files on
animate style Loop
display resetview
mol addrep 0
display resetview
mol new {${PWD}/${mypdb}} type {pdb} first 0 last -1 step 1 waitfor 1
mol addfile {${PWD}/${mync}} type {netcdf} first 0 last -1 step 1 waitfor -1 0
menu save off
menu save on
animate write trr {${PWD}/${mytrr}} beg 1 end -1 skip 1 0
menu save off
quit
# VMD for LINUX, version 1.8.7a37 (October 9, 2008)
# end of log file.
EOF

vmd -e nc2trr_${mypdb}.tcl -dispdev none
rm -f nc2trr_${mypdb}.tcl



#END
#set mypro [atomselect top protein]
#animate write pdb {${PWD}/${protein}} beg 0 end 0 skip 1 sel \$mypro 0 
