SAMTOOLS VIEW
Convert or filter SAM/BAM.
URL: http://www.htslib.org/doc/samtools-view.html
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
region="", # optional region string
threads: 2
wrapper:
"v5.0.1/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
The extra param allows for additional program arguments (not -@/–threads, –write-index, -o or -O/–output-fmt).
The region param allows one to specify region to extract as RNAME[:STARTPOS[-ENDPOS]] (e.g. chr1, chr2:10000000, chr3:1000-2000, ‘*’).
Software dependencies
samtools=1.21
snakemake-wrapper-utils=0.6.2
Input/Output
Input:
SAM/BAM/CRAM file
Output:
SAM/BAM/CRAM file
SAM/BAM/CRAM index file (optional)
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", "")
region = snakemake.params.get("region", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True, append=True)
shell("samtools view {samtools_opts} {extra} {snakemake.input[0]} {region} {log}")