It's not an issue, but I just wanted to share an experience of making viralrecall run from any directory.
The solution is straightforward and consists of having one additional wrapper script that converts relative paths to the input and the project into absolute ones and launches viralrecall.py from its location, e.g. /opt/viralrecall/:
$ cat /opt/viralrecall/viralrecall
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "$( realpath "${BASH_SOURCE[0]}" )" )" &> /dev/null && pwd )"
args=()
while test $# -gt 0; do
arg=$1
args+=("$arg")
case "$arg" in
-i|--input|-p|--project)
args+=("$(realpath -ms "$2")")
shift
;;
esac
shift
done
cd "$SCRIPT_DIR"
python viralrecall.py "${args[@]}"
The wrapper can be soft-linked to a location on the PATH, and then viralrecall can be run intuitively as:
cd path/to/my/inputs/
viralrecall -i input.fasta -p project
One small problem is that viralrecall.py writes two files in the directory where it resides - err.txt and out.txt. To prevent this from happening in directories that are not supposed to have write permissions for regular users (and running viralrecall on different inputs compromises these files either way), they can be redirected preemptively to /dev/null:
It's not an issue, but I just wanted to share an experience of making viralrecall run from any directory. The solution is straightforward and consists of having one additional wrapper script that converts relative paths to the input and the project into absolute ones and launches
viralrecall.py
from its location, e.g./opt/viralrecall/
:The wrapper can be soft-linked to a location on the
PATH
, and then viralrecall can be run intuitively as:One small problem is that
viralrecall.py
writes two files in the directory where it resides -err.txt
andout.txt
. To prevent this from happening in directories that are not supposed to have write permissions for regular users (and running viralrecall on different inputs compromises these files either way), they can be redirected preemptively to/dev/null
:although of course a more elegant solution would be to modify
viralrecall.py
to make it write those files relative toproject
.