SAMTOOLS FASTQ INTERLEAVED
Convert a bam file back to unaligned reads in a single fastq file with samtools. For paired end reads, this results in an unsorted interleaved file.
Example
This wrapper can be used in the following way:
rule samtools_fastq_interleaved:
input:
"mapped/{sample}.bam",
output:
"reads/{sample}.fq",
log:
"{sample}.interleaved.log",
params:
" ",
threads: 3
wrapper:
"v5.6.1-7-g2ff6d79/bio/samtools/fastq/interleaved"
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 or -o).
For more information see, http://www.htslib.org/doc/samtools-fasta.html
Software dependencies
samtools=1.14
snakemake-wrapper-utils=0.5.2
Code
__author__ = "David Laehnemann, Victoria Sack"
__copyright__ = "Copyright 2018, David Laehnemann, Victoria Sack"
__email__ = "david.laehnemann@hhu.de"
__license__ = "MIT"
import os
from snakemake.shell import shell
from snakemake_wrapper_utils.samtools import get_samtools_opts
samtools_opts = get_samtools_opts(
snakemake, parse_write_index=False, parse_output_format=False
)
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=False, stderr=True)
shell("samtools fastq {samtools_opts} {extra} {snakemake.input[0]} {log}")