#!/bin/bash
set -e

pkg=edtsurf

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/doc/${pkg}/examples/* "${AUTOPKGTEST_TMP}"

cd "${AUTOPKGTEST_TMP}"

gunzip -r *
ls -R

cd data

echo -e "\e[93m\e[1mTest 1\e[0m"
EDTSurf -i 4we2.pdb

echo "5a8f743a66963e9939773cce4dd68063  4we2-cav.pdb" > checksums
echo "1e12bc9a1180027990d7b16497af051b  4we2.ply" >> checksums
md5sum --check checksums

echo -e "\e[92m\e[1mPassed\e[0m"
echo

echo -e "\e[93m\e[1mTest 2\e[0m"
EDTSurf -i 4we2.pdb -t 2 -o 4we2-vcmc-ms

echo "5a8f743a66963e9939773cce4dd68063  4we2-vcmc-ms-cav.pdb" > checksums
echo "1e12bc9a1180027990d7b16497af051b  4we2-vcmc-ms.ply" >> checksums
md5sum --check checksums

echo -e "\e[92m\e[1mPassed\e[0m"
echo

echo -e "\e[93m\e[1mTest 3\e[0m"
EDTSurf -i 4we2.pdb -s 1 -t 1 -o 4we2-mc-vws

echo "6c58df9e481d7acc476ac49b05ccf71a  4we2-mc-vws-cav.pdb" > checksums
echo "3fcf6ee03320d65165f6b69829184523  4we2-mc-vws.ply" >> checksums
md5sum --check checksums

echo -e "\e[92m\e[1mPassed\e[0m"
echo

echo -e "\e[93m\e[1mTest 4\e[0m"
EDTSurf -i 4we2.pdb -s 2 -t 2 -c 3 -o 4we2-sas-vcmc-chain

echo "e53d8f051ab37ddb2e8ea7f91b576046  4we2-sas-vcmc-chain.asa" > checksums
echo "a5c9f8506b7a19598abdd4d723b659d8  4we2-sas-vcmc-chain-cav.pdb" >> checksums
echo "840499d9781b146e0144fdb597c73a8e  4we2-sas-vcmc-chain.ply" >> checksums
md5sum --check checksums

echo -e "\e[92m\e[1mPassed\e[0m"
echo
