COVERAGEBED

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

Returns the depth and breadth of coverage of features from B on the intervals in A.

URL: https://bedtools.readthedocs.io/en/latest/content/tools/coverage.html

Example

This wrapper can be used in the following way:

rule coverageBed:
    input:
        a="bed/{sample}.bed",
        b="mapped/{sample}.bam"
    output:
        "stats/{sample}.cov"
    log:
        "logs/coveragebed/{sample}.log"
    params:
        extra=""  # optional parameters
    threads: 8
    wrapper:
        "v3.9.0/bio/bedtools/coveragebed"

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.

Notes

  • This program/wrapper does not handle multi-threading.

Software dependencies

  • bedtools=2.31.1

Input/Output

Input:

  • a: Path to the feature file (BAM/BED/GFF/VCF). This file is compared to b (see below)

  • b: Path or list of paths to file(s) (BAM/BED/GFF/VCF).

Output:

  • Path to the coverage file.

Params

  • extra: additional program arguments (except -a and -b)

Authors

  • Patrik Smeds

Code

__author__ = "Patrik Smeds"
__copyright__ = "Copyright 2019, Patrik Smeds"
__email__ = "patrik.smeds@gmail.com"
__license__ = "MIT"


from snakemake.shell import shell

shell.executable("bash")

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

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

input_a = snakemake.input.a
input_b = snakemake.input.b

output_file = snakemake.output[0]

if not isinstance(output_file, str) and len(snakemake.output) != 1:
    raise ValueError("Output should be one file: " + str(output_file) + "!")

shell(
    "coverageBed"
    " -a {input_a}"
    " -b {input_b}"
    " {extra_params}"
    " > {output_file}"
    " {log}"
)