From e74be7843299478a276febfacb52825a9762500c Mon Sep 17 00:00:00 2001 From: Felix Wiegand Date: Wed, 21 Aug 2024 10:39:10 +0200 Subject: [PATCH] feat: Allow outputting of rendered yte config in Datavzrd wrapper (#3123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### QC * [ ] I confirm that I have followed the [documentation for contributing to `snakemake-wrappers`](https://snakemake-wrappers.readthedocs.io/en/stable/contributing.html). While the contributions guidelines are more extensive, please particularly ensure that: * [ ] `test.py` was updated to call any added or updated example rules in a `Snakefile` * [ ] `input:` and `output:` file paths in the rules can be chosen arbitrarily * [ ] wherever possible, command line arguments are inferred and set automatically (e.g. based on file extensions in `input:` or `output:`) * [ ] temporary files are either written to a unique hidden folder in the working directory, or (better) stored where the Python function `tempfile.gettempdir()` points to * [ ] the `meta.yaml` contains a link to the documentation of the respective tool or command under `url:` * [ ] conda environments use a minimal amount of channels and packages, in recommended ordering ## Summary by CodeRabbit - **New Features** - Added an optional output configuration file in YAML format for enhanced tracking of pipeline parameters and settings. - Implemented functionality to save processed data to a specified output configuration path, improving workflow management. - Enhanced metadata in the configuration file with additional context regarding the output structure and location. --------- Co-authored-by: Johannes Köster --- utils/datavzrd/meta.yaml | 2 ++ utils/datavzrd/test/Snakefile | 2 ++ utils/datavzrd/wrapper.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/utils/datavzrd/meta.yaml b/utils/datavzrd/meta.yaml index 29f7caa14a..a9a3c6f990 100644 --- a/utils/datavzrd/meta.yaml +++ b/utils/datavzrd/meta.yaml @@ -6,5 +6,7 @@ description: | Any files specified in the configuration file have to be also specified as additional input files in the datavzrd rule. url: https://github.com/datavzrd/datavzrd +output: +- config: Path to the rendered yte config authors: - Felix Mölder diff --git a/utils/datavzrd/test/Snakefile b/utils/datavzrd/test/Snakefile index 03b70eba31..6c9eaef015 100644 --- a/utils/datavzrd/test/Snakefile +++ b/utils/datavzrd/test/Snakefile @@ -21,6 +21,8 @@ rule datavzrd: # see https://snakemake.readthedocs.io/en/stable/snakefiles/reporting.html # for additional options like caption, categories and labels ), + # optionally output the rendered config + config = "resources/datavzrd/{sample}.rendered_config.yaml" log: "logs/datavzrd_report/{sample}.log", wrapper: diff --git a/utils/datavzrd/wrapper.py b/utils/datavzrd/wrapper.py index d0138a287f..03dd330d97 100644 --- a/utils/datavzrd/wrapper.py +++ b/utils/datavzrd/wrapper.py @@ -6,6 +6,7 @@ import tempfile from yte import process_yaml from snakemake.shell import shell +import shutil log = snakemake.log_fmt_shell(stdout=True, stderr=True) @@ -27,4 +28,6 @@ ) processed.flush() + if snakemake.output.config: + shutil.copy(processed.name, snakemake.output.config) shell("datavzrd {processed.name} {extra} --output {snakemake.output[0]} {log}")