GATK DEPTHOFCOVERAGE

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

Run gatk DepthOfCoverage (BETA).

URL: https://gatk.broadinstitute.org/hc/en-us/articles/9570475259291-DepthOfCoverage-BETA-

Example

This wrapper can be used in the following way:

rule gatk_depth_of_coverage:
    input:
        bam="mapped/a.bam",  # File containing reads
        fasta="genome.fasta",
        intervals="regions.interval_list",  # Regions where the coverage is computed
    output:
        multiext(
            "depth/a",
            "",
            ".sample_interval_summary",
            ".sample_cumulative_coverage_counts",
            ".sample_cumulative_coverage_proportions",
            ".sample_interval_statistics",
            ".sample_statistics",
            ".sample_summary",
        ),
    log:
        "logs/gatk/depthofcoverage.log",
    params:
        extra="",
        java_opts="",
    resources:
        mem_mb=1024,
    wrapper:
        "v3.9.0-1-gc294552/bio/gatk/depthofcoverage"

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

  • The extra param allows for additional program arguments.

Software dependencies

  • gatk4=4.5.0.0

  • snakemake-wrapper-utils=0.6.2

Input/Output

Input:

  • one bam file to be analyzed for coverage statistics

  • one or more genomic intervals over which to operate

  • reference genome

Output:

  • base file location to which to write coverage summary information

Authors

  • Lauri Mesilaakso

Code

__author__ = "Lauri Mesilaakso"
__copyright__ = "Copyright 2022, Lauri Mesilaakso"
__email__ = "lauri.mesilaakso@gmail.com"
__license__ = "MIT"

import tempfile
from snakemake.shell import shell
from snakemake_wrapper_utils.java import get_java_opts
from os import path

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

# Extract basename from the output file names
out_basename = path.commonprefix(snakemake.output).rstrip(".")

with tempfile.TemporaryDirectory() as tmpdir:
    shell(
        "gatk --java-options '{java_opts}' DepthOfCoverage"
        " --input {snakemake.input.bam}"
        " --intervals {snakemake.input.intervals}"
        " --reference {snakemake.input.fasta}"
        " --output {out_basename}"
        " --tmp-dir {tmpdir}"
        " {extra}"
        " {log}"
    )