#!/bin/bash
set -e

pkg=spaln

export LC_ALL=C.UTF-8
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 -a /usr/share/${pkg}/seqdb/* "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"

#export ALN_DBS="${AUTOPKGTEST_TMP}"
NCPUS=`grep '^cpu cores' /proc/cpuinfo | head -n 1 | sed 's/cpu cores[[:space:]:]\+//'`

# Avoid using makeidx.pl (see https://github.com/ogotoh/spaln/issues/46#issuecomment-1025331901)
#perl makeidx.pl -v -inp dictdisc_g.gf.gz
spaln -W -KD -t${NCPUS} dictdisc_g.gf.gz >/dev/null
spaln -W -KP -t${NCPUS} dictdisc_g.gf.gz > /dev/null
spaln -Q7 -d dictdisc_g -T dictdisc dictdisc.faa.gz > /dev/null
spaln -Q7 -d dictdisc_g -yS -T dictdisc -O12 -g dictdisc.cf.gz > /dev/null
sortgrcd -O15 -F2 dictdisc.cf.grd.gz > /dev/null
