mim: A lightweight auxiliary index to enable fast, parallel, gzipped FASTQ parsing

Rob Patro, Siddhant Bharti, Prajwal Singhania, Rakrish Dhakal, Thomas J. Dahlstrom, Ragnar Groot KoerkampbioRxiv 2025

Abstract: The FASTQ file format is the <i>lingua franca</i> of primary data distribution and processing across most of bioinformatics. Over time, the compression, storage, transmission, and decompression of gzip compressed fastq.gz files has become a substantial scalability bottleneck in the modern world of fast and massively parallel genomics tools and algorithms. In this work, we introduce mim: a lightweight, <i>auxiliary</i> index that enables fast, parallel, and highly-scalable parsing of compressed fastq.gz files. The creation of the mim index for a file is a one-time operation that can be performed in time comparable to that of simply decompressing and parsing the file (index creation induces ~20% overhead) and with minimal working memory. The mim index itself is very small, usually about <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"> <mml:mfrac><mml:mrow><mml:mn>1</mml:mn></mml:mrow> <mml:mrow><mml:mn>1000</mml:mn></mml:mrow> </mml:mfrac> </mml:math> -th of the size of the original compressed file, and can be easily stored along side the file or fetched from a remote location when it is needed. Further, the mim index is purely additive - it does not modify the original gzipped FASTQ file in any way, nor require that the file be recompressed or rewritten - and thus it does not require converting the massive back catalog of existing raw sequencing data. To demonstrate the feasibility and utility of the mim index, we benchmark construction of the mim index on a variety of existing gzipped FASTQ data, and also measure thread-scaling of mim index-assisted parallel FASTQ parsing on a simple parsing/decompression-related task. We find that, for the one-time cost of index creation, and a small fraction of extra storage space, the mim index can massively accelerate the ingestion and parsing of gzipped FASTQ data, exhibiting near linear thread scaling in our experiments. mim is written in C++17, and is available as open source software under a BSD 3-clause license at https://github.com/COMBINE-lab/mim.

Introduction

In the field of bioinformatics, the FASTQ format serves as the universal standard for raw sequencing data. Due to the immense volume of data generated by modern sequencing technologies, these files are almost exclusively stored and transmitted in the compressed .gz (gzip) format. However, the gzip algorithm is fundamentally serial; to decompress data at a specific byte offset, a decoder must typically process the entire preceding stream to maintain the necessary compression context.

As genomics tools have evolved to become massively parallel, this serial decompression has emerged as a critical scalability bottleneck. While specialized formats like BGZF (Blocked GNU Zip Format) offer parallel access, they require re-compressing data into a specific structure. Given that over 60 Petabytes of data are already archived in standard gzip format across public repositories like the European Nucleotide Archive (ENA), re-compressing this "back catalog" is computationally and logistically prohibitive. Researchers require a solution that enables parallelization for existing gzipped files without modification.

The mim Indexing Strategy

We introduce mim, a lightweight auxiliary index designed to break the serial bottleneck of gzipped FASTQ files. mim builds upon the zran concept from the zlib library, enhancing it with "genomic awareness" to facilitate efficient parsing.

The indexing process involves scanning a gzipped file to create "checkpoints" at regular intervals—by default, every 32MB of uncompressed data. Each checkpoint stores the exact state of the gzip decoder, including the 32KB of context required to resume decompression immediately from that point.

Overview of the mim indexing process, showing the relationship between the uncompressed FASTQ, the gzipped file, and the resulting .mim index.

Crucially, mim adds semantic metadata to these checkpoints. It records the byte offset to the first complete FASTQ record following the checkpoint and the "record rank" (the numerical index of that record). This allows a parser to jump to any checkpoint and immediately begin processing valid records with full knowledge of their position in the sequence.

Parallel Parsing and Synchronization

The mim index enables a "divide and conquer" approach to file parsing. A tool can assign distinct segments of a file to different CPU threads. Each thread utilizes the index to jump to its assigned checkpoint, skips the necessary bytes to reach the start of a record, and proceeds independently.

