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

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

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

    # 3. import sample fasta (format "<name>:<filename>")
    local name="bacty"
    ./orthomapper.sh IMPORT "${name}:refs/unknown.fs" || { echo "error: failed importing primate.fs to user"; return 255; }
    
    # 6. start BUSCO at enterobacterales (NCBI taxid 91347) node
    local ec=$EC_OK
    local nodeid=91347
    local label=$(./orthomapper.sh RUNLABEL taxid=$name mode=busco nodeid=$nodeid)

    # remove old busco results
    rm -Rf busco/$name
    #    ./orthomapper.sh RUN $name mode=busco nodeid=$nodeid go || return $EC_FAIL
    ./orthomapper.sh RUN taxid=$name mode=busco nodeid=$nodeid go || return $EC_FAIL

    check_busco_result "$label" "$nodeid"
    ec=$?
    return $ec
}
run_test
exit $?

