Skip to main content
QUICK REVIEW

[Paper Review] Locality-Preserving Minimal Perfect Hashing of k-mers

Giulio Ermanno Pibiri, Y. Shibuya|arXiv (Cornell University)|Oct 24, 2022
Algorithms and Data CompressionComputer Science6 citations
TL;DR

This paper proposes LPHash, a locality-preserving minimal perfect hash function for k-mers that exploits overlapping sequences in genomic strings to achieve sub-log₂(e) bits per key—breaking the classic theoretical lower bound. By using random minimizers and partitioning k-mers into super-k-mers, LPHash reduces space usage to under 1 bit/key and accelerates streaming queries by up to 2× over state-of-the-art methods like PTHash and BBHash.

ABSTRACT

Minimal perfect hashing is the problem of mapping a static set of $n$ distinct keys into the address space $\{1,\ldots,n\}$ bijectively. It is well-known that $n\log_2(e)$ bits are necessary to specify a minimal perfect hash function (MPHF) $f$, when no additional knowledge of the input keys is to be used. However, it is often the case in practice that the input keys have intrinsic relationships that we can exploit to lower the bit complexity of $f$. For example, consider a string and the set of all its distinct $k$-mers as input keys: since two consecutive $k$-mers share an overlap of $k-1$ symbols, it seems possible to beat the classic $\log_2(e)$ bits/key barrier in this case. Moreover, we would like $f$ to map consecutive $k$-mers to consecutive addresses, as to also preserve as much as possible their relationship in the codomain. This is a useful feature in practice as it guarantees a certain degree of locality of reference for $f$, resulting in a better evaluation time when querying consecutive $k$-mers. Motivated by these premises, we initiate the study of a new type of locality-preserving MPHF designed for $k$-mers extracted consecutively from a collection of strings. We design a construction whose space usage decreases for growing $k$ and discuss experiments with a practical implementation of the method: in practice, the functions built with our method can be several times smaller and even faster to query than the most efficient MPHFs in the literature.

Motivation & Objective

  • Address the inefficiency of general-purpose minimal perfect hash functions (MPHFs) when applied to k-mers from biological sequences.
  • Exploit the inherent overlap between consecutive k-mers (sharing k−1 symbols) to reduce the space complexity below the theoretical log₂(e) ≈ 1.442 bits/key barrier.
  • Design a locality-preserving MPHF that maps consecutive k-mers to consecutive hash values to improve cache locality and satellite data compression.
  • Achieve both space efficiency and high query performance for streaming workloads common in bioinformatics.
  • Develop a practical, open-source implementation that outperforms existing MPHFs in both size and speed on real genomic datasets.

Proposed method

  • Use random minimizers to sample representative k-mers from long genomic sequences, reducing the effective key set size.
  • Group consecutive k-mers sharing the same minimizer into 'super-k-mers' to exploit structural locality and reduce redundancy.
  • Apply a two-level hashing scheme: a primary MPHF for super-k-mers and a fallback MPHF for ambiguous minimizers.
  • Leverage wavelet trees and rank-select data structures to support fast, compact rank queries within super-k-mer blocks.
  • Construct the final MPHF using a partitioned layout that preserves spatial locality and enables efficient streaming lookups.
  • Optimize the construction pipeline for external memory and parallel processing to scale to large datasets.

Experimental results

Research questions

  • RQ1Can we break the theoretical log₂(e) bits/key lower bound for minimal perfect hashing by exploiting structural relationships in k-mer sequences?
  • RQ2To what extent can locality-preserving hashing reduce space usage and improve query speed in k-mer workloads?
  • RQ3How effective is the use of random minimizers and super-k-mer partitioning in reducing redundancy and improving memory layout?
  • RQ4Can a locality-preserving MPHF outperform general-purpose MPHFs like PTHash and BBHash in both space and streaming query performance?
  • RQ5What is the impact of different minimizer sampling strategies on the final space and time efficiency of the MPHF?

Key findings

  • LPHash reduces space usage to 0.6–0.9 bits per k-mer, significantly below the theoretical minimum of 1.442 bits per key.
  • On large datasets like Human and Kestrel, LPHash achieves up to 2× faster streaming query performance than PTHash-v1 and up to 4× faster than PTHash-v2.
  • LPHash is 2× faster than BBHash on the Yeast dataset and up to 5× faster on larger datasets, while using substantially less memory.
  • Building time is competitive: LPHash is faster than PTHash on larger datasets due to smaller, partitioned MPHF constructions.
  • Random lookup performance is slower than PTHash due to increased evaluation complexity, but remains competitive with BBHash, especially on larger datasets.
  • The method scales effectively to real-world genomic data, with total construction time under 8 minutes for the Human dataset using 4 threads.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.