SAMTOOLS DEPTH

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

Compute the read depth at each position or region using samtools.

Example

This wrapper can be used in the following way:

rule samtools_depth:
    input:
        bams=["mapped/A.bam", "mapped/B.bam"],
        bed="regionToCalcDepth.bed",  # optional
    output:
        "depth.txt",
    log:
        "depth.log",
    params:
        # optional bed file passed to -b
        extra="",  # optional additional parameters as string
    wrapper:
        "v3.10.2-32-gf4e5b66/bio/samtools/depth"

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

Software dependencies

  • samtools=1.20

  • snakemake-wrapper-utils=0.6.2

Authors

  • Dayne Filer

  • Filipe G. Vieira

Code

"""Snakemake wrapper for running samtools depth."""

__author__ = "Dayne L Filer"
__copyright__ = "Copyright 2020, Dayne L Filer"
__email__ = "dayne.filer@gmail.com"
__license__ = "MIT"

from snakemake.shell import shell
from snakemake_wrapper_utils.samtools import get_samtools_opts

samtools_opts = get_samtools_opts(
    snakemake, parse_write_index=False, parse_output_format=False
)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)

# check for optional bed file
bed = snakemake.input.get("bed", "")
if bed:
    bed = "-b " + bed

shell("samtools depth {samtools_opts} {extra} {bed} {snakemake.input.bams} {log}")