Manuscript Offprint
arXiv:2610.10500Taxonomic Classification with Complete Tag Arrays
Abstract
Taxonomic classifiers such as Kraken assign each k-mer of a reference database to the lowest common ancestor (LCA) of the genomes containing it, but this works less well as databases grow, because more and more k-mers are shared across species. Cliffy (Ahmed, Boucher and Langmead, 2025) instead uses variable-length exact matches found with an r-index, and can list approximately the genera containing each match; on 16S rRNA it is more accurate than Kraken 2, but its index is large and expensive to build. We present KATKA, which finds the maximal exact matches (MEMs) of at least a given length in each read with Boyer–Moore–Li on a run-length compressed suffix array, counts the occurrences of each MEM in each genus exactly with a complete, run-length compressed tag array, and gives each genus credit in proportion to those counts. On the SILVA 16S rRNA database, KATKA's default index takes 1.44 GB and can be built in minutes on a desktop computer; it classifies a read in 66 μs with one thread and reaches 93.8% genus-level accuracy, close to what Cliffy reports for its 9 GB index. Grammar-compressing the runs of the tag array shrinks the index to 1.04 GB, at 75 μs per read. On the same machine and reads, it is more accurate than Kraken 2 (79.3%) and Tagger (81.7 to 92.8%, depending on how mates that disagree are scored). Indexing minimizer digests instead of the sequences makes the index three times smaller and classification 1.7 times faster, at a cost of 1.3 points of accuracy. KATKA is available at https://github.com/TravisGagie/KATKA.
2012 ACM Subject Classification Theory of computation → Data structures design and analysis; Applied computing → Bioinformatics
Keywords and phrases Taxonomic classification, maximal exact matches, Boyer–Moore–Li, run-length compressed suffix arrays, tag arrays, document listing, minimizer digests, 16S rRNA
Acknowledgements We thank Ben Langmead for encouraging us to classify with MEMs, and Omar Ahmed, Christina Boucher and Ben Langmead for making Cliffy and their experimental scripts publicly available. We thank Victor Alfaro, whose work with the second author on grammar-compressing the differential suffix array prompted us to grammar-compress the runs of the tag array. The ideas in this paper are the authors'; the code, the experiments and the text were developed by Claude Opus 5.5, an AI model by Anthropic, under their direction.
Taxonomic Classification with Complete Tag Arrays
1 Introduction
A sequencing experiment on a microbial sample produces millions of reads: short strings, typically of a few hundred bases, copied from random places in the DNA of whatever organisms the sample contains, and from either strand of that DNA, so a read may match the database only as a reverse complement: reversed, with A and T, and C and G, swapped. Taxonomic classification assigns each read to a node of a taxonomy, such as a species or genus, by comparing it with a reference database of sequences whose taxa are known. Kraken [57] made this fast by precomputing, for every k-mer in the database, the lowest common ancestor (LCA) in the taxonomy of the genomes containing it. To classify a read, Kraken looks up its k-mers and gives each a vote for its stored LCA; the read is assigned to the leaf of the taxonomy whose root-to-leaf path collects the most votes. Kraken 2 [56] stores minimizers instead of all k-mers, in a compact probabilistic hash table, which makes the database about 85% smaller: for a reference of 9.1 Gbp it uses 10.6 GB of memory when classifying, against Kraken's 72.4 GB. Even so, the databases keep growing: the prebuilt Kraken 2 Standard database (RefSeq archaea, bacteria, viruses, plasmids, human and vectors) now takes 103 GB, and the one built from GTDB release 226 takes 644 GB.
Growth also hurts accuracy, because k-mer methods depend on k-mers that are specific to a single taxon, and such k-mers become rarer as databases grow. Nasko et al. [48] showed that as NCBI RefSeq grew, the number of species grew much faster than the number of genera; as a result, more reads were classified with newer versions of the database, but fewer of them at the species level, because more k-mers were shared by several species and their LCAs moved up the taxonomy. Commichaux et al. [19] showed a similar trend for the 16S rRNA gene and other prokaryotic marker genes: species-level resolution is lost as the number of sequences in reference databases grows, and the loss is strongest for the best represented taxa. In work in preparation, Cheng et al. [14] report that using maximal exact matches (MEMs) instead of k-mers gives better classifications than any single choice of k: a MEM is as long as the match allows, so a read from a well represented taxon can still have long matches that are specific to it.
Whatever the matches are, a classifier has to decide what each match votes for. Following Kraken, a match can vote for the LCA of all the taxa containing it. Alternatively, it can vote directly for each of the taxa containing it, splitting its weight among them, either evenly or in proportion to the number of occurrences of the match in each. We call these the LCA and listing approaches; Figure 1 illustrates the difference. Listing avoids giving weight to taxa that do not contain the match, which matters when a match occurs in a few distant taxa.
Cliffy [1], which we describe in Section 2, supports both approaches for variable-length exact matches, and on 16S rRNA it is considerably more accurate than Kraken 2: its authors report genus-level accuracy 11 to 18 percentage points higher, although Kraken 2's index for SILVA takes only 144 MB. Its index, however, is large and expensive to build. In this paper we present KATKA, a classifier built from standard compressed data structures that is about as accurate as Cliffy reports, with an index that is several times smaller and can be built in minutes on a desktop computer; on the same machine and reads, it is also more accurate than Kraken 2 and Tagger. KATKA's design has four parts (Section 3):
It indexes the reference sequences, grouped by genus and with their reverse complements, with a run-length compressed suffix array (RLCSA) [45, 11], together with a table of the search states of all 10-mers.
https://benlangmead.github.io/aws-indexes/k2, accessed October 2026.

