DATAVZRD

https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/utils/datavzrd?label=version%20update%20pull%20requests

datavzrd allows to render tables by providing a configuration file. Configuration templates can be dynamically customized by utilizing the rendering integration. 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

Example

This wrapper can be used in the following way:

rule datavzrd:
    input:
        # the config file may be a yte template, with access to input, params and wildcards
        # analogous to Snakemake's generic template support:
        # https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#template-rendering-integration
        # For template processing, __use_yte__: true has to be stated in the config file
        config="resources/{sample}.datavzrd.yaml",
        # optional files required for rendering the given config
        table="data/{sample}.tsv",
    params:
        extra="",
    output:
        report(
            directory("results/datavzrd-report/{sample}"),
            htmlindex="index.html",
            # see https://snakemake.readthedocs.io/en/stable/snakefiles/reporting.html
            # for additional options like caption, categories and labels
        ),
    log:
        "logs/datavzrd_report/{sample}.log",
    wrapper:
        "v3.12.1-18-g9861c57/utils/datavzrd"

Note that input, output and log file paths can be chosen freely.

When running with

snakemake --use-conda

the software dependencies will be automatically deployed into an isolated environment before execution.

Software dependencies

  • datavzrd=2.36.15

  • yte=1.5.4

Authors

  • Felix Mölder

Code

__author__ = "Johannes Köster"
__copyright__ = "Copyright 2017, Johannes Köster"
__email__ = "johannes.koester@protonmail.com"
__license__ = "MIT"

import tempfile
from yte import process_yaml
from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=True, stderr=True)

extra = snakemake.params.get("extra", "")

with tempfile.NamedTemporaryFile(mode="w") as processed, open(
    snakemake.input.config
) as f:
    # support templating in the config file
    process_yaml(
        f,
        outfile=processed,
        variables={
            "params": snakemake.params,
            "wildcards": snakemake.wildcards,
            "input": snakemake.input,
        },
        require_use_yte=True,
    )
    processed.flush()

    shell("datavzrd {processed.name} {extra} --output {snakemake.output[0]} {log}")