#!/bin/sh
# autopkgtest check: Run sumaclust on two different chains with a threshold of  
# 0.97, and then do a second run based on the output of the first one.
# Check that the chains are the same in the two output files, which is a kind 
# of idempotency test.
# (C) 2020 Pierre Gruet.
# Author: Pierre Gruet <pgt@debian.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > inputTwoDifferent.fasta
>SEQ_TEST1
CCAGATCTAGCTAGCTAGCTACAGCATCGACATCAGCACTCAGCACTCAG
>SEQ_TEST2
CCAGATGATCTAGCTAGCTAGCTACAGCATTTGAACATCAGCACTGGATCAG
EOF

sumaclust -t 0.97 inputTwoDifferent.fasta > outputTwoDifferent.fasta 2>&1
sumaclust -t 0.97 outputTwoDifferent.fasta > outputTwoDifferent2.fasta 2>&1

sed -n -e '2p;4p' outputTwoDifferent.fasta > extract
sed -n -e '2p;4p' outputTwoDifferent2.fasta > extract2

diff extract extract2

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

