Converting Bam file to Fasta (Zipped)
0
0
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?

bedtools samtools • 1.5k views
ADD COMMENT
2
Entering edit mode

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 fastq

ADD REPLY
1
Entering edit mode

Thank you for the suggestion!

ADD REPLY
1
Entering edit mode

samtools should be fine: samtools fastq compression

Be sure to use file to manually check that it is indeed gzip-compressed once finished.

ADD REPLY
1
Entering edit mode

Thank you for the confirmation and tips!

ADD REPLY

Login before adding your answer.

Traffic: 3550 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6