#!/bin/bash
source ../test_common.sh
set_test_name "${BASH_SOURCE[0]}"

testfun() {
    [[ -f orthologer.sh ]] || { echo "error: setup_test.sh not executed"; return 255; }

    # check setup
    ./orthologer.sh -xp >& /dev/null || { echo "error: failed check - run ./orthologer.sh -xp to see details"; return 255; }
    
    # 3. download a sample fasta
    download_fasta example.fs || return 255

    # make sure that full pipeline is run
    ./orthologer.sh -r all || return 255

    # check existance of result
    fbase='Cluster/test.og'
    [[ -f ${fbase} ]] || { echo "error: missing local cluster file ${fbase}"; return 255; }

    # map example.fs to this orthology (label 'test')
    ./orthomapper.sh map localmap refs/example.fs local:test

    fbase='Cluster/localmap.og'
    [[ -f ${fbase} ]] || { echo "error: missing result file ${fbase}"; return 255; }

    # compare with reference
    cmp_with_ref "$fbase" "proj_prot/ref_test_localmap.og"
    return $?
}
run_test
exit $?
