Post

First off, the problem definition :) Sassy solves approximate string matching (ASM): finding all occurrences of a pattern in a text, with up to k errors. As you would expect from me, Sassy uses unit-cost edit distance.

The one long-lasting takeaway from this work: Searching a pattern P in text T and searching rev(P) in rev(T) give different results! Saying 'we find all matches' is kinda undefined, unless you specifically list all *intervals* of the text that align with cost <= k. But nobody does that.

Anyway, research on ASM is super old, with so many papers on it between 1980 and 2000. But then Myers'99 ruined the fun by introducing his O(ceil[k/w]*n) bitpacking algorithm (m=|P|, n=|T|), that computes 64 states in a column at once. Edlib also implements pretty much exactly this figure.

Speaking of Edlib: like many other modern tools, it solves 'semi-global alignment', which finds a (set of) alignments of the pattern to a substring of the text *of optimal cost*. Note that this can be much less than the set of matches of cost ≤k.

Algorithmically, the first main feature of Sassy is to tile the bitvectors horizontally, in the text direction. This way, we don't waste as much compute when only the top rows of the matrix are needed. In particular, usually the top 2*k rows are sufficient to get DP entries >k: O(k*ceil[n/w]).

Then, there is one more small contribution: we extend 'overlap' alignments to have an 'overhang' cost. This way, we can allow patterns matching only a prefix or suffix of the text, and control the penalty for characters extending beyond the text. By default, a cost of 0.5 works well.

Just one major drawback at this point: we didn't make an arm/neon port yet, and so we depend on avx2 and bmi2 instructions. Feel free to help out with this ;)

0 reposts0 likes