This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert fastq.gz to fastq.bgz

Hello,

Could someone please explain the difference between .gz and .bgz format - what are the advantages of one format over the other?

I would also like to know a way to convert fastq.gz to fastq.bgz files (and vice versa).

Thanks in advance for the help.

  • Akhil
ngs fastq

2 answers

A .bgz file is a "block gzipped" file, which can be thought of as a special kind of gzipped file. The main differences are summarized here by Peter Cock and boil down to bgz files having entries compressed in blocks. This is mostly useful for random access, which isn't commonly needed with fastq files. In theory one could use bgz files more efficiently with cloud-based aligners, but since those aren't exactly commonly used...

To convert from one to the other: zcat foo.gz | bgzip -c > foo.bgz or the reverse. Having said that, pretty much anything that handles gzipped files can handle block gzipped files (except for Java programs).

Yup, you beat me by a minute :)

Good question. Apparently the default gzip implementation used to not be able to handle that. I know that was an issue until at least a year or two ago, not sure if it still is.

Correct, and I forgot a b in bgzip.

Is it faster than bcftools view my.vcf.gz -Oz -o my_bgziped.vcf.gz ?

Yes, that actually parses the file, which is unnecessary when just running it through bgzip

I tested it quickly and it is a lot faster (talkings days for bcftools compared to just a couple of hours with zcat)

Read a detailed comparison at BGZF - Blocked, Bigger & Better GZIP! .

Summary: gzip is widely available on any Unix / Linux system, bgzip isn't; bgzip produces bigger files than gzip; however bgzip does allow for much faster random access than gzip.

Log in to answer this question.