#!/bin/bash

ptraj_file="tmp.ptraj"
OUT="50ns_noWAT_500frames_noATP_noH"

REF="1XCK_chainA_sol.inpcrd"

PRMTOP="../../1XCK_rhod_MGATP_noWAT.prmtop"

TRAJIN[1]="../traj/1-25ns_2500frames_noWAT.nc"
TRAJIN[2]="../traj/26-50ns_2500frames_noWAT.nc"
TRAJIN[3]="../traj/51-75ns_2500frames_noWAT.nc"
TRAJIN[4]="../traj/76-100ns_2500frames_noWAT.nc"


MASK[1]=":1-524,5765-6288,6289-6812"
MASK[2]=":525-1048,5241-5764,5765-6288"
MASK[3]=":1049-1572,4717-5240,5241-5764"
MASK[4]=":1573-2096,4193-4716,4717-5240"
MASK[5]=":2097-2620,3669-4192,4193-4716"
MASK[6]=":2621-3144,3669-4192,6813-7336"
MASK[7]=":3145-3668,6289-6812,6813-7336"

#MASK[1]=":1-524,5765-6288,6289-6812,7337-7338"
#MASK[2]=":525-1048,5241-5764,5765-6288,7339-7340"
#MASK[3]=":1049-1572,4717-5240,5241-5764,7341-7342"
#MASK[4]=":1573-2096,4193-4716,4717-5240,7343-7344"
#MASK[5]=":2097-2620,3669-4192,4193-4716,7345-7346"
#MASK[6]=":2621-3144,3669-4192,6813-7336,7347-7348"
#MASK[7]=":3145-3668,6289-6812,6813-7336,7349-7350"





rm ${ptraj_file}

for index in 1 2 3 4 5 7;
do
        echo 'trajin '${DIR[index]}${TRAJIN[1]} 1 2500 10 >> ${ptraj_file}
        echo 'trajin '${DIR[index]}${TRAJIN[2]} 1 2500 10 >> ${ptraj_file}
        #echo 'trajin '${DIR[index]}${TRAJIN[3]} 1 2500 1 >> ${ptraj_file}
        #echo 'trajin '${DIR[index]}${TRAJIN[4]} 1 2500 1 >> ${ptraj_file}

        echo "strip '* & !"${MASK[index]}"'" >> ${ptraj_file}
        echo "strip @H*" >> ${ptraj_file}

	echo 'rms first mass :8-27,52-58-133,416-456,496-514@N,CA,C' >> $ptraj_file
	#echo 'rms first mass @N,CA,C' >> $ptraj_file
        echo 'trajout '${OUT}"_chain_"${index}".nc nobox netcdf" >> ${ptraj_file}

        ptraj ${PRMTOP} ${ptraj_file}

        rm ${ptraj_file}
done
