#!/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; }

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

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

    # 3. run mapping with busco auto lineage
    local run_label="test_simple_with_busco"
    ./orthomapper.sh MAP "$run_label" "refs/unknown.fs" || { echo "error: failed running mapping"; return $EC_FAIL; }

    # 5. check existance of result
    check_map_result_files "$run_label" || return $EC_FAIL

    # 6. compare with reference
    local ec=0
    local fclus="Cluster/${run_label}.og"
    cmp_with_ref "$fclus" "proj_map/ref_$(basename $fclus)"
    ec=$?
    # check
    if [[ $ec -eq 0 ]]; then
        # 4. check node id found
        check_busco_result "$run_label" "91347"
        ec=$?
    fi
    return $ec
}
run_test
exit $?

