Skip to content
Snippets Groups Projects

wrapper for zarp execution

Closed BIOPZ-Katsantoni Maria requested to merge snakemake_call_wrapper into dev
5 files
+ 185
19
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 26
19
@@ -78,6 +78,13 @@ def parse_cli_args() -> argparse.Namespace:
@@ -78,6 +78,13 @@ def parse_cli_args() -> argparse.Namespace:
help="path of the snakefile to be executed",
help="path of the snakefile to be executed",
metavar="STR",
metavar="STR",
)
)
 
zarp.add_argument(
 
"--bindings",
 
type=str,
 
default=None,
 
help="bindings for singularity",
 
metavar="STR",
 
)
io = parser.add_argument_group("input/output")
io = parser.add_argument_group("input/output")
io.add_argument(
io.add_argument(
"--input-to-output-mapping",
"--input-to-output-mapping",
@@ -219,12 +226,10 @@ def parse_cli_args() -> argparse.Namespace:
@@ -219,12 +226,10 @@ def parse_cli_args() -> argparse.Namespace:
"'--labkey-path' are required."
"'--labkey-path' are required."
)
)
if (args.execution_env and not args.cluster_json) or \
if (args.execution_env == 'slurm' and not args.cluster_json):
(args.cluster_json and not args.execution_env):
parser.print_help()
parser.print_help()
sys.exit(
sys.exit(
"\n[ERROR] Either none or both of '--execution_env' and "
"\n[ERROR] '--cluster_json' is required."
"'--cluster_json' are required."
)
)
return args
return args
@@ -488,7 +493,7 @@ def run_zarp(
@@ -488,7 +493,7 @@ def run_zarp(
result_dir: str,
result_dir: str,
cluster_json: str,
cluster_json: str,
snakefile_path: str,
snakefile_path: str,
anchor: str = os.getcwd()):
bindings):
"""
"""
trigger zarp snakemake workflow execution, according to
trigger zarp snakemake workflow execution, according to
the environment chosen by the user if no environment is
the environment chosen by the user if no environment is
@@ -508,13 +513,13 @@ def run_zarp(
@@ -508,13 +513,13 @@ def run_zarp(
try:
try:
command = [
command = [
'snakemake',
'snakemake',
f'--snakefile="{snakefile_path}"',
f'--snakefile={snakefile_path}',
f'--configfile="{config}"',
f'--configfile={config}',
'--cores=4',
'--cores=4',
'--printshellcmds',
'--printshellcmds',
'--rerun-incomplete',
'--rerun-incomplete',
'--use-singularity',
'--use-singularity',
f'--singularity-args="--bind {anchor}"',
f'--singularity-args=--bind {bindings}',
'--verbose']
'--verbose']
subprocess.check_call(
subprocess.check_call(
command,
command,
@@ -529,22 +534,23 @@ def run_zarp(
@@ -529,22 +534,23 @@ def run_zarp(
try:
try:
command = [
command = [
'snakemake',
'snakemake',
f'--snakefile="{snakefile_path}"',
f'--snakefile={snakefile_path}',
f'--configfile="{config}"',
f'--configfile={config}',
f'--cluster-config="{cluster_json}"',
f'--cluster-config={cluster_json}',
'--cluster="sbatch \
'''--cluster=sbatch \
--cpus-per-task={cluster.threads} \
--cpus-per-task={cluster.threads} \
--mem={cluster.mem} \
--mem={cluster.mem} \
--qos={cluster.queue} \
--qos={cluster.queue} \
--time={cluster.time} \
--time={cluster.time} \
--job-name={cluster.name} \
--job-name={cluster.name} \
-o {cluster.out} \
-o {cluster.out} \
-p scicore"',
-p scicore''',
'--cores=256',
'--cores=256',
'--printshellcmds',
'--printshellcmds',
'--rerun-incomplete',
'--rerun-incomplete',
'--use-singularity',
'--use-singularity',
f'--singularity-args="--bind {anchor}"',
'--latency-wait=60',
 
f'--singularity-args=--bind {bindings}',
'--verbose']
'--verbose']
subprocess.check_call(
subprocess.check_call(
command,
command,
@@ -557,9 +563,9 @@ def run_zarp(
@@ -557,9 +563,9 @@ def run_zarp(
try:
try:
report_command = [
report_command = [
'snakemake',
'snakemake',
'--snakefile="Snakefile"',
f'--snakefile={snakefile_path}',
f'--configfile="{config}"',
f'--configfile={config}',
f'--report="{report_path}"']
f'--report={report_path}']
subprocess.check_call(
subprocess.check_call(
report_command,
report_command,
stdout=sys.stdout,
stdout=sys.stdout,
@@ -809,10 +815,11 @@ def main(args):
@@ -809,10 +815,11 @@ def main(args):
if args.execution_env:
if args.execution_env:
run_zarp(
run_zarp(
args.execution_env,
args.execution_env,
args.config_file,
args.config_file.name,
results_dir,
results_dir,
args.cluster_json,
args.cluster_json,
args.snakefile_path)
args.snakefile_path,
 
args.bindings)
if __name__ == '__main__':
if __name__ == '__main__':
Loading