#!/bin/bash
set -e

pkg=wtdbg2

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 /usr/share/doc/${pkg}-examples/* -a "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"
gunzip -r *
tar -xvf *.tar
cd selfSampleData

echo "Begin Execution"
wtdbg2 -t 16 -x rs -g 4.6m -o dbg pacbio_filtered.fastq

# Step by step commandlines
# assemble long reads
wtdbg2 -x rs -g 4.6m -i pacbio_filtered.fastq -t 16 -fo dbg

# derive consensus
wtpoa-cns -t 16 -i dbg.ctg.lay.gz -fo dbg.raw.fa
[ -s dbg.raw.fa ] || exit 1
echo "PASS"

