SAMTOOLS DEPTH¶
Compute the read depth at each position or region using samtools.
Software dependencies¶
- samtools ==1.10
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"
params:
# optional bed file passed to -b
extra="" # optional additional parameters as string
wrapper:
"0.62.0/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.
Authors¶
- Dayne Filer
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
params = snakemake.params.get("extra", "")
# check for optional bed file
bed = snakemake.input.get("bed", "")
if bed:
bed = "-b " + bed
shell(
"samtools depth {params} {bed} " "-o {snakemake.output[0]} {snakemake.input.bams}"
)