LCA (Cliffy): to each of
Figure 1 A match M that occurs in genera and (boxed). The LCA of and is the root, so with Kraken's rule the match votes only for the root. With the leaves in left-to-right order, Cliffy's LCA query spreads the weight evenly over the genera from the leftmost to the rightmost one containing the match, including and , which do not contain it; listing splits the weight between and only, evenly as shown or in proportion to the number of occurrences in each.
It finds only the MEMs of each read that are at least L = 30 bases long, with Boyer–Moore–Li (BML) [28, 43], which skips over parts of the read as Boyer–Moore pattern matching does. Short MEMs occur in many genera, so they say little about where a read came from, and they are the expensive ones to answer for.
It counts the occurrences of each MEM in each genus with a run-length compressed tag array that stores the genus of each suffix of the reference in suffix-array order [5, 25, 26, 50]. Neighbouring suffixes tend to come from the same genus, so the tag array compresses well, and counting needs only the runs that overlap the MEM's interval, rather than locating every occurrence as an r-index would, which on SILVA makes classification about twice as fast; when counts are not needed, Muthukrishnan's document listing algorithm [47] lists the genera in an interval in time proportional to their number.
It gives each genus credit in proportion to the number of occurrences of the MEM in it, which turns out to be about 3.5 points more accurate than splitting the credit evenly. On the SILVA 16S rRNA database, this index takes 1.44 GB, against 9.01 GB for Cliffy's undigested index, classifies a read in 66 s with one thread, and reaches 93.8% genus-level accuracy (Section 4). As an option, KATKA can index minimizer digests [54, 3], as Cliffy can, which makes the index three times smaller and classification 1.7 times faster at a cost of 1.3 points of accuracy (Section 5).
We call our tool KATKA, reusing the name of two earlier projects of ours that share its goals but little of its design. The first KATKA [33] was a Kraken-like index with k given at query time: it found the leftmost and rightmost genomes containing each k-mer with range-minimum queries on grids built from LZ77 parses. The second [24] classified reads by the LCAs of their MEMs, concentrating on each read's longest MEMs, and studied how well this works over minimizer digests and over lossy “KATKA kernels”. The present KATKA differs from both in how it finds matches, in how it answers for them, and in its evaluation, which follows Cliffy's.
The closest work to ours is Tagger [22], which finds the super-maximal exact matches of length at least L of a read with move structures [49] and also uses a tag array of genera, sampled at the ends of BWT runs. Tagger assigns each match a single genus, that of the match's last occurrence in the BWT, which it maintains during the search much as the r-index maintains its toehold (the position of one occurrence of the current match); it is small, and its own evaluation, by a group of authors that includes one of us, found Cliffy's listing of several genera per match more accurate on the same SILVA genera, with different reads.
Taxonomic Classification with Complete Tag Arrays
Tagger reads only one tag of each match's BWT interval, the last one; we use all the tags in the interval, to count the occurrences of a match in each genus. Other classifiers built on r-indexes, such as SPUMONI 2 [3] and col-BWT [12], address a different problem: deciding whether a read comes from a target pangenome, such as a set of human haplotypes, or which of a few such pangenomes it comes from. Col-BWT adds chain statistics, which say whether a read's maximal matches are co-linear in the references, and with them comes within 0.6 percentage points of the sensitivity of alignment with minimap2 on long reads. Co-linearity matters less for our short 16S reads, which usually have only a few long MEMs, but it might help KATKA on longer reads or whole genomes. Alignment-free machine-learning methods based on k-mer frequencies or chaos-game representations classify or cluster whole genomes and metagenome-assembled genomes [53, 46, 44, 4]; we target short reads, for which we expect long exact matches to be more informative than k-mer profiles.
Section 2 gives some background on 16S rRNA classification and on Cliffy, Section 3 describes KATKA and Section 4 evaluates it and compares it with Kraken 2 and Tagger. Section 5 describes digestion, and Section 6 concludes. Appendix A gives the details needed to reproduce our experiments, and Appendix B describes the alternatives we considered and why we did not choose them.
Cliffy. Cliffy [1] indexes the reference sequences, concatenated in the left-to-right order of the leaves of the taxonomy, with an r-index [34]. We call the sequences of each genus a document, so that documents are numbered in tree order. To classify a read, Cliffy searches backward from the end of the read for as long as the match occurs in the database; when it does not, it starts a new backward search at the character where the previous one failed. This cuts the read into consecutive phrases, each the longest string ending at its position that occurs somewhere in the database: the mirror image of the cross parsing of Ziv and Merhav [58], which goes from left to right, taking each time the longest prefix of the rest of the sequence that occurs in the other one. Ziv and Merhav introduced cross parsing to classify a sequence by how few phrases it needs when parsed against the training data of each class, and it has since been used to classify texts [20] and electrocardiograms [21]; Omri et al. [51] recently classified genomic sequences with a related method based on LZ78.
Table 1 Cliffy on the SILVA database (aquatic biome), from [1]: index sizes (their Table 1), classification times with approximate document listing (their Figure 2), and genus-level accuracy (read from their Figure 3; each range is over the four regions). “DNA minimizers” writes each minimizer as its bases instead of one byte; its accuracy lies between the other two rows. The times are for 10 million simulated read pairs; assuming, as in their scripts, that the two mates are classified separately, we also give the time per read. We do not know the number of threads.
| digestion | size (GB) | time per 10 M pairs (s) | time per read (μs) | genus accuracy | |
|---|---|---|---|---|---|
| LCA | listing | ||||
| none | 9.01 | 3 980–4 080 | 199–204 | 87.5–90.2% | 93.3–94.8% |
| DNA minimizers | 7.86 | 3 500–3 850 | 175–193 | - | - |
| minimizers (k = 4, w = 11) | 4.27 | 1 530–1 640 | 77– 82 | 86.3–88.5% | 92.8–93.4% |
For each match, Cliffy needs to know which documents contain it. It stores, at the BWT positions where runs start and end, a document array profile [2]: for each document, the length of the longest common prefix of the suffix at that position with any suffix in that document. These profiles have one entry per document, so Cliffy compresses each one by keeping only its cliffs: the entries that are larger than every entry to their left, or to their right, in the order of the documents. From the cliffs at the end of a match's backward search, Cliffy can find the leftmost and rightmost documents containing the match, and thus their LCA in the taxonomy; it can also report the documents whose cliffs are at least as long as the match, which is a subset of the documents containing it and always includes the leftmost and rightmost ones. Cliffy's LCA query gives weight to each document from to , where is the match and and are the leftmost and rightmost documents containing it (see Figure 1); its approximate document listing gives weight to each document in the list . The LCA query thus does not vote for the LCA itself, as Kraken does, but spreads the weight over the genera from to , all of which lie under the LCA; like Cliffy's authors, we call it the LCA approach, and we do not evaluate Kraken's rule.
Cliffy can also index minimizer digests [54] of the sequences, as SPUMONI 2 does [3]: by default, the minimizers of length selected from windows of bases, each encoded as one byte, which makes the indexed text about 4.5 times shorter. Each read is digested the same way before its matches are found.
Table 1 summarizes Cliffy's results on SILVA, with reads simulated from the genus abundances of an aquatic community. Approximate document listing is consistently more accurate than the LCA query, by about 4.5 to 6.5 percentage points at the genus level, and minimizer digestion costs 0.5 to 1.7 points (comparing the ends of the ranges) while halving the size of the index and cutting the classification time by about . The index is large, however: 4.27 GB with minimizer digestion and 9.01 GB without it, from a database of 1.2 GB. Building it requires writing the uncompressed document array profiles to disk before compressing them, which takes 1.2 to 2.3 TB of temporary disk space for SILVA; the authors' experiments ran on a server with 1.5 TB of RAM. In their supplementary material they show that for whole genomes from GTDB, both the temporary disk space and the index size grow quickly, and they identify reducing them as future work.
Taxonomic Classification with Complete Tag Arrays
3 KATKA
3.1 The index
Let be the documents, that is, the concatenations of the reference sequences of each genus, numbered in the left-to-right order of the leaves of the taxonomy. We index the text , where denotes the reverse complement and separates sequences. Every position of or , and the separator after it, belongs to genus . Since contains both strands, a read matches whichever strand it came from, and extending a match to the right by a base is the same as extending its reverse complement to the left by the complement of ; so backward search alone supports search in both directions.
We store the Burrows–Wheeler transform (BWT) of S as a run-length compressed suffix array (RLCSA) in the form of Brown et al. [11], which supports LF-mapping and backward search directly, rather than Mäkinen et al.'s original [45], which represents : for each character c, the sorted list of the starting positions of the runs of c in the BWT, together with the cumulative lengths of those runs. A backward step by c maps a BWT interval to the interval of the suffixes preceded by c, and with these lists it is a predecessor search in the list of c, whose cost does not depend on the size of the alphabet. We store the lists as plain arrays, which is fast; Elias–Fano coding makes them about three times smaller but classification about four times slower (Appendix B.3).
Every backward search starts from scratch with the whole BWT as its interval, and BML starts many searches (Section 3.2). As Bowtie 2 [40] and Cliffy do, we therefore store the result of the first t steps for every string of length t, so that a search starts with one table lookup; if the string does not occur, we fall back to stepping base by base, so that we still know exactly where a match fails. We use t = 10, for which the table takes 18 MB.
3.2 Finding long MEMs
A MEM of a read with respect to is a substring of that occurs in but cannot be extended to the left or to the right and still occur. Reads have many short MEMs, which occur in many genera, so they say little about where the read came from, and listing the genera containing them is expensive. Boyer–Moore–Li (BML) [28, 43] finds only the MEMs of length at least a given . Starting with , it checks whether a MEM of length at least starts in by searching backward for the window , starting from its right end. If the step that prepends fails, so that does not occur, then no MEM of length at least starts at a position from to , and BML jumps to , skipping the rest of the window as in Boyer–Moore pattern matching. If the whole window occurs, BML extends the match to the left as far as it can, to some position , then to the right (by searching backward for the reverse complement), up to some position ; it reports the MEM and continues with , the first window that ends after the MEM. A window reached by a jump cannot extend to the left, since the extension would contain the string that just failed; only the first window after a MEM can. Figure 2 shows an example. The DLT paper [28] gives the theory, and its full version [29] gives a practical algorithm, which Li implemented in ropebwt3 [43]. At the end of the forward extension, we have the BWT interval of the MEM's reverse complement, whose occurrences are in the same genera as the MEM's.
We use L = 30 by default. Accuracy hardly changes for L between 15 and 30, and drops slowly after that, as more reads have fewer long MEMs, while classification becomes faster.
(1)
does not occur: jump to
(2)
MEM ,
(3)
MEM
R
0
10
20
30
40
50
Figure 2 Boyer–Moore–Li with L = 12 on a read R, where denotes a MEM. (1) The search for the window proceeds backward from its right end and fails at the step that prepends , so no MEM of length at least L starts at positions 0 to 4, and BML jumps to x = 5. (2) The window occurs; it cannot be extended to the left, since contains , so BML extends it to the right and reports the MEM . (3) Any later MEM of length at least L must end after position 28, so the next window is ; it occurs, and BML extends it in both directions, to the MEM , and continues with x = 30. With the lookup table, each window's search starts with one lookup of its last t bases.
as L grows (Section 4).
3.3 Listing genera with a tag array
A tag array associates a tag with each position of the BWT [5, 25, 26, 50], and Wheeler maps [5] bound its space in terms of the number of runs in the tags; here the tag of a BWT position is the genus of the corresponding suffix of S. Our use lies between the traditional use of document arrays and more flexible uses of tag arrays: if a document is the concatenation of the sequences of one genus, rather than a single genome as usual, then our tag array is the document array of Muthukrishnan [47], whereas the tags of Eskandar et al. [25, 26], which are vertices of a pangenome graph, and those of Olbrich and Ohlebusch [50], which are columns of a multiple alignment, cannot be seen as documents at all. Neighbouring positions of the BWT often come from the same genus, so we run-length compress the tag array. Tagger [22] stores only the tags at the ends of BWT runs, from which the tags of other positions cannot in general be recovered; to stress the difference, we call a tag array complete if it gives the tag of every BWT position, whether it stores them run-length compressed or recovers them from a sample. A complete tag array tells us the genus of every occurrence of a match, and so lets us count the occurrences in each genus. To list the distinct genera in a BWT interval, we use Muthukrishnan's document listing algorithm [47] on the runs: with a range-minimum structure [27] over the array C in which C[i] is the previous run with the same genus as run i, the runs with C[i] before the interval are exactly the first runs of each genus in it, and recursion on range minima reports them in time proportional to the number of genera. As in Sadakane's method [55], and as Olbrich and Ohlebusch do [50], we need not store C: if the run at a range minimum belongs to a genus we have already reported, the recursion can stop, provided we recurse on the left before the right. We thus store only the run starts (Elias-Fano), the genus of each run, and the range-minimum structure. Figure 3 shows an example.
Proportional credit (Section 3.4) needs more than the list of genera: it needs the number of occurrences of the MEM in each. To count them, we scan the runs that overlap the MEM's BWT interval and add up the lengths of the runs of each genus, clipped to the interval. This takes time proportional to the number of runs in the interval rather than to the number of genera, but MEMs of at least 30 bases have few runs in their intervals, and counting was as
Taxonomic Classification with Complete Tag Arrays

