#
# This is a command file.
#
# To make a new test, all you have to do is:
#   1.  Make a new directory under tests/
#   2.  Put a file like this (named "command") into that directory.
#
# The contents of this file will be passed to the shell (Bash or SSH),
# so any legal shell commands can go in this file.
# Or comments like this one, for that matter.
#
# Variable substiution is done using Python's printf format,
# meaning you need a percent sign, the variable name in parentheses,
# and the letter 's' (for 'string').
#
# Available variables include:
#   workdir     the directory where test input files have been copied,
#               and where test output files should end up.
#   minidir     the base directory where Mini lives
#   database    where the Mini database lives
#   bin         where the Mini binaries live
#   binext      the extension on binary files, like ".linuxgccrelease"
#
# The most important thing is that the test execute in the right directory.
# This is especially true when we're using SSH to execute on other hosts.
# All command files should start with this line:
#

cd %(workdir)s

#
# After that, do whatever you want.
# Here's a typical test for a Mini binary, assuming there's a "flags" file
# in this directory too:
#

nice %(bin)s/backrub_pilot.%(binext)s @flags_BackrubMover -database %(database)s 2>&1 > /dev/null

echo BackrubMover average PHI MSE : `grep "type= 1" BackrubMover_ala8_0001_mse.txt | head -n 23 | tail -n 22 | cut -d : -f 2 | awk '{total = total + $1}END{print total/NR}'` >> .results.log
echo BackrubMover average THETA MSE : `grep "type= 2" BackrubMover_ala8_0001_mse.txt | head -n 23 | tail -n 22 | cut -d : -f 2 | awk '{total = total + $1}END{print total/NR}'` >> .results.log

nice %(bin)s/backrub_pilot.%(binext)s @flags_SmallMover -database %(database)s 2>&1 > /dev/null

echo SmallMover average MSE : `grep "type= 1" SmallMover_ala8_0001_mse.txt | cut -d : -f 2 | awk '{total = total + $1}END{print total/NR}'` >> .results.log

nice %(bin)s/backrub_pilot.%(binext)s -s pdb/arg1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/asn1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/asp1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/cys1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/gln1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/glu1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/his1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/ile1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/leu1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/lys1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/met1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/phe1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/ser1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/thr1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/trp1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/tyr1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null
nice %(bin)s/backrub_pilot.%(binext)s -s pdb/val1.pdb @flags_SidechainMover -database %(database)s 2>&1 > /dev/null

cat SidechainMover_*1_0001_mse.txt > SidechainMover_all_0001_mse.txt
cat SidechainMover_*1_0001_hist.txt > SidechainMover_all_0001_hist.txt

echo SidechainMover average MSE : `grep "type= 1" SidechainMover_all_0001_mse.txt | cut -d : -f 2 | awk '{total = total + $1}END{print total/NR}'` >> .results.log

#
# Or if you don't care whether the logging output changes:
#
#
## nice %(bin)s/MY_MINI_PROGRAM.%(binext)s @flags -database %(database)s -run:constant_seed 2>&1 \
##     > /dev/null
#
# Please output your statistics results in yaml or plain text format
