Prefix-Free Parsing for Building Big BWTs

Christina Boucher, Travis Gagie, Alan Kuhnle, Ben Langmead, Giovanni Manzini, Taher Mun

TL;DR

Prefix-Free Parsing (PFP) is a novel preprocessing algorithm designed to make the Burrows-Wheeler Transform (BWT) computation memory-efficient for massive, highly repetitive genomic databases. By breaking large text datasets into a compact dictionary and a small parse, PFP reduces peak memory usage by up to 10x, allowing terabyte-scale sequencing data to be indexed within standard internal memory limits.

What Problem Does This Paper Address?

High-throughput DNA sequencing has led to an explosion of genomic databases, which are rapidly expanding toward hundreds of terabytes. To search these massive datasets efficiently, researchers rely on search indexes built using the Burrows-Wheeler Transform (BWT) and FM-indexes.

However, constructing a BWT for massive datasets is a notorious computational bottleneck. Standard algorithms require workspace proportional to the uncompressed text size, which quickly exceeds available RAM. While genomic data from the same species is highly repetitive (humans share roughly 99% of their DNA), traditional BWT construction methods cannot easily exploit this redundancy during the construction phase without hitting severe memory or disk I/O walls.

The relationship between the Suffix Array and the Last-to-First (LF) mapping underlies modern FM-indexes, as illustrated in the paper's review of classic indexing structures:

The Suffix Array and LF mapping for an example string collection.

The authors address this gap by introducing a preprocessing step that compresses the text into a manageable form before the BWT is computed.

Methods

The core innovation is Prefix-Free Parsing (PFP), a one-pass, linear-time preprocessing algorithm inspired by rsync’s rolling hash network protocol.

  1. Parsing Phase: The algorithm slides a window of length $w$ over the input text $T$. Whenever the Karp-Rabin hash of the window equals 0 modulo a parameter $p$, a phrase boundary is triggered. This divides the text into overlapping, variable-length phrases.
  2. Dictionary and Parse Generation: This process yields a Dictionary ($D$) of unique phrases and a Parse ($P$), which is a sequence of phrase IDs representing the original text.
  3. BWT Construction: Because the phrases terminate with specific trigger windows, the set of their suffixes is mathematically "prefix-free." This unique property allows the full BWT of the original text $T$ to be computed directly from $D$ and $P$ using workspace proportional only to their combined size, completely bypassing the need to keep the massive original text in memory.

Datasets

The authors evaluated PFP on several highly repetitive datasets:

  • Pizza & Chili Corpus: Standard repetitive text benchmarks including cere (yeast genome), einstein.en.txt, influenza, and world_leaders.
  • GenomeTrakr Salmonella Dataset: Publicly available environmental databases of microbial genomes, testing collections of up to 10,000 Salmonella genomes (totaling nearly 50 GB uncompressed).
  • 1000 Genomes Project: Haplotype data for human chromosome 19 (chr19), scaling up to 1,000 distinct versions to simulate large-scale human cohort indexing.

Key Insights and Ideas

  • Exploiting Repetition Early: Instead of compressing the data after building the index, PFP compresses the text before building the BWT, drastically lowering the memory footprint during the most intensive computation phase.
  • Locality via Rolling Hashes: Using a rolling hash ensures that a mutation in a genome only alters its local phrase. The rest of the repetitive text yields identical phrases, keeping the dictionary $D$ extremely small even as thousands of genomes are added.
  • The Power of Prefix-Free Suffixes: The prefix-free property guarantees that the relative lexicographic order of two phrase suffixes is determined entirely by the suffixes themselves. This decouples the global sorting problem into smaller, independent chunks that can be resolved using the parse.

Key Results

  • Massive Space Reduction: For 10,000 Salmonella genomes (~50 GB), the combined size of the dictionary and parse was only ~7 GB (a 14% footprint), allowing it to easily fit into the RAM of a commodity machine.
  • Memory and Time Efficiency: PFP reduced peak memory usage by 4x to 10x compared to simplebwt (a baseline using the state-of-the-art SACA-K algorithm). For large datasets (5,000+ genomes), it cut runtime by factors of 2 to 4.
  • Human-Scale Scaling: The authors built a 131 MB run-length compressed FM-index (RLFM) for 1,000 copies of human chromosome 19 in 2 hours using 21 GB of RAM. They project that a full index for 1,000 complete human genomes (approx. 300 TB uncompressed) would take just 6.73 GB of disk space and could be built in 102 hours using ~1.1 TB of RAM.

Limitations and Future Work

  • Counting vs. Locating: The current highly efficient implementation only supports "counting" queries (finding how many times a sequence occurs). Supporting "locating" queries (finding where it occurs) requires Suffix Array (SA) sampling. The authors' preliminary SA sampling tool (bwtscan) currently acts as a major memory bottleneck.
  • Parallelization Bottlenecks: Multi-threading scaling is currently limited to a 2x speedup with 4 threads due to disk I/O bottlenecks and synchronized dictionary updates.
  • Streaming/Server-side Parsing: The authors note that PFP could theoretically be run server-side or as a stream during download to avoid ever storing uncompressed datasets locally, which remains an open area for future implementation.

Summary updated

BibTeX
@inproceedings{boucher2018prefix,
  author = {Christina Boucher and Travis Gagie and Alan Kuhnle and Ben Langmead and Giovanni Manzini and Taher Mun},
  title = {{Prefix-Free Parsing for Building Big BWTs}},
  booktitle = {WABI},
  year = {2018},
  url = {https://openreview.net/forum?id=ivCnvsRCfJi},
}
Figure