@@ -122,6 +122,21 @@ function check(){
122
122
}
123
123
124
124
125
+ function require(){
126
+ # Requires an executable is in $PATH, as a last resort it will attempt to load
127
+ # the executable or dependency as a module
128
+ # @INPUT $@ = List of dependencies or executables to check
129
+
130
+ for exe in " ${@ } " ; do
131
+ # Check if executable is in $PATH
132
+ command -V ${exe} & > /dev/null && continue ;
133
+ # Try to load exe as lua module
134
+ module load ${exe} & > /dev/null || \
135
+ fatal " Failed to find or load '${exe} ', not installed on target system."
136
+ done
137
+ }
138
+
139
+
125
140
function submit(){
126
141
# Submit jobs to the defined job scheduler or executor (i.e. slurm)
127
142
# INPUT $1 = Snakemake Mode of execution
@@ -131,19 +146,9 @@ function submit(){
131
146
# INPUT $5 = Singularity cache directory
132
147
# INPUT $6 = Temporary directory for output files
133
148
134
- # SLURM inherits the environment from which the job was launched
135
- # Try to purge modules all modules from environment
136
- command -V module & > /dev/null && module purge
137
-
138
- # Check if singularity in $PATH
149
+ # Check if singularity and snakemake are in $PATH
139
150
# If not, try to module load singularity as a last resort
140
- command -V singularity & > /dev/null || module load singularity || \
141
- fatal " Fail to find or load 'singularity', not installed on target system."
142
-
143
- # Check if snakemake in $PATH
144
- # If not, try to module load snakemake as a last resort
145
- command -V snakemake & > /dev/null || module load snakemake || \
146
- fatal " Fail to find or load 'snakemake', not installed on target system."
151
+ require singularity snakemake
147
152
148
153
# Snakemake executor
149
154
executor=${1}
@@ -248,3 +253,4 @@ function main(){
248
253
249
254
# Main: check usage, parse args, and run pipeline
250
255
main " $@ "
256
+
0 commit comments