#!/bin/bash
set -e

pkg=resfinder

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}"

gunzip -r *
ls
echo "Indexing files as needed"
cd db_resfinder
python3 INSTALL.py
cd ..

cd db_pointfinder
python3 INSTALL.py
cd ..

echo "Running tests"
python3 functional_tests.py -db_res db_resfinder -db_point db_pointfinder -b /usr/bin/blastn -k /usr/bin/kma

echo "Cleanup"
rm -rf db_*

echo "PASS"
