#!/bin/bash

ptraj_file="tmp.ptraj"
OUT="50-90ns_noWAT_1000frames_noATP_noH"

REF="1XCK_chainA_sol.inpcrd"

PRMTOP="../../1XCK_apo_noWAT.prmtop"

TRAJIN[1]="../traj/1-40ns_imposedOnStart.nc"


MASK[1]=":1-1048 & !:7337-7340"
MASK[2]=":525-1572 & !:7339-7342"
MASK[3]=":1049-2096 & !:7341-7344"
MASK[4]=":1573-2620 & !:7343-7346"
MASK[5]=":2097-3144 & !:7345-7348"
MASK[6]=":2621-3668 & !:7347-7350"
#MASK[7]=":3145-3668,1-524"

MASK[1]=":1-1048"
MASK[2]=":525-1572"
MASK[3]=":1049-2096"
MASK[4]=":1573-2620"
MASK[5]=":2097-3144"
MASK[6]=":2621-3668"
#MASK[7]=":3145-3668,1-524"

MASK[8]=":3669-4716"
MASK[9]=":4193-5240"
MASK[10]=":4717-5764"
MASK[11]=":5241-6288"
MASK[12]=":5765-6812"
MASK[13]=":6289-7336"
#MASK[14]=":6813-7336"




rm ${ptraj_file}

for index in 1 2 3 4 5 6 8 9 10 11 12 13
do
        echo 'trajin '${DIR[index]}${TRAJIN[1]} 1 4000 4 >> ${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

