Entering edit mode
2.2 years ago
Eliveri
▴
350
I would like to convert .bam files to fq.gz (zipped fasta files) for paired reads.
bedtools bamtofastq seems to be a commonly recommended method, I have also seen samtools fastq as a possible alternative.
bedtools bamtofastq -i inputfile.bam -fq outputR1.fq -fq2 outputR2.fq
samtools fastq -@ 8 unmapped_sorted.bam \
-1 outputR1.fastq.gz \
-2 outputR2.fastq.gz \
-0 /dev/null -s /dev/null -n
It seems for bedtools bamtofastq it is not possible to output zipped fasta files.
Is samtools fastq a good alternative?
Hi! Just as an alternative to samtools (which should work), maybe worth trying
reformat.sh
from BBMap suite as suggested in Converting large (compressed and unsorted) BAM files to fastqThank you for the suggestion!
samtools should be fine: samtools fastq compression
Be sure to use
file
to manually check that it is indeed gzip-compressed once finished.Thank you for the confirmation and tips!