SAMBAMBA SLICE

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

Fast tool for copying a slice of a BAM file. See details `here https://lomereiter.github.io/sambamba/docs/sambamba-slice.html`_

Example

This wrapper can be used in the following way:

rule sambamba_slice:
    input:
        bam="mapped/{sample}.bam",
        bai="mapped/{sample}.bam.bai"
    output:
        "mapped/{sample}.region.bam"
    params:
        region="xx:1-10"  # region to catch (contig:start-end)
    log:
        "logs/sambamba-slice/{sample}.log"
    wrapper:
        "v3.8.0/bio/sambamba/slice"

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

Input/Output

Input:

  • coordinate-sorted and indexed bam file

Output:

  • new bam file with specific region

Authors

  • Jan Forster

Code

__author__ = "Jan Forster"
__copyright__ = "Copyright 2021, Jan Forster"
__email__ = "j.forster@dkfz.de"
__license__ = "MIT"


import os
from snakemake.shell import shell

log = snakemake.log_fmt_shell(stdout=False, stderr=True)

shell(
    "sambamba slice "
    "{snakemake.input[0]} {snakemake.params.region} > {snakemake.output[0]} "
    "{log}"
)