#!/bin/sh
#
# Testing RNAalifold (equilibrium probabilities)

echo 1..2 # Number of tests to be executed.

RETURN=0

failed () {
    RETURN=1
    if [ "x$1" != "x" ]
    then
        echo "not ok - $1"
    else
        echo "not ok"
    fi
}

passed () {
    if [ "x$1" != "x" ]
    then
        echo "ok - $1"
    else
        echo "ok"
    fi
}


# Test partition function folding (centroid, MEA, base pair- and stack probabilities)
testname="Partition function (centroid, MEA)"
RNAalifold -q --noPS -p --MEA -r --auto-id --id-prefix="rnaalifold_pf_test" ${DATADIR}/rfam_seed_selected.stk > rnaalifold_pf.out
diff=$(${DIFF} -ru -I frequency ${RNAALIFOLD_RESULTSDIR}/rfam_seed_selected.pf.gold rnaalifold_pf.out)
if [ "x${diff}" != "x" ] ; then failed "$testname"; echo -e "$diff"; else passed "$testname"; fi

testname="Partition function (base pair probabilities)"
for file in rnaalifold_pf_test_00*_dp.ps rnaalifold_pf_test_00*_ali.out
do
  diff=$(${DIFF} -ru -I CreationDate -I Creator -I Program ${RNAALIFOLD_RESULTSDIR}/${file} ${file})
  if [ "x${diff}" != "x" ] ; then break; fi
done
if [ "x${diff}" != "x" ] ; then failed "$testname"; echo -e "$diff"; else passed "$testname"; fi

# clean up
rm rnaalifold_pf.out rnaalifold_pf_test_00*_dp.ps rnaalifold_pf_test_00*_ali.out

exit ${RETURN}
