-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunGeCKO.sh
209 lines (160 loc) · 4.63 KB
/
runGeCKO.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bash
set -eo pipefail
SingularityImageVersion=1.2.0
### v WRITE YOUR MODULE LOAD OR CONDA ACTIVATE HERE v ###
#module purge
#module load snakemake/7.32.4-conda
#module load singularity/3.6.3
### ^ WRITE YOUR MODULE LOAD OR CONDA ACTIVATE HERE ^ ###
### DEFAULT OPTIONS
JOBS=1
LATENCY_WAIT=20
### DEFAULT ACTION VALUES
HELP="FALSE"
DRYRUN="FALSE"
DIAGRAM="FALSE"
REPORT="FALSE"
### ARGUMENTS
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--help)
HELP="TRUE"
shift # past argument
;;
--workflow)
WORKFLOW="$2"
shift
shift
;;
--cluster-profile)
CLUSTER_PROFILE="$2"
shift
shift
;;
--config-file)
CONFIG="$2"
shift
shift
;;
--jobs)
JOBS="$2"
shift
shift
;;
--forceall)
FORCEALL="--forceall"
shift
;;
--latency-wait)
LATENCY_WAIT="$2"
shift
shift
;;
--dryrun)
DRYRUN="TRUE"
shift
;;
--report)
REPORT="TRUE"
REPORT_NAME="$2"
shift
shift
;;
--diagram)
DIAGRAM="TRUE"
DIAGRAM_NAME="$2"
shift
shift
;;
--extra-snakemake-options)
EXTRA_SNAKEMAKE_OPTIONS="$2"
shift
shift
;;
-*)
echo -e "\nWARNING: $1 option is unknown and will be ignored.\n"
POSITIONAL+=("$1")
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
# --------------------------------------------------------------------------------------------------------------#
printAbsolutePath () {
if [[ ! -z "$1" ]] ; then
fileOrFolder_printAbsolutePath=$(readlink -f "$1") ;
echo ${fileOrFolder_printAbsolutePath}
else
echo $1
fi
}
# --------------------------------------------------------------------------------------------------------------#
### Paths
GeCKO_path=$(dirname $(printAbsolutePath "$0"))
checks_path="${GeCKO_path}/launcher_files"
# --------------------------------------------------------------------------------------------------------------#
### Functions
source "${checks_path}/lib.sh"
# --------------------------------------------------------------------------------------------------------------#
### Check if launcher_files folder exists
checkMissingDir $checks_path "GeCKOdir"
### Check if Singularity/Apptainer and Snakemake are available
isAvailable "Snakemake" "snakemake"
isAvailable "Singularity/Apptainer" "singularity"
### Download the singularity container if it can't be found
GeCKO_sif="${checks_path}/singularity_image/GeCKO.sif"
dlImageSylabs "library://ge2pop_gecko/gecko/gecko:${SingularityImageVersion}" "${GeCKO_sif}"
### Make scripts executable
for script in $(ls ${checks_path}/*.sh) ; do
makeExecutable $script
done
### Print the help
if [ "${HELP}" = "TRUE" ] ; then
cat ${checks_path}/launcher_help.txt
exit 0
fi
### Check variables and paths
source "${checks_path}/launcher_allWorkflowsCheck.sh"
if [[ -f "${checks_path}/launcher_${WORKFLOW}Check.sh" ]] ; then
source "${checks_path}/launcher_${WORKFLOW}Check.sh"
fi
### Unlock in case the folder is locked
snakemake --snakefile ${workflow_path}/${WORKFLOW_SMK} --jobs $JOBS --unlock --configfile ${CONFIG}
### RUN APPROPRIATE SNAKEMAKE COMMANDS ###
## DRYRUN ##
if [ "${DRYRUN}" = "TRUE" ] ; then
snakemake_command="snakemake --snakefile ${workflow_path}/${WORKFLOW_SMK} --printshellcmds --dryrun --dag --forceall --configfile ${CONFIG} ${EXTRA_SNAKEMAKE_OPTIONS}"
echo -e "\nCalling Snakemake:"
echo -e $snakemake_command"\n"
eval $snakemake_command
exit 0
fi
## DIAGRAM ##
if [ "${DIAGRAM}" = "TRUE" ] ; then
snakemake_command="snakemake --snakefile ${workflow_path}/${WORKFLOW_SMK} --printshellcmds --dryrun --dag --forceall --configfile ${CONFIG} ${EXTRA_SNAKEMAKE_OPTIONS} | dot -Tsvg > $DIAGRAM_NAME"
echo -e "\nCalling Snakemake:"
echo -e $snakemake_command"\n"
eval $snakemake_command
exit 0
fi
## REPORT ##
if [ "${REPORT}" = "TRUE" ] ; then
snakemake_command="snakemake --snakefile ${workflow_path}/${WORKFLOW_SMK} --printshellcmds --report $REPORT_NAME --configfile ${CONFIG} ${EXTRA_SNAKEMAKE_OPTIONS}"
echo -e "\nCalling Snakemake:"
echo -e $snakemake_command"\n"
eval $snakemake_command
exit 0
fi
## RUN ##
snakemake_command="snakemake --snakefile ${workflow_path}/${WORKFLOW_SMK} --printshellcmds $FORCEALL --latency-wait $LATENCY_WAIT --jobs $JOBS --use-singularity --configfile ${CONFIG} ${PROFILE} --config configfile_name=${CONFIG} clusterprofile_name=${PROFILE_FILE} ${EXTRA_SNAKEMAKE_OPTIONS} --singularity-args \"--bind ${GeCKO_path} --bind $(pwd) --bind ${HOME}\""
echo -e "\nCalling Snakemake:"
echo -e $snakemake_command"\n"
eval $snakemake_command
exit 0