Because mim tracks record ranks, it elegantly solves the synchronization problem for paired-end reads. In paired-end sequencing, two separate files contain matching DNA fragments that must be processed in tandem. With mim, threads can synchronize across multiple files without inter-thread communication, ensuring that matching records are always processed together. To ensure data integrity, each index includes a BLAKE3 hash of its source file, preventing the accidental use of mismatched indices.

Experimental Evaluation

The performance of mim was evaluated using 11 diverse gzipped FASTQ datasets, encompassing metagenomic sequencing, ChIP-seq, RNA-seq, and single-cell ATAC-seq, with compressed file sizes ranging from 400MB to 24GB.

The evaluation confirmed that the mim index is remarkably compact. For standard gzipped files, the index size is typically only 0.1% (1/1000th) of the original compressed file. Furthermore, mim is compatible with BGZF files; in these cases, the index is even smaller (approximately 0.0003% of the file size) as it leverages existing block boundaries.

Table showing the performance of mim across various datasets, highlighting the minimal index size and massive size reduction relative to the original uncompressed data.

In practical testing, mim-assisted parsing demonstrated near-linear speedup as thread counts increased. For example, a 132GB FASTQ file that required 12 minutes to parse serially was processed in just 37 seconds using 24 threads. The one-time cost of index construction is approximately 1.2x the time of a single-threaded parse, a cost easily amortized by subsequent parallel analyses.

Conclusion and Future Work

mim provides a purely additive, non-invasive solution to the gzip bottleneck in bioinformatics. By enabling high-performance parallel parsing of existing data archives, it allows researchers to fully utilize modern hardware without the need for data re-compression. Future development aims to parallelize the index construction process itself and expand language support through Rust implementations and Python bindings. The ultimate vision is for major data repositories to host these tiny mim indices alongside raw data, facilitating immediate, high-speed parallel access for the global research community.

Summary updated

Abstract

The FASTQ file format is the <i>lingua franca</i> of primary data distribution and processing across most of bioinformatics. Over time, the compression, storage, transmission, and decompression of gzip compressed fastq.gz files has become a substantial scalability bottleneck in the modern world of fast and massively parallel genomics tools and algorithms. In this work, we introduce mim: a lightweight, <i>auxiliary</i> index that enables fast, parallel, and highly-scalable parsing of compressed fastq.gz files. The creation of the mim index for a file is a one-time operation that can be performed in time comparable to that of simply decompressing and parsing the file (index creation induces ~20% overhead) and with minimal working memory. The mim index itself is very small, usually about <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"> <mml:mfrac><mml:mrow><mml:mn>1</mml:mn></mml:mrow> <mml:mrow><mml:mn>1000</mml:mn></mml:mrow> </mml:mfrac> </mml:math> -th of the size of the original compressed file, and can be easily stored along side the file or fetched from a remote location when it is needed. Further, the mim index is purely additive - it does not modify the original gzipped FASTQ file in any way, nor require that the file be recompressed or rewritten - and thus it does not require converting the massive back catalog of existing raw sequencing data. To demonstrate the feasibility and utility of the mim index, we benchmark construction of the mim index on a variety of existing gzipped FASTQ data, and also measure thread-scaling of mim index-assisted parallel FASTQ parsing on a simple parsing/decompression-related task. We find that, for the one-time cost of index creation, and a small fraction of extra storage space, the mim index can massively accelerate the ingestion and parsing of gzipped FASTQ data, exhibiting near linear thread scaling in our experiments. mim is written in C++17, and is available as open source software under a BSD 3-clause license at https://github.com/COMBINE-lab/mim.
BibTeX
@misc{patro2025mim,
  author = {Rob Patro and Siddhant Bharti and Prajwal Singhania and Rakrish Dhakal and Thomas J. Dahlstrom and Ragnar Groot Koerkamp},
  title = {{mim: A lightweight auxiliary index to enable fast, parallel, gzipped FASTQ parsing}},
  year = {2025},
  doi = {10.1101/2025.11.24.690271},
  howpublished = {bioRxiv},
}
Figure