COOLPUP.PY

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

Pileup features for a resolution in an .mcool file

URL: https://github.com/open2c/coolpuppy

Example

This wrapper can be used in the following way:

rule coolpuppy:
    input:
        cooler="CN.mm9.1000kb.mcool",  ## Multiresolution cooler file
        features="CN.mm9.toy_features.bed",  ## Feature file
        expected="CN.mm9.toy_expected.tsv",  ## Expected file
        view="CN.mm9.toy_regions.bed",  ## File with the region names and coordinates
    output:
        "CN_{resolution,[0-9]+}.clpy",
    params:
        ## Add optional parameters
        features_format="bed",  ## Format of the features file
        extra="--local",  ## Add extra parameters
    threads: 2
    log:
        "logs/CN_{resolution}_coolpuppy.log",
    wrapper:
        "v4.6.0-24-g250dd3e/bio/coolpuppy"

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

  • coolpuppy=1.1.0

Input/Output

Input:

  • a multiresolution cooler file (.mcool)

  • a file with features to pileup

  • (optional) file with expected

  • (optional) view, a bed-style file with region coordinates and names to use for analysis

Output:

  • A file (.clpy, HDF5-based format) with the pileup. Can have a {resolution} wildcard that specifies the resolution for the analysis, then it doesn’t need to be specified as a parameter.

Params

  • resolution: Optional, can be instead specified as a wildcard in the output

  • extra: Any additional arguments to pass

Authors

  • Ilya Flyamer

Code

__author__ = "Ilya Flyamer"
__copyright__ = "Copyright 2022, Ilya Flyamer"
__email__ = "flyamer@gmail.com"
__license__ = "MIT"

from snakemake.shell import shell

## Extract arguments
view = snakemake.input.get("view", "")
if view:
    view = f"--view {view}"
expected = snakemake.input.get("expected", "")
if expected:
    expected = f"--expected {expected}"

extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

resolution = snakemake.params.get("resolution", snakemake.wildcards.get("resolution"))
if not resolution:
    raise ValueError("Please specify resolution either as a wildcard or as a parameter")

shell(
    "(coolpup.py"
    " {snakemake.input.cooler}::resolutions/{resolution}"
    " {snakemake.input.features}"
    " {expected}"
    " --features-format {snakemake.params.features_format}"
    " {view}"
    " -p {snakemake.threads}"
    " {extra}"
    " -o {snakemake.output}) {log}"
)