This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting Bam file to Fasta (Zipped)

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

Thank you for the suggestion!

Thank you for the confirmation and tips!

0 answers

No answers yet.

Log in to answer this question.