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.

URL:

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:
        "v1.1.0/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.

Software dependencies

  • samtools=1.14

Notes

Authors

  • David Laehnemann
  • Victoria Sack
  • Filipe G. Vieira

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

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

prefix = os.path.splitext(snakemake.output[0])[0]

shell(
    "samtools fastq {snakemake.params} "
    " -@ {snakemake.threads} "
    " {snakemake.input[0]}"
    " > {snakemake.output[0]} "
    "{log}"
)