-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·99 lines (89 loc) · 2.81 KB
/
run
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
91
92
93
94
95
96
97
98
99
#!/bin/bash
# Warn users about missing RethinkDB environment variables.
if [[ -z "${RETHINK_HOST}" || -z "${RETHINK_AUTH_KEY}" ]]
then
echo -n "RETHINK_HOST or RETHINK_AUTH_KEY are not set. Continue? (Y/N): "
read should_continue
if [[ "${should_continue}" != "Y" && "${should_continue}" != "y" ]]
then
echo "Aborting"
exit 1
fi
fi
# Search user arguments for jobs parameter, -j or --jobs, and provide a default
# value if it isn't supplied.
FOUND_JOBS=0
for ARG in $*
do
if [[ "${ARG}" = "-j" || "${ARG}" = "--jobs" ]]
then
FOUND_JOBS=1
fi
done
if [[ "${FOUND_JOBS}" -eq "0" ]]
then
JOBS="-j 1"
else
JOBS=""
fi
# Use the cluster by default.
USE_CLUSTER=1
# Parse user arguments.
while getopts ":lh" opt; do
case $opt in
l)
# Run jobs locally.
USE_CLUSTER=0
# Remove janus argument from arguments passed to snakemake.
shift
;;
h)
echo "Usage: $0 [-l] [snakemake arguments]"
echo
echo "-l: run jobs locally (default: run jobs on cluster)"
echo "all other arguments are passed through to snakemake"
echo
echo "Examples"
echo "--------"
echo
echo "Local run:"
echo -e "\t./janus -l"
echo "Dry run:"
echo -e "\t./janus -n"
echo "Run 4 jobs at once:"
echo -e "\t./janus -j 4"
echo "Clean up prepare/process output for flu builds:"
echo -e "\t./janus clean -j 1 --config filters=\"flu*\""
echo "Clean up prepare/process output for H3N2 flu builds:"
echo -e "\t./janus clean -j 1 --config filters=\"flu_h3n2*\""
echo "Run only flu and zika builds with 4 jobs at once:"
echo -e "\t./janus -j 4 --config filters=\"flu*,zika\""
exit
;;
\?)
# Stop looking for other arguments if we find an unexpected one.
break
;;
esac
done
# If there are no cluster submission commands on the PATH, disable cluster
# submission.
if [[ -z "$(which sbatch)" && -z "$(which qsub)" ]]
then
USE_CLUSTER=0
fi
# Setup the environment.
. ${HOME}/miniconda3/etc/profile.d/conda.sh
conda activate nextstrain
export AUGUR_MINIFY_JSON=1
# Run jobs on the cluster if it is possible and the user did not request a local
# run.
if [[ "${USE_CLUSTER}" -eq "1" ]]
then
# Run multiple build jobs at a time on the cluster.
echo "Running on the cluster"
snakemake -w 60 --use-conda --cluster-config cluster.json --cluster "sbatch --nodes=1 --tasks=1 --mem={cluster.memory} --cpus-per-task={cluster.cores} --tmp={cluster.disk} --time={cluster.time}" ${JOBS} $*
else
echo "Running locally"
snakemake -w 60 --use-conda ${JOBS} $*
fi