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

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

    load_url_config || { echo "error: failed loading config!"; return $EC_FAIL; }
    
    # 3. download a sample fasta
    download_fasta example.fs || return $EC_FAIL

    local label="test_simple"
    local node="1489911"
    # 5. map fasta file against $node
    ./orthomapper.sh MAP "$label" "refs/example.fs" $node subsample="no" || {
        echo "error: failed running orthologer"
        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 $?

