#!/bin/sh
# autopkgtest check: Run sumaclust on two identical chains with a threshold of 
# 1 to check that only one cluster is created.
# (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 > inputIdentical.fasta
>SEQ_TEST1
CCAGATCTAGCTAGCTAGCTACAGCATCGACATCAGCACTCAGCACTCAG
>SEQ_TEST2
CCAGATCTAGCTAGCTAGCTACAGCATCGACATCAGCACTCAGCACTCAG
EOF

sumaclust -t 1. inputIdentical.fasta 2>&1 | \
  sed -n '/clusters/ s/.*Done : 100 \% *//p' | \
  sed -n 's/ clusters.*//p' | \
  grep -q "1"

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

