bedtools bamtofastq is a conversion utility for extracting FASTQ records from sequence alignments in BAM format.
bamToFastq [OPTIONS] -i
-fq2 FASTQ for second end. Used if BAM contains paired-end data.
BAM should be sorted by query name
(samtools sort -n aln.bam aln.qsort
) if creating
paired FASTQ with this option.
-tags Create FASTQ based on the mate info in the BAM R2 and Q2 tags.