We initiate the study of computational problems on $k$-mers (strings of length $k$) in labeled graphs. As a starting point, we consider the problem of counting the number of distinct $k$-mers found on the walks of a graph. We establish that this is $\#$P-hard, even on connected deterministic DAGs. However, in the class of deterministic Wheeler graphs (Gagie, Manzini, and Sirèn, TCS 2017), we show that distinct $k$-mers of such a graph $W=(V, E)$ can be counted using $O(|W|k)$ or $O(n^4 \log k)$ arithmetic operations, where $n=|V|$, $m=|E|$ and $|W|=n+m$. The latter result uses a new generalization of the technique of prefix doubling to Wheeler graphs. To generalize our results beyond Wheeler graphs, we discuss ways to transform a graph into a Wheeler graph in a manner that preserves the $k$-mers. As an application of our $k$-mer counting algorithms, we construct a representation of the de Bruijn graph of the $k$-mers that occupies $O(n_k + |W|k \log(\max_{1 \leq \ell \leq k} n_\ell) + σ\log m)$ bits of space, where $n_\ell$ is the number of distinct $\ell$-mers in the Wheeler graph, and $σ$ is the size of the alphabet. We show how to construct it in the same time complexity. Given that the Wheeler graph can be exponentially smaller than the de Bruijn graph, for large $k$ this provides a theoretical improvement over previous de Bruijn graph construction methods from graphs, which must spend $Ω(k)$ time per $k$-mer in the graph.
翻译:我们首次系统研究了带标签图中k-mer(长度为k的字符串)的计算问题。作为起点,我们考虑了统计图中所有游走路径上不同k-mer数量的问题。我们证明该问题属于#P难问题,即使在连通确定性有向无环图上亦然。然而,在确定性Wheeler图类(Gagie, Manzini与Sirèn, TCS 2017)中,我们证明此类图$W=(V, E)$的不同k-mer可通过$O(|W|k)$或$O(n^4 \log k)$次算术运算进行计数,其中$n=|V|$,$m=|E|$且$|W|=n+m$。后一结果运用了前缀倍增技术在Wheeler图上的新推广。为将结果推广至Wheeler图之外,我们探讨了在保持k-mer不变的前提下将任意图转换为Wheeler图的方法。作为k-mer计数算法的应用,我们构建了k-mer的de Bruijn图表示,其空间占用为$O(n_k + |W|k \log(\max_{1 \leq \ell \leq k} n_\ell) + σ\log m)$比特,其中$n_\ell$表示Wheeler图中不同$\ell$-mer的数量,$σ$为字母表规模。我们展示了在相同时间复杂度内完成构建的方法。鉴于Wheeler图可能指数级小于de Bruijn图,对于较大的$k$值,这为基于图的de Bruijn图构建方法提供了理论改进——传统方法必须为图中每个k-mer消耗$Ω(k)$时间。