#!/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 label="test_simple_with_busco"
    ./orthomapper.sh MAP "$label" "refs/unknown.fs" || { echo "error: failed running mapping"; return $EC_FAIL; }

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

    # 6. compare with reference
    local ec=0
    local fclus="Cluster/${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 "$label" "91347"
        ec=$?
    fi
    return $ec
}
run_test
exit $?

