#!/bin/bash
set -e

pkg=unicycler

if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkg}-test.XXXXXX`
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

if [ -d /usr/share/${pkg}-data/sample_data ] ; then
  cp -a /usr/share/${pkg}-data/sample_data/* $AUTOPKGTEST_TMP
else
  echo "Please install package unicycler-data to run this script"
  exit 1
fi

cd $AUTOPKGTEST_TMP

unicycler -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -o illumina_assembly

#unicycler -l long_reads_high_depth.fastq.gz -o long_read_assembly
# This command fails with the following error:
#    Assembling contigs and long reads with miniasm
#    ...
#    Assembling reads with miniasm... empty result
#    Error: miniasm assembly failed

# It might be that the reads have not enough depth. See issue:
#    https://github.com/rrwick/Unicycler/issues/38

unicycler -1 short_reads_1.fastq.gz -2 short_reads_2.fastq.gz -l long_reads_low_depth.fastq.gz -o hybrid_assembly
