#!/bin/sh -e

pkg="sim4db"

if [ "$AUTOPKGTEST_TMP" = "" ]; then
    AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
    trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi
ORIGDIR=`pwd`
cd $AUTOPKGTEST_TMP
if [ -e /usr/share/doc/kmer-examples/test_data.tar.gz ] ; then
    TARFILE=/usr/share/doc/kmer-examples/test_data.tar.gz
else
    if [ -e ${ORIGDIR}/debian/tests/test-data/test_data.tar.gz ] ; then
        TARFILE=${ORIGDIR}/debian/tests/test-data/test_data.tar.gz
    else
        echo "Please install package kmer-examples to run this script"
        exit 1
    fi
fi
tar -xaf $TARFILE

# Run sim4db
echo "Testing sim4 for intra-species alignment...\n"
sim4db -genomic GCF_000195955.2_ASM19595v2_genomic.fna -cdna ESTs.fasta \
	-output results.sim4db
[ -s results.sim4db ]
echo "Testing sim4cc for inter-species alignment...\n"
sim4db -genomic GCF_000195855.1_ASM19585v1_genomic.fna -cdna ESTs.fasta \
	-interspecies -gff3 -output results.gff3
[ -s results.gff3 ]

echo "RESULTS: OK\n"
