-
Notifications
You must be signed in to change notification settings - Fork 1
/
miracum_pipe.sh
executable file
·90 lines (76 loc) · 2.46 KB
/
miracum_pipe.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
readonly DIR_MIRACUM="/opt/MIRACUM-Pipe"
readonly SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
function join_by { local IFS="$1"; shift; echo "$*"; }
function usage() {
singularity exec $1 "${DIR_MIRACUM}"/miracum_pipe.sh -h
echo ""
echo "additional optional flags:"
echo " -n singularity image file (default is miracum-pipe-sl.sif)"
exit 1
}
IMAGE_FILE="${SCRIPTPATH}/miracum_pipe.sif"
readonly VALID_PROTOCOLS=("wes panel tumorOnly")
while getopts t:p:d:n:fsh option; do
case "${option}" in
t) readonly PARAM_TASK=$OPTARG;;
p) readonly PARAM_PROTOCOL=$OPTARG;;
f) readonly PARAM_FORCED=true;;
d) readonly PARAM_DIR_PATIENT=$OPTARG;;
s) readonly PARAM_SEQ=true;;
n) IMAGE_FILE=$OPTARG;;
h) readonly SHOW_USAGE=true;;
\?)
echo "Unknown option: -$OPTARG" >&2
exit 1
;;
:)
echo "Missing option argument for -$OPTARG" >&2
exit 1
;;
*)
echo "Unimplemented option: -$OPTARG" >&2
exit 1
;;
esac
done
[[ "${SHOW_USAGE}" ]] && usage "${IMAGE_FILE}"
if [[ ! -z "${PARAM_PROTOCOL}" ]]; then
if [[ ! " ${VALID_PROTOCOLS[@]} " =~ " ${PARAM_PROTOCOL} " ]]; then
echo "unknown protocol: ${PARAM_PROTOCOL}"
echo "use one of the following values: $(join_by ' ' ${VALID_PROTOCOLS})"
exit 1
fi
elif [[ -z "${PARAM_PROTOCOL}" ]]; then
echo "no protocol specified!"
exit 1
fi
# call script
if [[ "${PARAM_FORCED}" ]]; then
opt_args='-f'
fi
if [[ "${PARAM_TASK}" ]]; then
opt_args="${opt_args} -t ${PARAM_TASK}"
fi
if [[ "${PARAM_PROTOCOL}" ]]; then
opt_args="${opt_args} -p ${PARAM_PROTOCOL}"
fi
if [[ "${PARAM_SEQ}" ]]; then
opt_args="${opt_args} -s"
fi
if [[ "${PARAM_DIR_PATIENT}" ]]; then
opt_args="${opt_args} -d ${PARAM_DIR_PATIENT}"
fi
export SINGULARITYENV_CUSTOMCONFIGFILE=${SCRIPTPATH}/conf/custom.yaml
export SINGULARITYENV_INPUTPATH=$(pwd)/assets/input
export SINGULARITYENV_OUTPUTPATH=$(pwd)/assets/output
export SINGULARITYENV_REFERENCESPATH=${SCRIPTPATH}/assets/references
export SINGULARITYENV_DATABASEPATH=${SCRIPTPATH}/databases
export SINGULARITYENV_ANNOVARPATH=${SCRIPTPATH}/tools/annovar
export SINGULARITYENV_GATKPATH=${SCRIPTPATH}/tools/gatk
export SINGULARITYENV_FUSIONCATCHERPATH=${SCRIPTPATH}/tools/fusioncatcher/data
export SINGULARITYENV_OPTARGS=${opt_args}
export SINGULARITYENV_SCRATCH=${SCRATCH}
echo "running \"${DIR_MIRACUM}/miracum_pipe.sh ${opt_args}\" of image ${IMAGE_FILE}"
echo "---"
singularity run --writable-tmpfs ${IMAGE_FILE}