.. _`utils/nextflow`: NEXTFLOW ======== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/utils/nextflow?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Autils/nextflow Run nextflow pipeline Example ------- This wrapper can be used in the following way: .. code-block:: python rule chipseq_pipeline: input: input="design.csv", fasta="data/genome.fasta", gtf="data/genome.gtf", # any -- pipeline file arguments can be given here as = output: "results/multiqc/broadPeak/multiqc_report.html", params: pipeline="nf-core/chipseq", revision="2.0.0", profile=["test", "docker"], # The chosen pipeline expects an --outdir to be given. # We infer this from the output file path. Since that file path can be changed # e.g. in case of cloud storage, we use a lambda function to infer the outdir. outdir=lambda wildcards, output: str(Path(output[0]).parents[-2]), # any -- pipeline arguments can be given here as = handover: True wrapper: "v3.0.4/utils/nextflow" Note that input, output and log file paths can be chosen freely. When running with .. code-block:: bash snakemake --use-conda the software dependencies will be automatically deployed into an isolated environment before execution. Notes ----- This wrapper can e.g. be used to run `nf-core `_ pipelines. In each of the nf-core pipeline descriptions, you will find available parameters and the output file structure (under "aws results"). The latter can be used to set the desired output files for this wrapper. Software dependencies --------------------- * ``nextflow`` Authors ------- * Johannes Köster Code ---- .. code-block:: python __author__ = "Johannes Köster" __copyright__ = "Copyright 2021, Johannes Köster" __email__ = "johannes.koester@uni-due.de" __license__ = "MIT" import os from snakemake.shell import shell revision = snakemake.params.get("revision") profile = snakemake.params.get("profile", []) extra = snakemake.params.get("extra", "") if isinstance(profile, str): profile = [profile] args = [] if revision: args += ["-revision", revision] if profile: args += ["-profile", ",".join(profile)] print(args) # TODO pass threads in case of single job # TODO limit parallelism in case of pipeline # TODO handle other resources add_parameter = lambda name, value: args.append("--{} {}".format(name, value)) for name, files in snakemake.input.items(): if isinstance(files, list): # TODO check how multiple input files under a single arg are usually passed to nextflow files = ",".join(files) add_parameter(name, files) for name, value in snakemake.params.items(): if ( name != "pipeline" and name != "revision" and name != "profile" and name != "extra" ): add_parameter(name, value) log = snakemake.log_fmt_shell(stdout=False, stderr=True) args = " ".join(args) pipeline = snakemake.params.pipeline shell("nextflow run {pipeline} {args} {extra} {log}") .. |nl| raw:: html