#!/bin/bash
set -e

pkg=mcl

if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  # Double quote below to expand the temporary directory variable now versus
  # later is on purpose.
  # shellcheck disable=SC2064
#  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

cp /usr/share/doc/${pkg}/test/* -a "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"
gunzip -r *

# Just for debugging
set -x

#Generation of protein families
mcxload -abc protein_graphs.txt --stream-mirror --stream-neg-log10 -stream-tf 'ceil(200)' -o protein_graphs.mci -write-tab protein_graphs.tab

mcl protein_graphs.mci -I 2

mcxdump -icl out.protein_graphs.mci.I20 -tabr protein_graphs.tab -o clusters.protein_graphs.mci.I20

#Building clusters of genomes
mcxload -abc genome_graphs.txt --stream-mirror -o genome_graphs.mci -write-tab genome_graphs.tab

mcl genome_graphs.mci -I 1.2

mcl genome_graphs.mci -I 2
mcl genome_graphs.mci -I 4
mcl genome_graphs.mci -I 6
mcxdump -icl out.genome_graphs.mci.I12 -tabr genome_graphs.tab -o clusters.genome.mci.I12
mcxdump -icl out.genome_graphs.mci.I20 -tabr genome_graphs.tab -o clusters.genome.mci.I20
mcxdump -icl out.genome_graphs.mci.I40 -tabr genome_graphs.tab -o clusters.genome.mci.I40
mcxdump -icl out.genome_graphs.mci.I60 -tabr genome_graphs.tab -o clusters.genome.mci.I60
