SAMBAMBA SORT

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

Sort bam file with sambamba

Example

This wrapper can be used in the following way:

rule sambamba_sort:
    input:
        "mapped/{sample}.bam"
    output:
        "mapped/{sample}.sorted.bam"
    params:
        ""  # optional parameters
    log:
        "logs/sambamba-sort/{sample}.log"
    threads: 8
    wrapper:
        "v3.9.0-1-gc294552/bio/sambamba/sort"

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:

  • bam file

Output:

  • sorted bam file

Authors

  • Johannes Köster

Code

__author__ = "Johannes Köster"
__copyright__ = "Copyright 2016, Johannes Köster"
__email__ = "koester@jimmy.harvard.edu"
__license__ = "MIT"


import os
from snakemake.shell import shell
from tempfile import TemporaryDirectory

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

with TemporaryDirectory() as tempdir:
    shell(
        "sambamba sort {snakemake.params} --nthreads {snakemake.threads} "
        "--tmpdir {tempdir} --out {snakemake.output[0]} {snakemake.input[0]} "
        "{log}"
    )