#!/bin/bash
set -e

pkg=harvest-tools
CUR_DIR=`pwd`

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 ${CUR_DIR}/test/* -a "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"
gunzip -r *

echo 'Test 1'
echo 'convert to .ggr file'
harvesttools -x test2.xmfa -f test2.fna -g test2.vcf -n test2.tree
harvesttools -g test2.vcf -f test2.fna -x test2.xmfa -o test2.ggr
[ -s test2.tree ] || exit 1
[ -s test2.ggr ] || exit 1
echo 'PASS'
echo

echo 'Test 2'
echo 'Recover into fna format'
harvesttools -i test2.ggr -F out.fna
diff -u test2.fna out.fna
echo 'PASS'
echo '============================================================'

