SAMTOOLS BAM2FQ 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.

Software dependencies

  • samtools ==1.9

Example

This wrapper can be used in the following way:

rule samtools_bam2fq_interleaved:
    input:
        "mapped/{sample}.bam"
    output:
        "reads/{sample}.fq"
    params:
        " "
    threads: 3
    wrapper:
        "0.50.4/bio/samtools/bam2fq/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.

Authors

  • David Laehnemann
  • Victoria Sack

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


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

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