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