#!/bin/bash

#
# Script to prepare structural TR target template (starting model) from original T0xxxTSxxx_x model
#   and copy sequence template from T0xxx.seq.txt file
#

if [ $# -lt 2 ] 
then
	echo "Usage $0 TargetNum(only numbers) ModelName , e.g.:"
	echo "$0 0950 228_1"
	exit 1
fi

echo "REMARK REFINEMENT TARGET R$1" > R$1.pdb.txt
echo "REMARK STARTING MODEL T$1TS$2" >> R$1.pdb.txt
cat /data/CASP13/predictions/closed_4eval_TS/T$1/T$1TS$2 | grep -v 'PFRMAT\|TARGET\|MODEL\|PARENT' >> R$1.pdb.txt

echo ">R$1, residues (n-n) from the sequence below, T$1, should be modeled" > R$1.seq.txt
cat T$1.seq.txt >>R$1.seq.txt

echo "REMARK REFINEMENT TARGET R$1" > /data/CASP13/TARGETS/R$1.pdb
cat /data/CASP13/TARGETS/T$1.pdb >> /data/CASP13/TARGETS/R$1.pdb

# AFter the templates are copied remove residues 
# that are not in the structure of the target, change the header of the seq template  

# Tarballs are copied to the archive automatically at the time of releasing 'R' target
#  Obsolete: use the script copy_TR... to copy files to archive 
