SAMTOOLS VIEW

Convert or filter SAM/BAM.

Example

This wrapper can be used in the following way:

rule samtools_view:
    input:
        "{sample}.sam",
    output:
        bam="{sample}.bam",
        idx="{sample}.bai",
    log:
        "{sample}.log",
    params:
        extra="",  # optional params string
    threads: 2
    wrapper:
        "v1.9.0/bio/samtools/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.

Notes

Software dependencies

  • samtools=1.14
  • snakemake-wrapper-utils=0.3

Input/Output

Input:

  • SAM/BAM/CRAM file

Output:

  • SAM/BAM/CRAM file
  • SAM/BAM/CRAM index file (optional)

Authors

  • Johannes Köster
  • Filipe G. Vieira

Code

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


from snakemake.shell import shell
from snakemake_wrapper_utils.samtools import get_samtools_opts

samtools_opts = get_samtools_opts(snakemake)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True, append=True)


shell("samtools view {samtools_opts} {extra} {snakemake.input[0]} {log}")