#Usage: ./ab_ipatch_run_script.sh /home/icruser/public_html/csb/ABDB/ABDB_UI/ABipatch/jobs/30949034850983 1AHW
# Input arguments
# $1: job folder
# $2: antigen pdb
# $3: antibody pdb
# $4: antibody chains
# $5: antigen chains

#ip_dir="/home/icruser/public_html/csb/ABDB/ABDB_UI/ABipatch"
#db_dir="/home/icruser/public_html/csb/ABDB/ABDB/entries"
job_dir=$ip_dir/jobs/$1

mkdir $job_dir
cp -r $ip_dir/ipatch_base/* $job_dir
#Get the antigen whatever it is
wget http://www.rcsb.org/pdb/files/$2.pdb -O $job_dir/AG.pdb >> /dev/null
#Copy over the antibody file
cp $db_dir/$3/structure/$3.pdb $job_dir/AB.pdb

cd $job_dir
python RunABIpatch.py --abf AB.pdb --abc $4 --agf AG.pdb --agc $5 --jobid output
chmod a+rxw -R $ip_dir/jobs/*

