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

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

    # check setup
    ./orthomapper.sh CHECK || { echo "error: failed check!"; return 255; }

    # get DIR_BRHCLUS
    eval $(grep "^DIR_BRHCLUS" orthologer_conf.sh)
    [[ -x $DIR_BRHCLUS/cmpclus ]] || { echo "error: cannot find statclus at $DIR_BRHCLUS/cmpclus"; return 255; }

    # 3. download a sample fasta
    download_fasta virus.fs || return 255

    local run_label="test_virus"
    local node="95342"
    # 5. map fasta file against $node
    ./orthomapper.sh MAP "$run_label" "refs/virus.fs" $node || { echo "error: failed running orthologer"; return 255; }

    # results
    local fclus="Cluster/${run_label}.og"
    check_map_result_files "$run_label" || return $EC_FAIL

    # compare with reference
    cmp_with_ref "$fclus" "proj_map/ref_$(basename $fclus)"
    return $?
}
run_test
exit $?