left-first recursion on range minima of C: runs 3, 2, 6, 4 reported; stops at runs 5 and 7
Figure 3 Document listing on a run-length compressed tag array. Each box is a run of BWT positions with the same genus, and the arrows show C, which points from each run to the previous run with the same genus (runs 0, 1, 3 and 6 have none, C = -1). To list the genera in the BWT interval covering runs 2 to 8, we find the run with the minimum C in the interval, report and mark its genus, and recurse on the parts to its left and right. The runs with C before the interval (shaded) are exactly the first runs of each genus in it; we do not store C, but stop a recursion as soon as its minimum is a run whose genus is already marked, which, since we recurse on the left part first, happens exactly when that minimum is not before the interval [55, 50].
fast as listing in our experiments. The default configuration therefore counts and does not use document listing, which we use for equal credit and for the LCA approach.
The obvious alternative is to locate every occurrence with an r-index [34]: the toehold gives the suffix-array entry at one end of the MEM's BWT interval, queries give the others, and a predecessor search over the genus starts maps each occurrence to its genus. This also gives exact counts, but costs a query, with its cache misses, for every occurrence, whereas the tag array costs time per run. On SILVA the difference is large, because genera contain many near-identical sequences: a MEM of at least 30 bases in one of our reads occurs 70 times on average (in 3.8 genera); half of them occur only once, but 5% occur more than 200 times, but these occurrences are clustered in the BWT, so they form few runs of tags. With an explicit RLCSA and a lookup table, classifying with an r-index takes 125 s per read, against 66 s with the tag array, for an index only 0.06 GB smaller (Table 3); subsampling the r-index [15, 16] makes it smaller but slower still. On SILVA the tag array has 359 million runs, 5.3 times as many as the BWT, and takes 0.86 GB (19.1 bits per run); the range-minimum structure for listing takes another 0.11 GB, but counting does not need it, so we store it in a separate file and build and load it only for listing. The tag array needs no suffix-array samples at all, and neither listing nor counting ever locates an occurrence.
Grammar-compressing the runs. Run-length compression is what makes the tag array small enough, and it is all the default configuration uses; the runs can optionally be compressed further. LF maps the rows i..j of a BWT run to consecutive rows LF(i)..LF(j), whose suffixes are one character longer, so the tags of rows LF(i)..LF(j) are a copy of those of rows i..j, except at the rows whose suffix starts a genus. The run-length compressed tag array is therefore made of copies of its own substrings, at most one per BWT run plus one per genus, much as the differential suffix array is, which is what makes the latter grammar-compressible [35, 34]. Cobas and Navarro [18] used this to grammar-compress the document array, which is a complete tag array of documents without run-length compression, storing the list of documents in the expansion of each nonterminal, and Cobas, Mäkinen and Rossi [17] extended their index to report the frequency of each document too, for metagenomic read assignment; we run-length compress first and grammar-compress only the genera of the runs, so the grammar is over the 359 million runs rather than over the 1.17 billion positions of the BWT. Counting needs only the genera of consecutive runs, since the runs' extents come from the run starts, so we compress only the sequence of the runs' genera. On SILVA its 359 million genera have an LZ77 parse of 42.3 million phrases, and RePair [41], in the second author's implementation distributed with BigRePair [31], which avoids deep rules, gives a grammar with 19.0 million rules, a final sequence of 38.4 million symbols and height 46, in 4.5 minutes and 8.9 GB of memory. (BigRePair itself, which applies RePair to the dictionary and the parse of a prefix-free parse instead of to the whole sequence, needs less memory but gives 57.1 million rules and, encoded as below, a grammar 31% larger and slightly slower to decode.) We encode the grammar as Gagie et al. do [32], naming each symbol by the length of its expansion and its rank among the symbols with that length, so that expansion lengths need not be stored; in addition, we sort the rules with each length by the length of their left child, which is then stored only once for each group of rules. To count, we find the first run of the interval by a predecessor search on the cumulative lengths of the final sequence, descend through the grammar, and decode the following runs with a stack. The runs' genera then take 0.23 GB instead of 0.63 GB (0.09 GB for the rules and 0.14 GB for the final sequence), and the default index 1.04 GB instead of 1.44 GB; classification takes 75.0 s per read instead of 66.0, with identical answers, and this configuration is on the Pareto surface (Table 7).
3.4 Classifying a read pair
Each MEM M found in either mate gives each genus g containing it a weight , where is the number of occurrences of M in genus g, counting both strands; the read pair is assigned to the genus with the largest total weight. We call this proportional credit, as opposed to equal credit, in which each of the genera containing M gets weight , where D is the set of those genera, as in Cliffy's approximate listing. Proportional credit favours the genera in which a match occurs most often, as Tagger's single tag does implicitly, since the last occurrence of a match in its BWT interval is more likely to be in a genus with many occurrences; on our data it is about 3.5 points more accurate than equal credit. Part of this gain may come from a prior that suits our simulated reads, since proportional credit also favours genera that have many sequences in SILVA; normalizing each count by the size of its genus is about 1 point less accurate than proportional credit, and 2.5 points more accurate than equal credit (Appendix B.2).
4 Experiments
Setup. We reproduced Cliffy’s SILVA experiment as closely as we could from the authors’ scripts. We used SILVA 138.1 SSU NR99 [52] (small-subunit rRNA sequences, made non-redundant at 99% identity), grouped its sequences by genus with their script, and kept 9118 genera containing 402378 sequences, in the left-to-right order of the leaves of the SILVA taxonomy. The text S has n = 1.17 billion characters and its BWT has r = 68.3 million runs. We simulated reads with MicrobeMixer, the authors’ simulator (10 million pairs of 250-base reads per hypervariable region, from the aquatic biome), using ART [36]. Their scripts do not fix random seeds, so our reads are not theirs. We used the four regions in Cliffy’s experiments, V1–V2, V3–V4, V4 and V4–V5, and measured accuracy on every 50th read pair (200 000 pairs per region), which we have made available with our code.
Following Cliffy’s scripts, we classified each mate separately, combined the weights of the two mates, and scored the classification at the genus level: a read pair is correct if its true genus has the largest total weight. Their scoring also counts a read pair as correct if its true genus is tied for the largest weight, or if no match votes at all and its true genus is not “uncultured”. We report both their accuracy and a strict accuracy, in which ties and unclassified read pairs count as wrong; we consider the strict accuracy the more meaningful one. As in Cliffy’s scripts, read pairs whose true genus is missing or ambiguous in the truth
Taxonomic Classification with Complete Tag Arrays
file would count as correct under both measures, but at the genus level there are none among our reads. We report the mean accuracy over the four regions.
We measured time on 2000 reads per region with one thread, including digesting the read when needed, finding its matches and answering for them, but not loading the index, and report the mean over the four regions. We ran everything on a seven-year-old desktop computer (an Intel Core i7-8700 with 6 cores and 16 GB of RAM), on which we could not build Cliffy's indexes. Therefore, all the numbers we give for Cliffy are from its paper, obtained on a server (an Intel Xeon Gold 6248R with 1.5 TB of RAM) with a different set of simulated reads, and comparisons should be read with this in mind. Appendix A gives the details.
The default configuration. KATKA's default index takes 1.44 GB: 0.57 GB for the RLCSA, 0.86 GB for the tag array and 18 MB for the lookup table. Building it from the sequences takes minutes: on our desktop, 347 s for the BWT, with prefix-free parsing [9] (peak memory 5.1 GB), a few seconds for the RLCSA and the lookup table, and about 2 minutes for the tag array, which needs a suffix sort of S. On a 2023 laptop, our quick demo built everything, from SILVA's FASTA file to the index, in under 15 minutes, including structures the default configuration does not use. With one thread, it classifies a read in 66 s, excluding loading the index and reading the reads; Cliffy's paper reports the total time to classify 10 million read pairs, with an unknown number of threads and including reading the reads, which comes to 199 to 204 s per read on its server (Table 1), so the two are not directly comparable. KATKA's strict accuracy is 93.77% on average, and 92.67 to 95.29% over the four regions (93.79% on average with Cliffy's scoring), against the 93.3 to 94.8% over the four regions that Cliffy reports for approximate listing with its own scoring on its own reads. Ties almost never occur with proportional credit, so the two measures nearly coincide. Reads are classified independently, so classification parallelizes easily: with 12 threads on our 6 cores, sharing one copy of the index, KATKA classified 144 800 reads per second, 7.7 times as many as with one thread (on 200 000 read pairs per region). On the laptop (an Intel Core i5-1335U, with 2 performance and 8 efficiency cores), the same configuration classified a read in 46 s with one thread on a performance core, and 83 900 reads per second with 12 threads (on 5 000 read pairs per region, so this underestimates its throughput).
Kraken 2 and Tagger. Table 2 compares KATKA with Kraken 2 [56] and Tagger [22], run on our desktop, with accuracy measured on 5 000 of our read pairs per region and speed on 200 000 (Appendix A gives the details). Kraken 2 is by far the smallest and the fastest, with one thread or with 12, but it assigns only 79.3% of the pairs to their true genus (84.3% to their true genus or one of its ancestors below the domain). We ran Tagger with its defaults (L = 25, against our 30). It gives each mate a single genus, so its accuracy on pairs depends on how we resolve mates that disagree: 81.7% if such pairs count as wrong, 87.2% if the disagreement is broken at random and 92.8% if they count as correct. KATKA is more accurate than either: by almost a point even when Tagger is credited with every disagreement, and by 6 to 12 points otherwise; it is also faster than Tagger, with one thread or with 12.
The effect of each choice. Table 3 shows what happens when we change one part of the default configuration at a time. Accuracy hardly changes for L from 15 to 30 and drops slowly after that, while each increase in L makes classification faster, because BML skips more of each read and finds fewer MEMs; L = 30 is the largest threshold with the best accuracy. Equal credit is 3.2 to 3.6 points less accurate than proportional credit, for both
Table 2 KATKA's default configuration, Kraken 2 and Tagger on our desktop: index size; time per read with one thread and reads per second with 12 threads, both excluding loading and measured on 200 000 read pairs per region; and genus-level accuracy on 5 000 read pairs per region (mean over the four regions). KATKA's accuracy is strict (93.77% on all 200 000 pairs per region); its time per read here is its total classification time divided by the number of reads, which is lower than the 66.0 s we measure per read elsewhere; for Kraken 2, a pair is correct only if it is assigned to its true genus; for Tagger, a pair whose mates are assigned different genera is counted as wrong, broken at random, or counted as correct.
| classifier | space (GB) | time (s) | reads/s, 12 threads | accuracy |
|---|---|---|---|---|
| KATKA | 1.44 | 53.1 | 144 800 | 93.70% |
| Kraken 2 | 0.15 | 14.3 | 366 900 | 79.26% |
| Tagger | 0.82 | 70.4 | 82 600 | 81.69 / 87.24 / 92.78% |
Table 3 The default configuration, and what changes when one part of it is changed (strict and Cliffy's genus-level accuracy, mean over the four regions; time per read with one thread; a blank entry is the same as for the default). The sampled tag arrays and the sr-indexes use the lookup table; the sr-index with uses an RLBWT instead of an RLCSA; equal credit lists genera, so it also needs the tag array's range-minimum structure. Cliffy's numbers are from its paper, on another machine and other reads, with an unknown number of threads (Table 1).
| configuration | space (GB) | time (s) | strict | theirs |
|---|---|---|---|---|
| default (Section 3) | 1.44 | 66.0 | 93.77% | 93.79% |
| 88.6 | 93.74% | 93.75% | ||
| 79.2 | 93.77% | 93.78% | ||
| 57.3 | 93.48% | 93.53% | ||
| equal credit | 1.55 | 90.28% | 91.83% | |
| no lookup table | 1.42 | 94.6 | ||
| lookup table with | 1.71 | 62.9 | ||
| Elias-Fano RLCSA | 1.06 | 257.3 | ||
| tags sampled with | 1.17 | 100.3 | ||
| grammar-compressed runs | 1.04 | 75.0 | ||
| sr-index, (no subsampling) | 1.38 | 124.7 | ||
| sr-index, , RLBWT | 0.46 | 315.1 | ||
| Cliffy [1], undigested, approx. listing | 9.01 | 199–204 | 93.3–94.8% |
and and with or without digestion (Appendix B.2). The lookup table saves 30% of the time for 18 MB; a table of 12-mers saves another 5% for 0.27 GB more. Of the other ways to list or count, subsampled r-indexes (sr-indexes) [15, 16], which locate every occurrence, can be smaller (0.41 GB without a lookup table, with sampling parameter and the BWT stored as a run-length compressed BWT, or RLBWT) but are 2 to 7 times slower; tag arrays in which only some runs store their genus, the others recovering it by LF-mapping, are smaller but slower too, and grammar-compressing the runs (Section 3.3) gives indexes that are both smaller and faster than those. Appendix B.3 describes these alternatives and gives the full time-space-accuracy Pareto surface of our configurations, on which the default configuration lies.
Taxonomic Classification with Complete Tag Arrays
Table 4 Classification over minimizer digests (, ), with tags and proportional credit, against the default configuration and Cliffy's digested index. All use a lookup table ( digest symbols with digestion, bases without).
| configuration | space (GB) | time per read () | ||||
|---|---|---|---|---|---|---|
| digests: strict accuracy | 92.47% | 92.47% | 92.48% | 92.36% | 92.05% | |
| explicit RLCSA, tags | 0.49 | 56.6 | 54.7 | 39.3 | 32.7 | 25.2 |
| Elias-Fano RLCSA, tags | 0.27 | 79.0 | 76.6 | 61.9 | 50.7 | 44.4 |
| RLBWT, tags sampled with | 0.19 | 220.1 | 147.0 | 114.3 | ||
| undigested: strict accuracy | 93.74% | 93.77% | 93.77% | 93.48% | ||
| default configuration | 1.44 | 88.6 | 79.2 | 66.0 | 57.3 | |
| Cliffy [1], digests, approximate listing: 92.8–93.4% with their scoring and reads | ||||||
| 4.27 | 77–82 | |||||
5 Minimizer digests
Like Cliffy, KATKA can index minimizer digests of the sequences instead of the sequences themselves. We digest each sequence and its reverse complement as Cliffy does, with and , but symmetrically, so that the digest of a reverse complement is the reverse complement of the digest: we use a canonical hash, select all minimizers tied for the minimum in a window, and collapse equal consecutive minimizers. Since 4 byte values are reserved for terminators and the separator, the 256 distinct minimizers fit in a byte only once the 6 rarest share one. The digested text has 262 million symbols and its BWT has 35.9 million runs. To classify a read, we digest it the same way, keeping only the minimizers selected by windows lying entirely inside each match; since a window inside a match in the read is also a window inside the corresponding occurrence in the database, and selects the same minimizers there, the digest of every DNA match occurs in the digested database.
We keep the threshold in bases rather than in digest symbols, since consecutive digest symbols can stand for very different numbers of bases. A window of the read covers bases and selects a range of digest symbols, and these ranges move monotonically to the right as the window does. A DNA match contains exactly the windows starting in , so its digest is the range of symbols they select. BML searches backward for this range of symbols; if the search fails at symbol , then every window start whose first window selects a symbol no later than also fails, and we jump to the first window that selects only symbols after . If the search succeeds, we extend the match to a maximal digested MEM and compute its span in bases: the longest DNA interval of the read all of whose windows select symbols within the MEM. This finds every digested MEM whose span is at least bases and is not contained in another digested MEM's span; we checked this against brute-force enumeration on 3000 reads for every from 15 to 50. The weight of a MEM is the length of its span.
Table 4 shows that digestion makes the index three times smaller (0.49 instead of 1.44 GB with an explicit RLCSA and tags) and classification 1.7 times faster with (39.3 instead of ), at a cost of 1.3 points of accuracy (92.48 instead of ). The digested tag array has 81.0 million runs, 2.26 times as many as the BWT, and takes 0.19 GB (18.3 bits per run), plus 0.03 GB for the range-minimum structure if listing. Over digests, an Elias–Fano RLCSA is only 1.6 times slower than an explicit one, so it gives a 0.27 GB index that is still faster than the undigested default, and sampled tag arrays on the RLBWT give the smallest indexes we built, 0.16 to 0.19 GB. Once the sequences are digested, building the index with an explicit RLCSA takes about 3 minutes: 132 s for the BWT (peak memory 2.0 GB), a few seconds for the RLCSA, and 35 s for the tags. Cliffy's digested index is almost 9 times larger and, on its server, about twice as slow per read; it reports 92.8 to 93.4% accuracy with its own scoring on its own reads, against our 92.5% on ours.
6 Conclusions
Long MEMs found by BML on an RLCSA, a complete, run-length compressed tag array that lists the genera containing each MEM and counts its occurrences in them, and credit in proportion to those counts, give a taxonomic classifier for 16S rRNA that is about as accurate as Cliffy reports, with an index several times smaller that can be built in minutes on a desktop computer. Indexing minimizer digests trades 1.3 points of accuracy for an index three times smaller and faster classification.
On the same machine and reads, KATKA (93.7% on those reads) is more accurate than Kraken 2 (79.3%) and Tagger (at most 92.8%), and faster than Tagger; the most important next step is to compare it with Cliffy in the same way, which requires a machine on which Cliffy's index can be built; our repository includes scripts for doing so. We would also like to test KATKA on reads drawn independently of how well each genus is represented in the database (Appendix B.2), on whole genomes, such as the GTDB collections, and on reads from species absent from the database, where reads have fewer long matches and the trade-offs may change. Two-level parse indexes might give us the speed of digests with the accuracy of undigested matches, and suffixient sets might find MEMs faster still (Appendix B.9). Run-length compression makes the tag array practical, and grammar-compressing its runs on top makes the default index another 28% smaller for 14% more time (Section 3.3); bounding the size of such grammars in terms of the number of BWT runs and genera, encoding them more compactly, and storing the genus counts of each nonterminal, so that counting can skip whole subtrees, as Cobas, Mäkinen and Rossi do with document frequencies [17], are natural next steps. We have not tuned our code at the systems level, beyond classifying reads in parallel; interleaving searches with prefetching, huge pages and memory-mapped indexes should make it faster (Appendix A). Finally, the LCA is natural for a tree but can be misled by lateral gene transfer, and we would like to generalize our approach to phylogenetic networks.
References
1 O. Ahmed, C. Boucher, and B. Langmead. Robust 16S rRNA classification based on a compressed LCA index. Genome Research, 35:2650–2660, 2025.
2 O. Ahmed, M. Rossi, C. Boucher, and B. Langmead. Efficient taxa identification using a pangenome index. Genome Research, 33:1069–1077, 2023.
3 O. Ahmed, M. Rossi, T. Gagie, C. Boucher, and B. Langmead. SPUMONI 2: improved classification using a pangenome index of minimizer digests. Genome Biology, 24:122, 2023.
4 F. Alipour, C. Holmes, Y. Y. Lu, K. A. Hill, and L. Kari. Leveraging machine learning for taxonomic classification of emerging astroviruses. Frontiers in Molecular Biosciences, 10:1305506, 2024.
5 A. Balázs, T. Gagie, A. Goga, S. Heumos, G. Navarro, A. Petescia, and J. Sirén. Wheeler maps. In Proc. LATIN, 2024.
6 R. Becker, D. Cenzato, T. Gagie, R. Groot Koerkamp, S.-H. Kim, G. Manzini, and N. Prezza. Compressing suffix trees by path decompositions. In Proc. ICALP, LIPIcs, pages 24:1–24:25, 2026.
Taxonomic Classification with Complete Tag Arrays
7 D. Belazzougui, F. Cunial, T. Gagie, N. Prezza, and M. Raffinot. Composite repetition-aware data structures. In Proc. CPM, pages 26–39, 2015.
8 D. Belazzougui, F. Cunial, T. Gagie, N. Prezza, and M. Raffinot. Flexible indexing of repetitive collections. In Proc. CiE, 2017.
9 C. Boucher, T. Gagie, A. Kuhnle, B. Langmead, G. Manzini, and T. Mun. Prefix-free parsing for building big BWTs. Algorithms for Molecular Biology, 14:13, 2019.
10 N. K. Brown, L. Depuydt, M. Zakeri, A. Alhadi, N. Allam, D. Begleiter, N. B. Kabilan, Karpagavalli, S. S. Khajjayam, H. Wahed, T. Gagie, and B. Langmead. KeBaB: k-mer based breaking for finding long MEMs. In Proc. SPIRE, LNCS 16073, pages 10–17, 2025.
11 N. K. Brown, T. Gagie, G. Manzini, G. Navarro, and M. Sciortino. Faster run-length compressed suffix arrays. In From Strings to Graphs, and Back Again: A Festschrift for Roberto Grossi's 60th Birthday, OASIcs 132, pages 10:1–10:15, 2025.
12 N. K. Brown, V. S. Shivakumar, and B. Langmead. Col-BWT: pangenomic seed chaining with maximal matches improves read classification. Journal of Computational Biology, 33(1):168–183, 2026.
13 D. Cenzato, L. Depuydt, T. Gagie, S.-H. Kim, G. Manzini, F. Olivares, and N. Prezza. Suffixient arrays: a new efficient suffix array compression technique. Theory of Computing Systems, 70:50, 2026.
14 M. Cheng, O. Ahmed, A. Liebhoff, and B. Langmead. Factors affecting k-mer specificity and alternative approaches for metagenomic classification. In preparation.
15 D. Cobas, T. Gagie, and G. Navarro. A fast and small subsampled r-index. In Proc. CPM, LIPIcs 191, pages 13:1–13:16, 2021.
16 D. Cobas, T. Gagie, and G. Navarro. Fast and small subsampled r-indexes. ACM Transactions on Algorithms, 22(1):7, 2025.
17 D. Cobas, V. Mäkinen, and M. Rossi. Tailoring r-index for document listing towards metagenomics applications. In Proc. SPIRE, LNCS 12303, pages 291–306, 2020.
18 D. Cobas and G. Navarro. Fast, small, and simple document listing on repetitive text collections. In Proc. SPIRE, LNCS 11811, pages 482–498, 2019.
19 S. Commichaux, T. Luan, H. S. Muralidharan, and M. Pop. Database size positively correlates with the loss of species-level taxonomic resolution for the 16S rRNA and other prokaryotic marker genes. PLoS Computational Biology, 20(8):e1012343, 2024.
20 D. P. Coutinho and M. A. T. Figueiredo. Information theoretic text classification using the Ziv–Merhav method. In Proc. IbPRIA, LNCS 3523, pages 355–362, 2005.
21 D. P. Coutinho, A. L. N. Fred, and M. A. T. Figueiredo. One-lead ECG-based personal identification using Ziv–Merhav cross parsing. In Proc. ICPR, pages 3858–3861, 2010.
22 L. Depuydt, O. Y. Ahmed, J. Fostier, B. Langmead, and T. Gagie. Run-length compressed metagenomic read classification with SMEM-finding and tagging. iScience, 28:114029, 2025.
23 L. Depuydt, T. Gagie, B. Langmead, G. Manzini, and N. Prezza. Suffixient sets. arXiv:2312.01359, 2023.
24 D. Draesslerová, O. Ahmed, T. Gagie, J. Holub, B. Langmead, G. Manzini, and G. Navarro. Taxonomic classification with maximal exact matches in KATKA kernels and minimizer digests. In Proc. SEA, LIPIcs 301, pages 10:1–10:13, 2024.
25 P. Eskandar, B. Paten, and J. Sirén. Lossless pangenome indexing using tag arrays. In Proc. WABI, LIPIcs, pages 8:1–8:20, 2025.
26 P. Eskandar, B. Paten, and J. Sirén. Lossless pangenome indexing using tag arrays. Algorithms for Molecular Biology, 21:12, 2026.
27 J. Fischer and V. Heun. Space-efficient preprocessing schemes for range minimum queries on static arrays. SIAM Journal on Computing, 40(2):465–492, 2011.
28 T. Gagie. How to find long maximal exact matches and ignore short ones. In Proc. DLT, 2024.
29 T. Gagie. How to find long maximal exact matches and ignore short ones. arXiv:2403.02008v4, 2024.
30 T. Gagie. Parse indexing for discarding short pseudo-MEMs safely. arXiv:2605.17574, 2026.
31 T. Gagie, T. I, G. Manzini, G. Navarro, H. Sakamoto, and Y. Takabatake. Rpair: Rescaling RePair with rsync. In Proc. SPIRE, LNCS 11811, pages 35–44, 2019.
32 T. Gagie, T. I, G. Manzini, G. Navarro, H. Sakamoto, L. Seelbach Benkner, and Y. Takabatake. Practical random access to SLP-compressed texts. In Proc. SPIRE, LNCS 12303, pages 221–231, 2020.
33 T. Gagie, S. Kashgouli, and B. Langmead. KATKA: A KRAKEN-like tool with k given at query time. In Proc. SPIRE, LNCS 13617, pages 191–197, 2022.
34 T. Gagie, G. Navarro, and N. Prezza. Fully functional suffix trees and optimal text searching in BWT-runs bounded space. Journal of the ACM, 67(1):2, 2020.
35 R. González and G. Navarro. Compressed text indexes with fast locate. In Proc. CPM, LNCS 4580, pages 216–227, 2007.
36 W. Huang, L. Li, J. R. Myers, and G. T. Marth. ART: a next-generation sequencing read simulator. Bioinformatics, 28(4):593–594, 2012.
37 A. Hong, M. Oliva, D. Köppl, H. Bannai, C. Boucher, and T. Gagie. Pfp-fm: an accelerated FM-index. Algorithms for Molecular Biology, 19:15, 2024.
38 J. S. Johnson, D. J. Spakowicz, B.-Y. Hong, L. M. Petersen, P. Demkowicz, L. Chen, S. R. Leopold, B. M. Hanson, H. O. Agresta, M. Gerstein, E. Sodergren, and G. M. Weinstock. Evaluation of 16S rRNA gene sequencing for species and strain-level microbiome analysis. Nature Communications, 10:5029, 2019.
39 S. Kuruppu, S. J. Puglisi, and J. Zobel. Relative Lempel–Ziv compression of genomes for large-scale storage and retrieval. In Proc. SPIRE, pages 201–206, 2010.
40 B. Langmead and S. L. Salzberg. Fast gapped-read alignment with Bowtie 2. Nature Methods, 9(4):357–359, 2012.
41 N. J. Larsson and A. Moffat. Off-line dictionary-based compression. Proceedings of the IEEE, 88(11):1722–1732, 2000.
42 H. Li. Exploring single-sample SNP and INDEL calling with whole-genome de novo assembly. Bioinformatics, 28(14):1838–1844, 2012.
43 H. Li. BWT construction and search at the terabase scale. Bioinformatics, 40(12):btae717, 2024.
44 W. Li, L. Kari, Y. Yu, and L. A. Hug. MT-MAG: Accurate and interpretable machine learning for complete or partial taxonomic assignments of metagenome-assembled genomes. PLoS ONE, 18(8):e0283536, 2023.
45 V. Mäkinen, G. Navarro, J. Sirén, and N. Välimäki. Storage and retrieval of highly repetitive sequence collections. Journal of Computational Biology, 17(3):281–308, 2010.
46 P. Millán Arias, F. Alipour, K. A. Hill, and L. Kari. DeLUCS: Deep learning for unsupervised clustering of DNA sequences. PLoS ONE, 17(1):e0261531, 2022.
47 S. Muthukrishnan. Efficient algorithms for document retrieval problems. In Proc. SODA, pages 657–666, 2002.
48 D. J. Nasko, S. Koren, A. M. Phillippy, and T. J. Treangen. RefSeq database growth influences the accuracy of k-mer-based lowest common ancestor species identification. Genome Biology, 19:165, 2018.
49 T. Nishimoto and Y. Tabei. Optimal-time queries on BWT-runs compressed indexes. In Proc. ICALP, LIPIcs 198, pages 101:1–101:15, 2021.
50 J. Olbrich and E. Ohlebusch. The TAG array of a multiple sequence alignment. In Proc. CPM, LIPIcs, pages 29:1–29:14, 2026.
51 Y. Omri, N. Sagan, E. Min, H. Choi, T. Moon, and T. Weissman. Genomic data classification via universal compression. Preprint, Research Square, https://doi.org/10.21203/rs.3.rs-6363017/v2, 2026.
52 C. Quast, E. Pruesse, P. Yilmaz, et al. The SILVA ribosomal RNA gene database project: improved data processing and web-based tools. Nucleic Acids Research, 41(D1):D590–D596, 2013.
Taxonomic Classification with Complete Tag Arrays
53 G. S. Randhawa, M. P. M. Soltysiak, H. El Roz, C. P. E. de Souza, K. A. Hill, and L. Kari. Machine learning using intrinsic genomic signatures for rapid classification of novel pathogens: COVID-19 case study. PLoS ONE, 15(4):e0232391, 2020.
54 M. Roberts, W. Hayes, B. R. Hunt, S. M. Mount, and J. A. Yorke. Reducing storage requirements for biological sequence comparison. Bioinformatics, 20(18):3363–3369, 2004.
55 K. Sadakane. Succinct data structures for flexible text retrieval systems. Journal of Discrete Algorithms, 5(1):12–22, 2007.
56 D. E. Wood, J. Lu, and B. Langmead. Improved metagenomic analysis with Kraken 2. Genome Biology, 20:257, 2019.
57 D. E. Wood and S. L. Salzberg. Kraken: ultrafast metagenomic sequence classification using exact alignments. Genome Biology, 15:R46, 2014.
58 J. Ziv and N. Merhav. A measure of relative entropy between individual sequences with application to universal classification. IEEE Transactions on Information Theory, 39(4):1270–1279, 1993.
A Implementation and experimental details
This appendix lists what we believe is needed to reproduce our results; all parameters not mentioned are defaults. Our code is available at https://github.com/TravisGagie/KATKA.
Software and data. Cliffy's experiment scripts (https://github.com/oma219/cliffy-experiments, commit 566f647), its read simulator MicrobeMixer (https://github.com/oma219/MicrobeMixer, 6409f5d) with ART 2.5.8 [36] and seqtk 1.4; Big-BWT (https://github.com/alshai/Big-BWT, 5b00650); sdsl-lite (c32874c) with libdiv-sufsort. Our own C++17 code was compiled with g++ 15.2 and -03 -march=native -DNDEBUG; the scoring scripts use Python 3.14. The reference is SILVA 138.1 SSU Ref NR99 (SILVA_138.1_SSURef_NR99_tax_silva.fasta, with tax_slv_ssu_138.1.txt and .tre). All times were measured with one thread on an Intel Core i7-8700 (3.2 GHz, 6 cores) with 16 GB of RAM under Linux.
Running the code. From the root of the repository, demo_quick.sh fetches and builds the dependencies at the commits above, downloads SILVA, builds the reference and the default index (silva/build_katka.sh), and classifies 5000 read pairs per region that are included in the repository, with one thread and with all cores. demo_full.sh builds every index in this paper (ALL=1 silva/build_katka.sh), downloads the read pairs we used (every 50th pair of our simulation, 200000 per region, from a release of the repository) and runs every experiment, each with its own script in silva/; pareto_ft.py computes the Pareto surface. To classify reads with the default configuration and 8 threads, the command is RZ_COUNTS=1 rz-classify -j 8 -L 30 -l -C bac.csa -T bac.s1.tag -F 10 bac.rz reads.fq out.listings; with a digested index, add -B bac.map and use -F 2. The output has Cliffy's listing format, extended with the number of occurrences in each genus, so our rz_score2.py, or Cliffy's scripts without the counts, can score it. Finally, silva/run_cliffy.sh and silva/run_katka.sh run Cliffy and KATKA on the same reads on one machine, first with one thread each and then with the same number of threads each, check that the parallel outputs equal the single-thread ones, and score both.
Reference text. We converted the FASTA to one line per sequence (seqtk seq -U) and ran Cliffy's write_silva_genera.py with the tree and rank files and -n 10000, which writes one file per genus, numbered in the left-to-right order of the SILVA tree (9118 files), and doc_to_traversal.txt; as in Cliffy's pipeline, each file is reverse-complemented with seqtk seq -r, which also turns U into T. We call genus i document i. In the text S of Section 3.1, is the concatenation of the sequences of genus i separated by X, and any character other than A, C, G, T (in either case) becomes X. A text position is mapped to its document by a predecessor search over the document starts. For Cliffy's scoring script we also need trav_to_length.txt, which gives for each genus its traversal string and the total length of its sequences.
Reads. For each of V1–V2, V3–V4, V4 and V4–V5 we ran the simulate command of MicrobeMixer's sim_16s_reads.py with the region's primer file, the SILVA FASTA and taxonomy, 10 million reads, and the aquatic abundance profile shipped with MicrobeMixer (data/aquatic.tsv, in which we replaced Candidatus_by Candidatus followed by a space, to match SILVA 138.1); this gives 10 million pairs of 250-base reads and a truth file *_seqtax.txt per region. The read files are grouped by genus, so we subsample regularly: for accuracy, pairs 0, 50, 100, ... (200 000 pairs per region); for time, mate-1 reads 0, 5000, 10000, ... (2 000 reads per region), which are among the former. Each mate is classified on its own, as given (both strands are in the index).
Lookup tables. For each string of length t over the alphabet (A, C, G, T, or the digest bytes) the table stores the BWT interval after searching for it, and for the sr-index also the toehold; it is built when the classifier starts (-F t; under a second). A search for a string of length at least t starts with a lookup of its last t symbols; if they do not occur, the search proceeds symbol by symbol from scratch, so that BML learns exactly where it fails. Every configuration gives the same answers with and without a table.
Digests. Number A, C, G, T as 0–3 and let a k-mer's code be its 2k-bit integer. Its hash is the splitmix64 finalizer applied to the smaller of its code and its reverse complement's code. In each maximal A/C/G/T run, every window of w consecutive bases consecutive k-mers) selects all its k-mers of minimum hash; the selected k-mers, in text order and in their own orientation, form the digest of the run, after collapsing equal consecutive symbols. Digests of consecutive runs are joined by X. With and , every one of the 256 codes occurs; only 252 bytes are free (0–2 are reserved for terminators and X is the separator), so the rarest codes in the reference, taken in reverse-complement pairs until the rest fit (6 codes), share one byte; the others get bytes 3, 4, ... (skipping X) in increasing order of code. Reverse complementing a digest reverses it and maps each byte to the byte of the reverse-complemented k-mer. We digest and build S from the digests as above.
Indexes. The BWT of S (with one terminator) is built with Big-BWT. The RLBWT stores the run heads in a Huffman-shaped wavelet tree and the run starts in Elias–Fano coded bitvectors (one overall and one per character). The RLCSA stores, for each character c, the BWT positions of the starts of the runs of c and the cumulative lengths of those runs, either as plain 32-bit arrays or with Elias–Fano coding; a backward step by c is a predecessor search in the list of c, and gives the same intervals as the RLBWT. The tag array is built by suffix sorting S with libdivsufsort, assigning each BWT row the document of its suffix, and run-length compressing the result (the terminator's row gets the last document). The r-index [34] stores the suffix-array samples at the run boundaries and supports with a predecessor structure on them; our sr-index removes samples as in Cobas et al. [15, 16] with parameter s, and s = 0 means no subsampling. Reported sizes are file sizes in units of
Taxonomic Classification with Complete Tag Arrays
bytes. A configuration’s space is the sum of the structures it uses: the RLBWT or RLCSA used for backward search; the tag array (plus the RLBWT, for LF, if it is sampled and the search uses an RLCSA); the sr-index samples (plus the RLBWT, for reading run heads, if the search uses an RLCSA); and the lookup table.
BML without digests. Let be a maximal A/C/G/T run of the read, skipped if ; set and, while : search backward for from its right end; if the step for fails, set and repeat. Otherwise continue backward from to the leftmost such that occurs, then search forward from (backward on the reverse complement) to the largest such that occurs. Report the MEM (the genera of its occurrences are those of its reverse complement's, whose interval the forward search gives), and set .
BML with digests. For a maximal A/C/G/T run of the read with , digest it as above, and for each window (covering bases ) let and be the positions in the digest of the first and last symbols it selects; both are non-decreasing in . Set and, while : search backward for ; if the step for fails, set to the smallest with (stop if there is none) and repeat. Otherwise extend backward to the leftmost and then forward to the largest such that occurs. The MEM's span in the read is the interval of bases [left, right], where left is the smallest with , and right = for the smallest with (right = if there is none). Record the MEM with its span, and set . Finally, discard every recorded MEM whose span is contained in another's, and report the rest with their spans.
Answers and scoring. The listing answer for a MEM M is the set D of documents containing it, with the number of occurrences in each (RZ_COUNTS=1); with proportional credit each gets weight , and with equal credit . The LCA answer is the pair of the smallest and largest documents containing M, and gives weight to each document from to ; this is Cliffy's LCA scoring (“method0” in its scripts), since documents are in tree order. Here is the length of M in bases (of its span, with digests). Weights from both mates are summed per genus (through doc_to_traversal.txt), with Cliffy's DocProfReadSet class handling the truth files. A pair whose true genus is missing or ambiguous in the truth file counts as correct, as in Cliffy's script, under both of our measures. Otherwise a pair is correct under Cliffy's rule if its true genus has the maximum weight, possibly tied, or if it has no weight at all and its true genus is not “uncultured”; it is strictly correct if its true genus alone has the maximum weight. We checked that our re-implementation of the scoring gives the same numbers as Cliffy's classify_silva_readset.py on a sample of 1500 pairs.
Other classifiers. We ran Kraken 2 [56] and Tagger [22] on the same reads and the same machine as KATKA (silva/run_kraken2.sh and silva/run_tagger.sh). We built Kraken 2's database with its own SILVA script (kraken2-build -special silva, default k = 35 and minimizer length 31), as Cliffy's authors did; it downloads the same release, SILVA 138.1 SSU NR99, but indexes all of its sequences, including those not annotated down to the genus level, with SILVA's taxonomy. Kraken 2 classifies the two mates of a pair together (-paired), and we scored its classifications with the part of Cliffy's script for Kraken 2, under which a pair is correct at the genus level only if Kraken 2 assigns it to its true genus; pairs assigned to a higher taxon, to the root or to nothing count as wrong (Cliffy's rule for pairs with no votes applies only to its own methods). The 84.3% in Section 4 also counts pairs assigned to an ancestor of their true genus below the domain, which that script calls vague positives. Tagger's authors instead built Kraken 2 with a flat hierarchy, in which a read is assigned to a genus, to the root or to nothing, so our numbers for Kraken 2 are not comparable with theirs. For Tagger, we built an index of the same 402 378 sequences as KATKA's, with each sequence's genus as its tag and one strand only (Tagger handles reverse complements when classifying), and used its default parameters (L = 25, a 10-mer lookup table). With L = 30, as for KATKA, Tagger was no more accurate (81.05%, 86.88% and 92.72% under the three rules), so we report its defaults. Tagger assigns each read a single genus, so we classified the two mates separately and let each vote for its genus with its length, as we do for KATKA; a pair whose mates are assigned different genera is then a tie, which is wrong under the strict measure, and a pair with one mate unclassified gets the other's genus. (Tagger's authors classified single reads.) For both tools, the times are with one thread and exclude loading the index: Kraken 2 reports its own classification time, and for Tagger we subtracted the running time of an invocation on a single read, which is dominated by loading the index. Tagger breaks ties between genera at random, with a separate random number generator in each thread, so its outputs with one thread and with 12 differ slightly; we scored the single-thread outputs. If a pair's mates are assigned different genera, breaking the tie at random gives the true genus with probability 1/2 when one of them is right, so the expected accuracy is the mean of the accuracies with such pairs counted as wrong and as correct. We measured speed separately, with silva/run_scale.sh, on 200 000 read pairs per region with 1, 6 and 12 threads, because on 5 000 pairs a run with 12 threads takes well under a second and start-up dominates: on 5 000 pairs, Kraken 2 was no faster with 12 threads than with one. With 6 and 12 threads, KATKA was 5.3 and 7.7 times faster than with one, Kraken 2 4.3 and 5.2 times, and Tagger 4.5 and 5.8 times. KATKA's time per read in Table 2, 53.1 s, is its total classification time divided by the number of reads; the 66.0 s elsewhere in the paper, which we use to compare our configurations, is measured differently, as the mean of per-read timings on 2 000 reads per region, and we have not investigated the difference. On the 5 000 read pairs per region, KATKA's default configuration has strict accuracy 93.70%, against 93.77% on the 200 000 pairs per region of Section 4.
Timing. Times are wall-clock per read, measured inside the classifier, with the index already loaded and the reads already read from disk; they include digesting the read, finding the matches and answering them. We report the mean over the four regions of the mean over the 2000 reads, all measured in a single run of run_pareto_ft.sh (with COUNTS=1), which also checks that every configuration gives the same answers with and without a lookup table. For every configuration, we checked that all backends and sampling rates give identical outputs.
Parallelism and further systems optimizations. With rz-classify -j p, p threads share one copy of the index: each takes chunks of 256 reads from the input, and the answers are written back in input order, so the output is identical to that of a single thread (we checked this for every listing method, with and without lookup tables and digests). The index structures are read-only during classification; the scratch space for document listing, counting and locating, and the statistics counters, are kept per thread. Alternatively, silva/run_split.sh p splits the read file into p contiguous slices, classifies them with p processes and concatenates the outputs; this needs no threads but loads p copies of the index. Beyond parallelism, we have not tuned our code at the systems level. Backward
Taxonomic Classification with Complete Tag Arrays
search and LF-mapping are dominated by cache misses that depend on each other, so the natural next steps are interleaving the searches for several reads and prefetching their next memory accesses, to hide the latency of each miss behind work on other reads; huge pages, to reduce TLB misses on indexes of a few gigabytes; and memory-mapping the indexes, so that processes share them and start immediately. Graphics processors suit data-parallel work better than pointer chasing, but they can also hide latency by running very many searches at once, so they might pay off for large batches of reads.
B Alternatives we considered
This appendix explains why KATKA is designed as it is, by describing the alternatives we tried along the way, and some we have not tried yet. Most of them were worse on SILVA, which consists of short, highly conserved sequences with many per genus; some might work better on other datasets, such as whole genomes, where the number of occurrences of matches and the compressibility of tag arrays could be quite different.
B.1 Which matches
Cliffy cuts each read into Ziv–Merhav phrases (ZMPs), the phrases of the cross parse of Section 2: each is the longest string ending at its position that occurs in the database, and each new backward search starts at the character where the previous one failed. The same parse underlies Relative Lempel–Ziv compression [39], but there each phrase also stores the position of a source, which is needed to decompress; for classification only the phrases matter, so ZMP seems the more appropriate name. Our first experiments compared ZMPs with all the MEMs of each read, found by Li’s forward–backward algorithm [42], which alternates backward and forward extensions and starts each search one position after the end of the previous MEM, using the LCA approach. MEMs were more accurate than ZMPs by 0.4 to 1.3 points at the genus level (with Cliffy’s scoring), both with and without digestion. However, reads have many short MEMs, short MEMs occur many times in the database, and listing the genera containing them is expensive: with a subsampled r-index (Appendix B.3), locating all the occurrences of all the MEMs of a read took 35 to 78 ms.
Table 5 shows how the threshold L of BML affects accuracy with equal credit. With L = 15, the accuracy of the LCA approach (87.3% with Cliffy's scoring; not shown in the table, which is for listing) is the same as with all the MEMs found by forward–backward search (87.2%), while listing with the sr-index becomes more than 100 times faster (289 s per read instead of 35 to 78 ms, with sampling parameter s = 4 and an explicit RLCSA). Accuracy is almost unchanged up to L = 30, drops by about 2 points at L = 50 and collapses for larger L, as reads start to have no MEM that long. Most of the gain in time comes from not listing the short MEMs, but BML also searches faster: forward–backward search that lists only the MEMs of length at least L takes 133 to 146 s per read without digestion, almost independently of L, against 77 to 136 s for BML (unsampled tags, explicit RLCSA, no lookup table, L from 40 down to 15), and remains slower with a lookup table (for example, 75 against 61 s with L = 30 and a 12-base table).
The table also shows why we prefer the strict accuracy: with Cliffy's scoring, accuracy appears to increase up to L = 50, but only because more read pairs end in ties among a few genera. Listing is also clearly more accurate than the LCA approach: with L = 15 and equal credit, by 3.5 points (strict) without digestion and by 3.6 points with it.
Table 5 Genus-level accuracy with BML for various thresholds (mean over the four regions), listing the genera containing each MEM, with equal credit. “Strict” counts ties and unclassified read pairs as wrong; “theirs” is Cliffy’s scoring. The last column is the fraction of unclassified read pairs.
| undigested | minimizer digests | |||||
|---|---|---|---|---|---|---|
| strict | theirs | uncl. | strict | theirs | uncl. | |
| 15 | 90.56% | 91.59% | 0.0% | 88.93% | 89.97% | 0.0% |
| 20 | 90.53% | 91.68% | 0.0% | 88.91% | 89.98% | 0.0% |
| 30 | 90.28% | 91.83% | 0.0% | 88.84% | 90.03% | 0.0% |
| 40 | 89.61% | 91.93% | 0.0% | 88.55% | 90.12% | 0.0% |
| 50 | 88.27% | 92.01% | 0.2% | 87.91% | 90.27% | 0.0% |
| 75 | 78.05% | 87.46% | 7.6% | 82.59% | 89.91% | 2.3% |
| 100 | 56.85% | 66.13% | 31.8% | 67.58% | 77.77% | 18.0% |
Table 6 Genus-level accuracy (strict / Cliffy’s scoring, mean over the four regions) with equal credit to each genus containing a match, credit proportional to the number of occurrences in each genus, and credit proportional to the fraction of each genus’s sequences (both strands) containing the match.
| equal | proportional | normalized | |
|---|---|---|---|
| digests, | 88.93 / 89.97% | 92.47 / 92.49% | 91.36 / 91.36% |
| digests, | 88.84 / 90.03% | 92.48 / 92.51% | 91.34 / 91.34% |
| undigested, | 90.56 / 91.59% | 93.74 / 93.75% | 92.92 / 92.92% |
| undigested, | 90.28 / 91.83% | 93.77 / 93.79% | 92.76 / 92.76% |
B.2 How to give credit
Equal credit, as in Cliffy’s approximate listing, was our first choice, since it treats each genus containing a match alike. Table 6 shows that proportional credit (Section 3.4) is about 3.5 points more accurate, both with and without digestion, and that it almost eliminates ties. Proportional credit favours genera with many sequences in SILVA, since they have more occurrences of everything. To separate this effect from that of weighting each genus by how much of it contains the match, we also tried dividing each count by , where is the number of sequences in genus and the factor 2 accounts for the two strands, so that each genus gets credit in proportion to the fraction of its sequences containing the match. This normalized credit gains about 2.5 points of strict accuracy over equal credit, but about 1 point less than proportional credit.
This does not mean that normalizing is a bad idea in general. MicrobeMixer chooses the genus of each simulated read according to the abundances in an aquatic biome, and only then a sequence of that genus, so our reads are not drawn in proportion to how well each genus is represented in SILVA. Proportional credit then acts as a prior that a genus with many sequences in the database is more likely, and it helps only insofar as the genera that are abundant in the simulated samples are also well represented in SILVA, which is plausible since well-studied genera tend to be sequenced more. On samples whose composition differs from that of the database, the prior could hurt, and normalizing, or correcting towards a known or estimated composition of the sample, could be better. A direct test would be to simulate reads by choosing genera uniformly, regardless of their representation in the database, and then sequences within each genus: if the advantage of proportional credit
Taxonomic Classification with Complete Tag Arrays
comes from the prior, it should shrink or disappear, while both kinds of weighting should still beat equal credit if the rest of the gain comes from weighting each genus by how much of it contains the match. We leave this test for future work.
B.3 How to list and count
Subsampled r-indexes. Once we have the BWT interval of a MEM, the obvious way to find the genera containing it, and the number of occurrences in each, is to locate all its occurrences with an r-index [34] and map each to its genus. The r-index stores two samples of the suffix array per run of the BWT; the subsampled r-index (sr-index) [15, 16] discards samples that are close in the text to others, so that it stores samples for a parameter s while locating each occurrence in time. We first stored the BWT as an RLBWT, with the run heads in a Huffman-shaped wavelet tree and the run starts in Elias–Fano coded bitvectors. With s = 16 and no lookup table, this index takes only 0.41 GB and classifies a read in 477 s with L = 30; building it from the sequences took under 9 minutes on our desktop (347 s for the BWT, 119 s for the r-index samples and 43 s to subsample them), and it is the smallest undigested index on our Pareto surface.
RLCSAs. Backward search on an RLBWT computes rank queries on the BWT, which become slower as the alphabet grows; this matters especially for minimizer digests, whose alphabet has 256 symbols. The RLCSA (Section 3.1) avoids this, and the sr-index's subsampling works the same way on an RLCSA, as in Cobas et al.'s sr-csa [16]; we still use the RLBWT's run heads to read characters when locating. Building an RLCSA from the BWT takes a few seconds, and an explicit RLCSA makes every configuration two to four times faster than the RLBWT.
Tag arrays. A tag array needs no suffix-array samples, and listing or counting with it costs time proportional to the number of genera or runs in the interval, rather than to the number of occurrences, so it is much faster than locating; it is also larger, because the tags have more runs than the BWT. Tagger [22] stores the genus of only the last position of each BWT run, which suffices for its single-genus toehold but not for listing. Most of the space of our tag array is in the genera of its runs, so we tried storing them for only some runs, in the spirit of subsampled r-indexes [16] and of Olbrich and Ohlebusch's sampled tag arrays [50]. Following Olbrich and Ohlebusch, let be the run containing the LF-mapping of the first position of run i. LF moves to the previous position of the text, so run has the same genus as run i, unless the first position of run i is the first character of a genus; we store the genera of those runs, of which there are fewer than genera, since only some genus starts are the first position of a run. The graph with edges has out-degree 1; unlike in Olbrich and Ohlebusch's setting, where tags strictly decrease along edges, it may have cycles (within a genus), so we also store the genus of one run on each cycle. We then choose the other sampled runs greedily so that every run reaches a sampled run in fewer than s steps. On the digest there are 7467 genus boundaries and 11141 cycles, and we sample 24% of the runs with s = 4 and 5% with s = 16, which shrinks the tags from 0.19 GB to 0.09 GB and 0.06 GB, respectively (without the range-minimum structure). Sampling did not help much, and grammar-compressing the runs instead works better (Section 3.3): computing LF needs access to the BWT, which an RLCSA does not provide, so a sampled tag array needs the RLBWT as well, which cancels most of its savings unless the RLBWT is used for backward search anyway; and counting with sampled tags needs the genus of every run in the interval, each recovered by following LF.
Table 7 Configurations on the time-space-accuracy Pareto surface (time per read in s, by threshold ), with proportional credit. EF stands for Elias–Fano, gramm. runs for tags with grammar-compressed runs (Section 3.3), is the sampling parameter of the sr-index or of the tags, and is the length of the strings in the lookup table: digest symbols with digestion and, unless stated otherwise, bases without. The accuracy depends only on the digestion and on (strict, mean over the four regions).
| configuration | space (GB) | |||
|---|---|---|---|---|
| minimizer digests: strict accuracy | 92.48% | 92.36% | 92.05% | |
| RLBWT + tags, | 0.16 | 735.6 | 361.4 | 225.1 |
| RLBWT + tags, , no table | 0.18 | 240.1 | 162.0 | 125.6 |
| RLBWT + tags, | 0.19 | 220.1 | 147.0 | 114.3 |
| EF RLCSA + tags | 0.27 | 61.9 | 50.7 | 44.4 |
| explicit RLCSA + tags | 0.49 | 39.3 | 32.7 | 25.2 |
| undigested: strict accuracy | 93.77% | 93.48% | ||
| RLBWT + sr-index, , no table | 0.41 | 476.9 | 389.5 | |
| RLBWT + sr-index, | 0.46 | 315.1 | 265.9 | |
| RLBWT + tags, | 0.61 | 227.8 | 197.6 | |
| RLBWT + gramm. runs | 0.64 | 211.5 | 186.6 | |
| RLBWT + tags, , | 0.88 | 216.2 | 185.8 | |
| RLBWT + gramm. runs, | 0.90 | 199.1 | 177.3 | |
| explicit RLCSA + sr-index, , no table | 0.98 | 193.9 | 145.3 | |
| explicit RLCSA + gramm. runs, no table | 1.02 | 104.0 | 85.0 | |
| explicit RLCSA + gramm. runs | 1.04 | 75.0 | 62.4 | |
| explicit RLCSA + gramm. runs, | 1.31 | 71.0 | 60.0 | |
| explicit RLCSA + tags (default) | 1.44 | 66.0 | 57.3 | |
| explicit RLCSA + tags, | 1.71 | 62.9 | 54.4 |
The Pareto surface. A configuration is on the time-space-accuracy Pareto surface if no other configuration is at least as good in all three measures and better in at least one. Table 7 lists the configurations on this surface, out of all combinations of backend (RLBWT, Elias–Fano or explicit RLCSA), listing structure (sr-index with , tags with , or, without digestion and with or 40, tags with grammar-compressed runs), lookup table ( bases or 0, 2 digest symbols) and (15 to 40 bases, or to 50 with digests), all with proportional credit, so the space of a tag array does not include its range-minimum structure. No configuration with is on the surface, since is at least as accurate and faster. Without digestion, sr-indexes give the smallest configurations, run-length compressed tag arrays the fastest, and grammar-compressed runs most of those in between; with digestion, only tag arrays appear.
B.4 LCAs without locating: the rz-index
When each match votes for an LCA, we only need the leftmost and rightmost genera containing it, which are the genera of its leftmost and rightmost occurrences in the text. The rz-index finds these without locating any other occurrence. It combines the first KATKA [33], which found the leftmost and rightmost occurrences of a -mer with range-minimum queries on grids built from LZ77 parses, with the composite indexes of Belazzougui et al. [7, 8], which pair the RLBWT with the phrase boundaries of the LZ77 parse: an occurrence that crosses or ends at a phrase boundary (a primary occurrence) is found with a two-dimensional grid whose points are the phrase boundaries, sorted by the text that follows them and by
Taxonomic Classification with Complete Tag Arrays
Table 8 LCA classification: the rz-index with ZMPs (Cliffy's matches; scored on 1 million read pairs per region) and with BML MEMs, against Cliffy's LCA query. Accuracy is at the genus level, with Cliffy's scoring ("theirs") and strict; ranges are over the four regions, single values are means; we did not compute strict accuracy for the ZMP runs. The rz-index sizes include auxiliary structures that speed up its grid queries; EF stands for Elias–Fano. Cliffy's time is for approximate listing, which uses the same index as its LCA query.
| configuration | space (GB) | time (/read) | theirs | strict | |
| digested ZMPs | rz, RLBWT | 0.76 | 212 | 83.7–87.3% | |
| rz, EF RLCSA | 0.75 | 152 | |||
| rz, explicit RLCSA | 0.96 | 125 | |||
| undigested ZMPs | rz, RLBWT | 0.99 | 522 | 84.8–88.6% | |
| rz, EF RLCSA | 1.01 | 594 | |||
| rz, explicit RLCSA | 1.39 | 330 | |||
| digested MEMs | rz, explicit RLCSA, | 0.96 | 131 | 85.7% | 85.3% |
| rz, explicit RLCSA, | 0.96 | 66 | 86.7% | 84.8% | |
| undigested MEMs | rz, explicit RLCSA, | 1.39 | 262 | 87.6% | 87.0% |
| rz, explicit RLCSA, | 1.39 | 167 | 89.3% | 85.5% | |
| Cliffy LCA | minimizers | 4.27 | 77–82 | 86.3–88.5% | |
| undigested | 9.01 | 199–204 | 87.5–90.2% |
the reversed text that precedes them, and all other occurrences are copies of primary ones. To query the grid for a pattern, they need the BWT interval of each of its suffixes, which backward search over the RLBWT of the text provides, and the interval of the reverse of each of its prefixes, for which they keep a second RLBWT, of the reversed text. Since our index contains both strands, we do not need that second RLBWT: we sort the phrase boundaries by the reverse complement of the text preceding them, instead of its reverse, so the intervals we need are those of the reverse complements of the prefixes, which are in the same index. Since the leftmost occurrence of a pattern is always primary, we can also replace range reporting with range-minimum queries on the grid. A symmetric grid built on a right-to-left parse gives the rightmost occurrence. For the rz-index, and its reverse are parsed with a left-referencing greedy LZ77 parse in which each phrase's source starts within the previous 32 million characters; the two grids are built on the phrase ends of the two parses, each as a wavelet matrix with a range-minimum structure on each level, and auxiliary structures (per-level union bitvectors and scan arrays) speed up the grid queries.
Table 8 compares the rz-index with Cliffy's LCA query. With Cliffy's own matches (ZMPs), the rz-index is 4.4 to 9 times smaller than Cliffy's index; on our older desktop it takes 1.6 to 3 times as long per read as Cliffy reports on its server (1.6 times with the explicit RLCSA). Its accuracy is within a few points of Cliffy's on a different set of reads: 1 point higher on V1–V2 and 1 to 4 points lower on the other three regions, which suggests that the two read sets differ somewhat in difficulty, and which served as a check on our setup. With MEMs found by BML and , the digested rz-index classifies a read in , faster than Cliffy reports for its digested LCA query on its server, with an index 4.4 times smaller and similar accuracy.
The rz-index is not on our Pareto surface, however, because with tag arrays listing costs little more than computing the LCA and is about 3.5 points more accurate with equal credit, and more with proportional credit. Computing the LCA from tags, as the smallest and largest genus listed, also gives exactly the same answers as the rz-index, about three times faster: over digests, with and an explicit RLCSA, about per read against .
The rz-index may still be useful where listing is not an option, for example when the number of documents is so large that listing them is too expensive.
B.5 Verifying digested matches
Undigested MEMs are more accurate than digested ones, so we tried to get the best of both by verifying each occurrence of a digested MEM against the DNA and extending it to an exact match, using a Relative Lempel–Ziv representation of the database (with the longest sequence of each genus as the reference) and the positions of the minimizers. These structures took 0.24 GB, and verification worked, but digested MEMs are less specific than DNA MEMs (with L = 30, they occur in 6.0 genera on average, against 3.8), and checking their occurrences took 850 s per read, against 125 to 253 s for classifying with an undigested sr-index on an explicit RLCSA with a lookup table (L from 30 down to 15).
B.6 Combining LCAs and listing
Listing is most expensive for MEMs with many occurrences, and for such MEMs the LCA may lose little information, so we tried answering by LCA (with the rz-index's grids) whenever a MEM has more than T occurrences, or whenever its occurrences cover a fraction at least of the sequences under its LCA, and listing (with the sr-index) otherwise. With BML, few MEMs have many occurrences: the threshold T saved 25 to 45% of the time over digests, but required the grids (0.42 GB more), and the rule based on sent fewer than 1% of the MEMs to the LCA while needing the LCA of every MEM to decide. With tag arrays, listing is as fast as computing the LCA anyway.
B.7 Filtering k-mers instead of digesting
KeBaB [10] first breaks each read into pseudo-MEMs, the maximal substrings of length at least L all of whose k-mers pass a Bloom filter of the database's k-mers ( ); every MEM of length at least L lies in a pseudo-MEM, so the rest of the read can be skipped without changing the answers. Since this keeps the accuracy of undigested matches, we asked whether it could give us the speed of digests instead. To bound what any filter could achieve, we used exact k-mer membership at no cost before undigested BML (listing with tags on the explicit RLCSA). The answers were identical, but 94 to 97% of the bases remained in pseudo-MEMs, and the time per read dropped only from 92–99 to 72–83 s for L = 30 ( or 25) and by 7 to 9% for L = 15 ( ), against 42 s with digests and an index a third of the size (all without lookup tables). Almost every k-mer of our short, accurate reads occurs in the database, and BML spends its time extending the long MEMs themselves; KeBaB is designed for long, error-prone reads. Brown et al. obtained their largest speedups by searching only each read's longest pseudo-MEMs, which risks discarding all of its long MEMs, since a long pseudo-MEM need not contain a long MEM: in their pipeline the pseudo-MEMs were chosen before any was searched. If finding pseudo-MEMs is integrated with searching them, this risk disappears: we can search the pseudo-MEMs in decreasing order of length and stop only when we have found as many MEMs as we want that are longer than the next pseudo-MEM [10], or use parse indexing to bound the lengths of the MEMs that pseudo-MEMs must contain [30].
B.8 Matching whole phrases
A digest symbol names only its minimizer, not the bases up to the next one. A one-level parse index [37, 11, 30] instead replaces each phrase of a locally consistent parse, such as
Taxonomic Classification with Complete Tag Arrays
prefix-free parsing [9] or a parse into phrases starting at minimizers, by an identifier, such as its Karp–Rabin hash, and parses the read the same way, so that matching whole phrases is exact, at about the cost of matching digests; only the ends of each MEM, up to about a phrase on each side, are lost. To estimate that loss, we trimmed each MEM found with L = 30 by the undigested index to the part a phrase index with minimizer phrases (k = 4, w = 11) would certainly match (18.5 bases removed per MEM, on average) and listed the genera of the trimmed strings. On 20 000 read pairs from each of V1–V2 and V4, strict accuracy dropped by 2.3 and 3.3 points, more than digestion costs, and trimming just 2 bases from each end already cost 0.3 to 0.5 points: the ends of a MEM are where the read diverges from all but a few genera, and the middles of our MEMs occur in 219 genera on average, against 4 for the whole MEMs. A one-level phrase index is therefore no substitute for digests on SILVA, although it might be on datasets whose matches carry less of their information at their ends.
B.9 Ideas we have not tried
Two-level parse indexes. A two-level parse index along the lines of Hong et al. [37, 11] stores an index for the text, as we do, together with an index for the parse, whose alphabet consists of the distinct phrases, and a bitvector marking the suffixes of the text that start phrases, which maps intervals between the two. A match can then be extended a whole phrase at a time while whole phrases match, and base by base only near its ends, so such an index avoids the loss of a one-level phrase index while taking fewer search steps. It needs a parse in which every occurrence of a string is cut in the same way, and the extra space for the parse index, and whether it saves time depends on how much a phrase step costs compared with the base steps it replaces.
Counting with rank queries. Instead of scanning the runs in a MEM's interval to count its occurrences in each genus, we could list the genera with Muthukrishnan's algorithm and then count the occurrences of each with two rank queries on the tag array, as Sadakane's document listing allows [55] and as Cobas, Mäkinen and Rossi do on a grammar-compressed document array [17]. This takes time proportional to the number of genera, rather than to the number of runs in the interval, but needs rank support on the run-length compressed tag array, for example a sorted list of the runs of each genus with their cumulative lengths, like the lists of our RLCSA; on SILVA, long MEMs have few runs in their intervals, so we did not expect it to pay off, but it could on datasets with more runs per interval.
Suffixient sets. Suffixient sets are a natural next step for finding MEMs. A suffixient set [23] is a set of text positions such that, for every edge of the suffix tree, some position in the set holds the edge's first character and is preceded by the label of the edge's parent node; one of size at most always exists, where is the number of runs in the BWT of the reversed text, and it supports finding MEMs with random access to the text. Suffixient arrays [13] store such positions in suffix-array order and locate MEMs by binary search, given random access to the text; they are efficient in the I/O model and are reported to be one to two orders of magnitude faster than the r-index on repetitive collections. Becker et al. [6] sample the suffix array using path decompositions of the suffix tree, also aiming at indexes that are efficient in the I/O model. Since KATKA spends most of its time finding MEMs, and our RLCSA, like any BWT-based index, suffers from poor cache locality, replacing it with a suffixient index, while keeping the tag array for listing, might make classification considerably faster.