pybedtools.bedtool.BedTool.bam_to_fastq

BedTool.bam_to_fastq(*args, **kwargs)[source]

Wraps bedtools bamtofastq.

The fq argument is required.

The resulting BedTool will have a new attribute, fastq.

For convenience, the file or stream this BedTool points to is implicitly passed as the -i argument to bamToFastq

Original BEDTools help::

Tool:    bedtools bamtofastq (aka bamToFastq)
Version: v2.31.1
Summary: Convert BAM alignments to FASTQ files. 

Usage:   bamToFastq [OPTIONS] -i <BAM> -fq <FQ> 

Options:
        -fq2    FASTQ for second end.  Used if BAM contains paired-end data.
                BAM should be sorted by query name is creating paired FASTQ.

        -tags   Create FASTQ based on the mate info
                in the BAM R2 and Q2 tags.

Tips: 
        If you want to create a single, interleaved FASTQ file 
        for paired-end data, you can just write both to /dev/stdout:

        bedtools bamtofastq -i x.bam -fq /dev/stdout -fq2 /dev/stdout > x.ilv.fq

        Also, the samtools fastq command has more fucntionality and is a useful alternative.