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

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

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

    # 3. download a sample fasta
    download_fasta unknown.fs || return $EC_FAIL

    local label="test_with_subset"
    local nodeid="91347"
    local subset="571_1,243265_0,55209_0,82979_0"
    # 5. run mapping
    ./orthomapper.sh MAP "$label" "refs/unknown.fs" "$nodeid" "using=$subset" || { echo "error: failed running mapping"; return $EC_FAIL; }

    # results
    check_map_result_files "$label" || return $EC_FAIL

    # compare with reference
    local fclus="Cluster/${label}.og"
    cmp_with_ref "$fclus" "proj_map/ref_$(basename $fclus)"
    return $?
}
run_test
exit $?

