#!/bin/bash
set -e

pkg=shasta

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

cp -a /usr/share/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"

# We first test /usr/bin/shasta binary
echo "Testing /usr/bin/shasta"

gunzip TinyTest.fasta.gz
shasta --input TinyTest.fasta

# Now, test Python3 binding via invocation
echo "Alignment compression test"
python3 -c 'import shasta;shasta.testAlignmentCompression();'

echo "Base test"
python3 -c 'import shasta;shasta.testBase();'

echo "Compact undirected graph 1 test"
python3 -c 'import shasta;shasta.testCompactUndirectedGraph1();'

echo "Compact undirected graph 2 test"
python3 -c 'import shasta;shasta.testCompactUndirectedGraph2();'

echo "De-duplicate and count test"
python3 -c 'import shasta;shasta.testDeduplicateAndCount();'

echo "Long base sequence test"
python3 -c 'import shasta;shasta.testLongBaseSequence();'

echo "Median consensus caller test"
python3 -c 'import shasta;shasta.testMedianConsensusCaller();'

echo "Multi-threaded object test"
python3 -c 'import shasta;shasta.testMultithreadedObject();'

echo "Short base sequence test"
python3 -c 'import shasta;shasta.testShortBaseSequence();'

echo "Simple bayesian consensus test using guppy-2.3.1-a model"
python3 -c 'import shasta;shasta.testSimpleBayesianConsensusCaller("guppy-2.3.1-a");'

echo "Spoa test"
python3 -c 'import shasta;shasta.testSpoa();'
