Skip to content

Commit 15b9769

Browse files
committed
Updating logic for required software dependencies
1 parent a668f27 commit 15b9769

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

resources/runner

+17-12
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ function check(){
121121
}
122122

123123

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+
124139
function submit(){
125140
# Submit jobs to the defined job scheduler or executor (i.e. slurm)
126141
# INPUT $1 = Snakemake Mode of execution
@@ -130,19 +145,9 @@ function submit(){
130145
# INPUT $5 = Singularity cache directory
131146
# INPUT $6 = Temporary directory for output files
132147

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
138149
# 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
146151

147152
# Snakemake executor
148153
executor=${1}

0 commit comments

Comments
 (0)