How to convert BAM format to Fastq format?


I got seq data from PacBio plateform. That was formatted by BAM. Do you know how to convert xx.bam file to fastq file to analyze them in qiime2?



Hi @baehsung,
Looks like you can use the command bamtofastq. Here is the link to the documentation: bamtofastq — bedtools 2.31.0 documentation

Hope that helps!



Looks like PacBio also has their own software for converting their BAM files into Fastq files.

See this PDF, page 3, bam2fastq

bam2fastq -o myEcoliRuns \
  m54008_160330_053509.subreads.bam \

Dear Hee-Sung

You can also use samtools to convert BAM or CRAM to either FASTQ or FASTA files.
It's a useful tool alongside the other recommendations.

Thanks all for kind replies.

I run qiime2 in miniconda environments. Do you know the codes how to download samtools and install it in my system?


Dear Hee-Sung,

You'll be able to install it within your conda environment with the following commands:

conda install -c bioconda samtools
conda install -c "bioconda/label/cf201901" samtools

Dear @baehsung @skose82 ,

Depending on what plugins you installed in your conda environment, samtools should already be installed. It is a dependency for a few QIIME 2 plugins, including at least one in the standard core distribution I believe. So try running this to check your environment before installing:

conda list samtools

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.