#!/usr/bin/env bash
#
# orthologer - Pipeline for deducing orthology from fasta files.
# Copyright (C) 2005-2023 E. Zdobnov lab: F. Tegenfeldt
# <fredrik.tegenfeldt@unige.ch> based on code by E. Kriventseva
#
# This file is part of orthologer.
#
# orthologer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# orthologer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with orthologer.  If not, see <http://www.gnu.org/licenses/>.
#

[[ $# -eq 0 ]] && { echo "usage: $0 <cmd>"; exit 255; }

localdir=$(pwd)
[[ -f $localdir/orthologer_conf.sh ]] || { echo "error: no local orthologer_conf.sh found" 1>&2; exit 255; }
source $localdir/orthologer_conf.sh

setup_environment

cmd=$1
shift
cmdargs=$*

cmddir=$(dirname $cmd)
if [[ "$cmddir" == "." ]]; then
    cmd=${DIR_ORTHOLOGER}/bin/$cmd
fi

echo
echo "RUNNING: $cmd"
echo
tmp_setup_trap
source $cmd $cmdargs
