Backward search 2026-10-20
Backward search finds a query's matching interval in a suffix array by processing the query from right to left. With inclusive one-based interval , prepending changes it to . An empty interval means no match. This works through the occurrence-order property of the last-to-first mapping.[ref]
Opportunistic Data Structures with Applications by Paolo Ferragina and others. §3.1, Figure 1, BW Search
Burrows-Wheeler transform 2026-10-20
The Burrows-Wheeler transform appends a unique smallest terminator to a string, sorts its cyclic rotations in lexicographic order, and records the last column. It is reversible because the first and last columns contain the same characters and the last-to-first mapping preserves the occurrence order of each character. The resulting letter arrangement supports both compression and backward search.[ref]
Opportunistic Data Structures with Applications by Paolo Ferragina and others. §2, Background: sorted cyclic shifts and inversion
FM-index 2026-10-20
An FM-index is a compressed text index supporting backward search through the Burrows-Wheeler transform and occurrence counts. Character rank queries locate a matching interval; sampled suffix array positions then allow the actual text positions to be recovered. Query length, number of matches and the chosen sampling density control different parts of the search cost.[ref]
Opportunistic Data Structures with Applications by Paolo Ferragina and others. §§3.1–3.2, counting and locating occurrences
Relevant passages: §2, Background, Burrows-Wheeler transform and last-to-first mapping; §3.1, Figure 1, counting occurrences by backward search; §3.2, locating occurrences.
Use one-based row numbers, and write and for the first and last columns. The last-to-first mapping matches the th occurrence of a character in to its th occurrence in : equal characters retain the ordering of their following suffixes. This lets us extend an interval of matching suffixes one character to the left without reconstructing the full strings.
Start with the last query character. Rows of contain C, so the interval of suffixes beginning with C is . Within those rows, the A entries of are at rows and . They are respectively the first and second A entries in all of , and therefore map to rows and of . These are exactly the suffixes beginning with AC. Reading their supplied positions gives matches starting at positions 11 and 3, or positions 3 and 11 in increasing genomic order.
The same calculation can be written as backward search. Let count characters strictly smaller than , and let count occurrences of in , with . Prepending changes an inclusive interval toHere , and , giving .
Build an FM-index: store the Burrows-Wheeler transform, cumulative character counts , and a structure supporting fast rank queries for . Then each step of backward search uses two rank queries instead of rescanning the last column. A wavelet tree or suitably checkpointed counts can supply these queries while keeping memory manageable. The counting cost is proportional to query length times the rank query cost, rather than repeatedly scanning the whole genome.[ref]
Opportunistic Data Structures with Applications by Paolo Ferragina and others. §2, LF-mapping; §§3.1–3.2, counting and locating occurrences
To recover genomic positions, store a sampled suffix array and follow the last-to-first mapping to a sampled position, adding the number of steps taken. More samples trade storage for faster position recovery. Index character counts and sample positions, rather than storing the quadratic-size full cyclic rotation matrix.