#!/bin/sh
# autopkgtest check: Run sumatra on two identical files with three sequences 
# in each. We use a threshold of 1 and check that
# * 3 sequences are read in each one;
# * 5 lines are output with a score of 1.
# (C) 2020 Pierre Gruet.
# Author: Pierre Gruet <pgtdebian@free.fr>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > input.fasta
>SEQ1
ATGTGATCAATGCTGCTAGCTGCTAGCTGCTACGCACACGTGCATCGCTGCATGCACTGCTGCTGATGCTCAGCTAG
>SEQ2
AGGTATCTCGATCGATCACTCGCATCGTGTGCTAGCTGCTAGCTGCTACGATCGCATCGC
>SEQ3
AGGTATCTCGATCGATCACTCGCATCGTGTGCTAGCTGCTAGCTGCTACGATCGCATCGC
EOF

sumatra -t 1. input.fasta input.fasta 2>&1 | \
  sed -n 's/^3.sequences//p' | \
  wc -l |
  grep -q "2"

if [ $? -ne 0 ]; then
  exit 1
fi

sumatra -t 1. input.fasta input.fasta 2>&1 | \
  sed -n 's/^SEQ.*SEQ.*1.00//p' | \
  wc -l |
  grep -q "5"

if [ $? -ne 0 ]; then
  exit 1
fi
