Skip to content

Commit

Permalink
feat: enable parameters to use snakemake profile
Browse files Browse the repository at this point in the history
  • Loading branch information
matinnuhamunada committed Jan 26, 2024
1 parent 4ce9fbe commit d257403
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ repos:
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 23.3.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args: ['--ignore=E501,C901']
additional_dependencies: [flake8-typing-imports==1.10.0]
exclude: ^tests
9 changes: 5 additions & 4 deletions src/bgcflow/bgcflow.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Main module."""
import json
import multiprocessing
import subprocess
import sys
import time
from pathlib import Path

Expand All @@ -29,15 +27,18 @@ def snakemake_wrapper(**kwargs):
touch = ""
unlock = ""
until = ""
profile = ""

if kwargs["dryrun"]:
dryrun = "--dryrun"
if kwargs["touch"]:
touch = "--touch"
if kwargs["unlock"]:
touch = "--unlock"
unlock = "--unlock"
if kwargs["until"] is not None:
until = f"--until {kwargs['until']}"
if kwargs["profile"] is not None:
profile = f"--profile {kwargs['profile']}"

if kwargs["monitor_off"]:
pass
Expand Down Expand Up @@ -132,7 +133,7 @@ def snakemake_wrapper(**kwargs):
click.echo(
f"\nDEBUG: Using {kwargs['cores']} out of {multiprocessing.cpu_count()} available cores\n"
)
snakemake_command = f"cd {kwargs['bgcflow_dir']} && snakemake --snakefile {snakefile} --use-conda --keep-going --rerun-incomplete --rerun-triggers mtime -c {kwargs['cores']} {dryrun} {touch} {until} {unlock} --wms-monitor {kwargs['wms_monitor']}"
snakemake_command = f"cd {kwargs['bgcflow_dir']} && snakemake --snakefile {snakefile} --use-conda --keep-going --rerun-incomplete --rerun-triggers mtime -c {kwargs['cores']} {dryrun} {touch} {until} {unlock} {profile} --wms-monitor {kwargs['wms_monitor']}"
click.echo(f"Running Snakemake with command:\n{snakemake_command}")
subprocess.call(snakemake_command, shell=True)

Expand Down
5 changes: 5 additions & 0 deletions src/bgcflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def clone(**kwargs):
default=None,
help="Runs the pipeline until it reaches the specified rules or files.",
)
@click.option(
"--profile",
default=None,
help="Path to a directory containing snakemake profile.",
)
@click.option(
"-t",
"--touch",
Expand Down

0 comments on commit d257403

Please sign in to comment.