#!/bin/sh
# autopkgtest check: build and run with default test data
# Author: Tatiana Malygina <merlettaia@gmail.com>

set -e

pkg=profphd

if [ "$ADTTMP" = "" ] ; then
  ADTTMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  trap "rm -rf $ADTTMP" 0 INT QUIT ABRT PIPE TERM
fi

cd $ADTTMP

cp -a /usr/share/${pkg}/prof/exa/* .
find . -type f -name "*.gz" -exec gunzip \{\} \;
for lnk in `find . -type l -name "*.gz"` ; do
    ln -s `basename $(readlink $lnk) .gz` `echo $lnk | sed 's/\.gz$//'`
    rm $lnk
done

# Prediction from alignment in HSSP file for best results
prof 1ppt.hssp fileRdb=${ADTTMP}/1ppt_new.hssp.prof
[ -z $(cmp -s 1ppt_new.hssp.prof 1ppt.hssp.prof) ]
# Prediction from a single sequence
prof 1ppt.f fileRdb=${ADTTMP}/1ppt_new.f.rdbProf
[ -z $(cmp -s 1ppt_new.f.rdbProf 1ppt.f.rdbProf) ]
# phd.pl invocation
/usr/share/profphd/prof/embl/phd.pl 1ppt.hssp htm fileOutPhd=${ADTTMP}/query_new.phdPred  fileOutRdb=${ADTTMP}/query.phdRdb  fileNotHtm=${ADTTMP}/query.phdNotHtm
[ -z $(cmp -s query_new.phdPred query.phdPred) ]
