*FILENAME: merge-orient-trajectory.inp
*PURPOSE: merge trajectories, orienting wrt initial protein coordinates, and removing solvent
*AUTHOR: Lennart Nilsson, Karolinska Institutet, October 2003
!unix environment variable CHM_HOME points to CHARMM installation directory
read rtf card name $CHM_HOME/toppar/top_all22_prot.inp
read para card name $CHM_HOME/toppar/par_all22_prot.inp
read psf card name my_psf.psf
read coor card name my_reference.crd
! put reference coordinates into comparison set as well
coor copy comp
! Initial trajectory
open unit 51 read unform name traj_1.cor
open unit 52 read unform name traj_2.cor
! New, merged trajectory
open unit 81 write unform name traj_orient_nosolv.cor

merge first 51 nunit 2 output 81 skip 500 - ! one frame/ps is all we need
sele segid prot end orient mass sele segid prot .and. .not. hydrogen end
! first selection picks up those atoms that will be written to new trajectory
! second selection is used in the least squares re-orienting of each frame

! save new psf that is compatible with the new trajectory
delete atom sele .not. segid prot end

write psf card name new_psf.psf
* psf after deleting everything but the protein segment

Lennart Nilsson
Karolinska Institutet
Stockholm, Sweden