MOSDEPTH

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

fast BAM/CRAM depth calculation for WGS, exome, or targeted sequencing.

URL: https://github.com/brentp/mosdepth

Example

This wrapper can be used in the following way:


test/Snakefile not found.

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.

Input/Output

Input:

  • bam: input bam file.

  • bai: input bam index.

Output:

  • summary: xxx.mosdepth.summary.txt.

Params

  • mosdepth: mosdepth path. default mosdepth. (optional)

  • by: bin size or bed file. default none. (optional)

  • thresholds: thresholds. default none. (optional)

  • extras: extra arguments. (optional)

Authors

  • yangqun

Code

# mosdepth wrapper.
__author__ = "yangqun"

import sys
import os
from snakemake.shell import shell

# params
assert 'bam' in snakemake.input.keys()
assert 'bai' in snakemake.input.keys()
assert 'summary' in snakemake.output.keys()

bam = snakemake.input.get('bam')
bai = snakemake.input.get('bai')
summary = snakemake.output.get('summary')
prefix = summary.replace(".mosdepth.summary.txt", "")

# optional
mosdepth = snakemake.params.get('mosdepth', 'mosdepth')
by = snakemake.params.get('by', '')
if by:
    by = '--by ' + by

thresholds = snakemake.params.get('thresholds', '')
if thresholds:
    thresholds = '--thresholds ' + thresholds

extras = snakemake.params.get('extras', '')

# threads
threads = snakemake.threads if snakemake.threads <= 4 else 4

# run
shell(
    "{mosdepth} -t {threads} {by} {thresholds} {extras} {prefix} {bam}"
)