SAMBAMBA VIEW
Filter and/or view BAM files. See details `here https://lomereiter.github.io/sambamba/docs/sambamba-view.html`_
Example
This wrapper can be used in the following way:
rule sambamba_view:
input:
"mapped/{sample}.bam"
output:
"mapped/{sample}.filtered.bam"
params:
extra="-f bam -F 'mapping_quality >= 50'" # optional parameters
log:
"logs/sambamba-view/{sample}.log"
threads: 8
wrapper:
"v5.6.1-7-g2ff6d79/bio/sambamba/view"
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.
Software dependencies
sambamba=1.0.1
Input/Output
Input:
bam/sam file
Output:
(filtered) bam/sam file
Code
__author__ = "Jan Forster"
__copyright__ = "Copyright 2021, Jan Forster"
__email__ = "j.forster@dkfz.de"
__license__ = "MIT"
import os
from snakemake.shell import shell
in_file = snakemake.input[0]
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
if in_file.endswith(".sam") and ("-S" not in extra or "--sam-input" not in extra):
extra += " --sam-input"
shell(
"sambamba view {extra} -t {snakemake.threads} "
"{snakemake.input[0]} > {snakemake.output[0]} "
"{log}"
)