#!/bin/bash
set -e

pkg=scythe
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 /usr/share/doc/${pkg}/* -a "${AUTOPKGTEST_TMP}"
cp ${CUR_DIR}/testing/reads.fastq -a "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"
gunzip -r *

contam_rate=0.5
mkdir -p scythe/results/$contam_rate
## scythe trimming - multiple priors for 40% contamination
i=1
for prior in 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95
do
    for rep in 01 02 03 04 05 06 07 08 09 10
    do
	echo "Test $i"	
	echo "Testing with prior:$prior and rep:$rep"
        scythe -n 0 -p $prior -a illumina_adapters.fa reads.fastq > scythe/results/$contam_rate/trimmed-$rep-$prior.fastq 2> /dev/null
	[ -s scythe/results/$contam_rate/trimmed-$rep-$prior.fastq ]  
	echo "PASS"
	((i++))
    done
done

