Compact representation of k-mer de Bruijn graphs for genome read assembly
Identifieur interne : 000947 ( Pmc/Corpus ); précédent : 000946; suivant : 000948Compact representation of k-mer de Bruijn graphs for genome read assembly
Auteurs : Einar Andreas R DlandSource :
- BMC Bioinformatics [ 1471-2105 ] ; 2013.
Abstract
Processing of reads from high throughput sequencing is often done in terms of edges in the de Bruijn graph representing all
The FM-index, which is based on the Burrows–Wheeler transform, provides an efficient data structure providing a searchable index of all substrings from a set of strings, and is used to compactly represent full genomes for use in mapping reads to a genome: the memory required to store this is in the same order of magnitude as the strings themselves. However, reads from high throughput sequences mostly have high coverage and so contain the same substrings multiple times from different reads. I here present a modification of the FM-index, which I call the kFM-index, for indexing the set of
The kFM-index could replace more memory demanding data structures for storing the de Bruijn
Url:
DOI: 10.1186/1471-2105-14-313
PubMed: 24152242
PubMed Central: 4015147
Links to Exploration step
PMC:4015147Le document en format XML
<record><TEI><teiHeader><fileDesc><titleStmt><title xml:lang="en">Compact representation of <italic>k</italic>
-mer de Bruijn graphs for genome read assembly</title>
<author><name sortKey="R Dland, Einar Andreas" sort="R Dland, Einar Andreas" uniqKey="R Dland E" first="Einar Andreas" last="R Dland">Einar Andreas R Dland</name>
<affiliation><nlm:aff id="I1">Center for Cancer Biomedicine & Departement of Informatics, University of Oslo, 0316 Oslo, Norway</nlm:aff>
</affiliation>
<affiliation><nlm:aff id="I2">Department of Tumor Biology, Institute for Cancer Research, The Norwegian Radium Hospital, Oslo University Hospital, 0424 Oslo, Norway</nlm:aff>
</affiliation>
</author>
</titleStmt>
<publicationStmt><idno type="wicri:source">PMC</idno>
<idno type="pmid">24152242</idno>
<idno type="pmc">4015147</idno>
<idno type="url">http://www.ncbi.nlm.nih.gov/pmc/articles/PMC4015147</idno>
<idno type="RBID">PMC:4015147</idno>
<idno type="doi">10.1186/1471-2105-14-313</idno>
<date when="2013">2013</date>
<idno type="wicri:Area/Pmc/Corpus">000947</idno>
<idno type="wicri:explorRef" wicri:stream="Pmc" wicri:step="Corpus" wicri:corpus="PMC">000947</idno>
</publicationStmt>
<sourceDesc><biblStruct><analytic><title xml:lang="en" level="a" type="main">Compact representation of <italic>k</italic>
-mer de Bruijn graphs for genome read assembly</title>
<author><name sortKey="R Dland, Einar Andreas" sort="R Dland, Einar Andreas" uniqKey="R Dland E" first="Einar Andreas" last="R Dland">Einar Andreas R Dland</name>
<affiliation><nlm:aff id="I1">Center for Cancer Biomedicine & Departement of Informatics, University of Oslo, 0316 Oslo, Norway</nlm:aff>
</affiliation>
<affiliation><nlm:aff id="I2">Department of Tumor Biology, Institute for Cancer Research, The Norwegian Radium Hospital, Oslo University Hospital, 0424 Oslo, Norway</nlm:aff>
</affiliation>
</author>
</analytic>
<series><title level="j">BMC Bioinformatics</title>
<idno type="eISSN">1471-2105</idno>
<imprint><date when="2013">2013</date>
</imprint>
</series>
</biblStruct>
</sourceDesc>
</fileDesc>
<profileDesc><textClass></textClass>
</profileDesc>
</teiHeader>
<front><div type="abstract" xml:lang="en"><sec><title>Background</title>
<p>Processing of reads from high throughput sequencing is often done in terms of edges in the de Bruijn graph representing all <italic>k</italic>
-mers from the reads. The memory requirements for storing all <italic>k</italic>
-mers in a lookup table can be demanding, even after removal of read errors, but can be alleviated by using a memory efficient data structure.</p>
</sec>
<sec><title>Results</title>
<p>The FM-index, which is based on the Burrows–Wheeler transform, provides an efficient data structure providing a searchable index of all substrings from a set of strings, and is used to compactly represent full genomes for use in mapping reads to a genome: the memory required to store this is in the same order of magnitude as the strings themselves. However, reads from high throughput sequences mostly have high coverage and so contain the same substrings multiple times from different reads. I here present a modification of the FM-index, which I call the kFM-index, for indexing the set of <italic>k</italic>
-mers from the reads. For DNA sequences, this requires 5 bit of information for each vertex of the corresponding de Bruijn subgraph, i.e. for each different <italic>k</italic>
−1-mer, plus some additional overhead, typically 0.5 to 1 bit per vertex, for storing the equivalent of the FM-index for walking the underlying de Bruijn graph and reproducing the actual <italic>k</italic>
-mers efficiently.</p>
</sec>
<sec><title>Conclusions</title>
<p>The kFM-index could replace more memory demanding data structures for storing the de Bruijn <italic>k</italic>
-mer graph representation of sequence reads. A Java implementation with additional technical documentation is provided which demonstrates the applicability of the data structure (<ext-link ext-link-type="uri" xlink:href="http://folk.uio.no/einarro/Projects/KFM-index/">http://folk.uio.no/einarro/Projects/KFM-index/</ext-link>
).</p>
</sec>
</div>
</front>
<back><div1 type="bibliography"><listBibl><biblStruct><analytic><author><name sortKey="Conway, Tc" uniqKey="Conway T">TC Conway</name>
</author>
<author><name sortKey="Bromage, Aj" uniqKey="Bromage A">AJ Bromage</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Ning, Z" uniqKey="Ning Z">Z Ning</name>
</author>
<author><name sortKey="Cox, Aj" uniqKey="Cox A">AJ Cox</name>
</author>
<author><name sortKey="Mullikin, Jc" uniqKey="Mullikin J">JC Mullikin</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Roberts, M" uniqKey="Roberts M">M Roberts</name>
</author>
<author><name sortKey="Hayes, W" uniqKey="Hayes W">W Hayes</name>
</author>
<author><name sortKey="Hunt, Br" uniqKey="Hunt B">BR Hunt</name>
</author>
<author><name sortKey="Mount, Sm" uniqKey="Mount S">SM Mount</name>
</author>
<author><name sortKey="Yorke, Ja" uniqKey="Yorke J">JA Yorke</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Ye, C" uniqKey="Ye C">C Ye</name>
</author>
<author><name sortKey="Ma, Zs" uniqKey="Ma Z">ZS Ma</name>
</author>
<author><name sortKey="Cannon, Ch" uniqKey="Cannon C">CH Cannon</name>
</author>
<author><name sortKey="Pop, M" uniqKey="Pop M">M Pop</name>
</author>
<author><name sortKey="Yu, Dw" uniqKey="Yu D">DW Yu</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Pell, J" uniqKey="Pell J">J Pell</name>
</author>
<author><name sortKey="Hintze, A" uniqKey="Hintze A">A Hintze</name>
</author>
<author><name sortKey="Canino Koning, R" uniqKey="Canino Koning R">R Canino-Koning</name>
</author>
<author><name sortKey="Howe, A" uniqKey="Howe A">A Howe</name>
</author>
<author><name sortKey="Tiedje, Jm" uniqKey="Tiedje J">JM Tiedje</name>
</author>
<author><name sortKey="Brown, Ct" uniqKey="Brown C">CT Brown</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Chikhi, R" uniqKey="Chikhi R">R Chikhi</name>
</author>
<author><name sortKey="Rizk, G" uniqKey="Rizk G">G Rizk</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Ferragina, P" uniqKey="Ferragina P">P Ferragina</name>
</author>
<author><name sortKey="Manzini, G" uniqKey="Manzini G">G Manzini</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Burrows, M" uniqKey="Burrows M">M Burrows</name>
</author>
<author><name sortKey="Wheeler, Dj" uniqKey="Wheeler D">DJ Wheeler</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Grossi, R" uniqKey="Grossi R">R Grossi</name>
</author>
<author><name sortKey="Vitter, Js" uniqKey="Vitter J">JS Vitter</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Simpson, Jt" uniqKey="Simpson J">JT Simpson</name>
</author>
<author><name sortKey="Durbin, R" uniqKey="Durbin R">R Durbin</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Ferragina, P" uniqKey="Ferragina P">P Ferragina</name>
</author>
<author><name sortKey="Manzini, G" uniqKey="Manzini G">G Manzini</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Zerbino, Dr" uniqKey="Zerbino D">DR Zerbino</name>
</author>
<author><name sortKey="Birney, E" uniqKey="Birney E">E Birney</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Simpson, Jt" uniqKey="Simpson J">JT Simpson</name>
</author>
<author><name sortKey="Wong, K" uniqKey="Wong K">K Wong</name>
</author>
<author><name sortKey="Jackman, Sd" uniqKey="Jackman S">SD Jackman</name>
</author>
<author><name sortKey="Schein, Je" uniqKey="Schein J">JE Schein</name>
</author>
<author><name sortKey="Jones, Sjm" uniqKey="Jones S">SJM Jones</name>
</author>
<author><name sortKey="Birol, I" uniqKey="Birol I">I Birol</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Kelley, Dr" uniqKey="Kelley D">DR Kelley</name>
</author>
<author><name sortKey="Schatz, Mc" uniqKey="Schatz M">MC Schatz</name>
</author>
<author><name sortKey="Salzberg, Sl" uniqKey="Salzberg S">SL Salzberg</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Yang, X" uniqKey="Yang X">X Yang</name>
</author>
<author><name sortKey="Dorman, Ks" uniqKey="Dorman K">KS Dorman</name>
</author>
<author><name sortKey="Aluru, S" uniqKey="Aluru S">S Aluru</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Melsted, P" uniqKey="Melsted P">P Melsted</name>
</author>
<author><name sortKey="Pritchard, Jk" uniqKey="Pritchard J">JK Pritchard</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Marcais, G" uniqKey="Marcais G">G Marçais</name>
</author>
<author><name sortKey="Kingsford, C" uniqKey="Kingsford C">C Kingsford</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Liu, Y" uniqKey="Liu Y">Y Liu</name>
</author>
<author><name sortKey="Schroder, J" uniqKey="Schroder J">J Schröder</name>
</author>
<author><name sortKey="Schmidt, B" uniqKey="Schmidt B">B Schmidt</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Nong, G" uniqKey="Nong G">G Nong</name>
</author>
<author><name sortKey="Zhang, S" uniqKey="Zhang S">S Zhang</name>
</author>
<author><name sortKey="Chan, Wh" uniqKey="Chan W">WH Chan</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Hon, Wk" uniqKey="Hon W">WK Hon</name>
</author>
<author><name sortKey="Sadakane, K" uniqKey="Sadakane K">K Sadakane</name>
</author>
<author><name sortKey="Sung, Wk" uniqKey="Sung W">WK Sung</name>
</author>
</analytic>
</biblStruct>
<biblStruct><analytic><author><name sortKey="Okanohara, D" uniqKey="Okanohara D">D Okanohara</name>
</author>
<author><name sortKey="Sadakane, K" uniqKey="Sadakane K">K Sadakane</name>
</author>
</analytic>
</biblStruct>
</listBibl>
</div1>
</back>
</TEI>
<pmc article-type="research-article" xml:lang="en"><pmc-dir>properties open_access</pmc-dir>
<front><journal-meta><journal-id journal-id-type="nlm-ta">BMC Bioinformatics</journal-id>
<journal-id journal-id-type="iso-abbrev">BMC Bioinformatics</journal-id>
<journal-title-group><journal-title>BMC Bioinformatics</journal-title>
</journal-title-group>
<issn pub-type="epub">1471-2105</issn>
<publisher><publisher-name>BioMed Central</publisher-name>
</publisher>
</journal-meta>
<article-meta><article-id pub-id-type="pmid">24152242</article-id>
<article-id pub-id-type="pmc">4015147</article-id>
<article-id pub-id-type="publisher-id">1471-2105-14-313</article-id>
<article-id pub-id-type="doi">10.1186/1471-2105-14-313</article-id>
<article-categories><subj-group subj-group-type="heading"><subject>Methodology Article</subject>
</subj-group>
</article-categories>
<title-group><article-title>Compact representation of <italic>k</italic>
-mer de Bruijn graphs for genome read assembly</article-title>
</title-group>
<contrib-group><contrib contrib-type="author" corresp="yes" id="A1"><name><surname>Rødland</surname>
<given-names>Einar Andreas</given-names>
</name>
<xref ref-type="aff" rid="I1">1</xref>
<xref ref-type="aff" rid="I2">2</xref>
<email>einarro@ifi.uio.no</email>
</contrib>
</contrib-group>
<aff id="I1"><label>1</label>
Center for Cancer Biomedicine & Departement of Informatics, University of Oslo, 0316 Oslo, Norway</aff>
<aff id="I2"><label>2</label>
Department of Tumor Biology, Institute for Cancer Research, The Norwegian Radium Hospital, Oslo University Hospital, 0424 Oslo, Norway</aff>
<pub-date pub-type="collection"><year>2013</year>
</pub-date>
<pub-date pub-type="epub"><day>23</day>
<month>10</month>
<year>2013</year>
</pub-date>
<volume>14</volume>
<fpage>313</fpage>
<lpage>313</lpage>
<history><date date-type="received"><day>2</day>
<month>5</month>
<year>2013</year>
</date>
<date date-type="accepted"><day>14</day>
<month>10</month>
<year>2013</year>
</date>
</history>
<permissions><copyright-statement>Copyright © 2013 Rødland; licensee BioMed Central Ltd.</copyright-statement>
<copyright-year>2013</copyright-year>
<copyright-holder>Rødland; licensee BioMed Central Ltd.</copyright-holder>
<license license-type="open-access" xlink:href="http://creativecommons.org/licenses/by/2.0"><license-p>This is an Open Access article distributed under the terms of the Creative Commons Attribution License (<ext-link ext-link-type="uri" xlink:href="http://creativecommons.org/licenses/by/2.0">http://creativecommons.org/licenses/by/2.0</ext-link>
), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
</license>
</permissions>
<self-uri xlink:href="http://www.biomedcentral.com/1471-2105/14/313"></self-uri>
<abstract><sec><title>Background</title>
<p>Processing of reads from high throughput sequencing is often done in terms of edges in the de Bruijn graph representing all <italic>k</italic>
-mers from the reads. The memory requirements for storing all <italic>k</italic>
-mers in a lookup table can be demanding, even after removal of read errors, but can be alleviated by using a memory efficient data structure.</p>
</sec>
<sec><title>Results</title>
<p>The FM-index, which is based on the Burrows–Wheeler transform, provides an efficient data structure providing a searchable index of all substrings from a set of strings, and is used to compactly represent full genomes for use in mapping reads to a genome: the memory required to store this is in the same order of magnitude as the strings themselves. However, reads from high throughput sequences mostly have high coverage and so contain the same substrings multiple times from different reads. I here present a modification of the FM-index, which I call the kFM-index, for indexing the set of <italic>k</italic>
-mers from the reads. For DNA sequences, this requires 5 bit of information for each vertex of the corresponding de Bruijn subgraph, i.e. for each different <italic>k</italic>
−1-mer, plus some additional overhead, typically 0.5 to 1 bit per vertex, for storing the equivalent of the FM-index for walking the underlying de Bruijn graph and reproducing the actual <italic>k</italic>
-mers efficiently.</p>
</sec>
<sec><title>Conclusions</title>
<p>The kFM-index could replace more memory demanding data structures for storing the de Bruijn <italic>k</italic>
-mer graph representation of sequence reads. A Java implementation with additional technical documentation is provided which demonstrates the applicability of the data structure (<ext-link ext-link-type="uri" xlink:href="http://folk.uio.no/einarro/Projects/KFM-index/">http://folk.uio.no/einarro/Projects/KFM-index/</ext-link>
).</p>
</sec>
</abstract>
</article-meta>
</front>
<body><sec><title>Background</title>
<p>High throughput sequencing is generating huge amounts of sequence data even from single experiments. The raw sequence data will typically be too much to keep in the memory of most off-the-shelf computers, and with sequencing technologies progressing faster than the improvements in computer memory, the memory challenge is likely to increase in the future.</p>
<p>One key property of the raw sequencing data is that it is highly redundant. Genomes are usually sequenced at high coverage, which means there will frequently be at least 30–50 reads covering the same region of the genome, differing primarily by sequencing errors. Processing of sequencing reads for genome assembly usually involves two crucial steps: error correction to remove or correct sequencing errors, and assembly of overlapping reads to produce a smaller number of assembled sequences.</p>
<p>A common approach for simplifying the processing of the sequence data is to consider all the <italic>k</italic>
-mers of the reads: i.e. all the <italic>k</italic>
-substrings of the reads if we view them as strings. This set of <italic>k</italic>
-strings is then thought of as a subgraph of the de Bruijn graph of order <italic>k</italic>
− 1: i.e. one which has vertices corresponding to all <italic>k</italic>
− 1-substrings and edges corresponding to the <italic>k</italic>
-substrings. Even if sequenced at high coverage, each <italic>k</italic>
-mer is thus represented only once, reducing the redundancy of the sequence data considerably. However, direct storage of all <italic>k</italic>
-mers in a single list will require <italic>k</italic>
letters per <italic>k</italic>
-mer, i.e. 2<italic>k</italic>
bit of information for DNA sequences, which can be quite memory consuming when <italic>k</italic>
is large.</p>
<p>Naively, one might expect that this could be greately improved. From each vertex in the graph, there may be 4 possible out-going (or in-coming) edges if the graph represents DNA sequences: one for each of the nucleotides. Encoding which of these exist in the graph should require only 4 bit of information per vertex; if most vertices have only one out-edge, this might even be reduced towards 2 bit of information per vertex by only encoding which of the 4 possible edges is actually found. Of course, this approach requires that the vertices be known, but one might envision that the information about the vertices could be reconstructed when walking the graph: when walking <italic>k</italic>
−1 steps, all <italic>k</italic>
−1 letters of the resulting vertex will be known.</p>
<p>A traversable representation of the de Bruijn subgraph is equivalent to storing a searchable index of all the <italic>k</italic>
-substrings. By traversable, I mean that it is possible to efficiently walk the graph starting at any vertex, to check if any <italic>k</italic>
-mer or <italic>k</italic>
−1-mer is present as an edge or vertex in the graph, and preferably also to be able to retrieve the <italic>k</italic>
-mers and <italic>k</italic>
−1-mers represented by the graph. Thus, it is not only important that the data structure be compact, but efficient algorithms for using it are just as important.</p>
<p>A number of data structures exist that provide more compact storage of the de Bruijn subgraph than naive <italic>k</italic>
-mer lists or maps. Conway et al. [<xref ref-type="bibr" rid="B1">1</xref>
] were able to represent a de Bruijn subgraph with 12 G edges in 40.8 GB, i.e. 28.5 bit per edge, by using a compressed array. Other approaches reduce memory by storing only a subset of the <italic>k</italic>
-mers [<xref ref-type="bibr" rid="B2">2</xref>
-<xref ref-type="bibr" rid="B4">4</xref>
].</p>
<p>An entirely different approach uses a Bloom filter to store a hashed set of <italic>k</italic>
-mers [<xref ref-type="bibr" rid="B5">5</xref>
] using only 4 bit per <italic>k</italic>
-mer. This is a probabilistic data structure with a known false positive rate, but where false positive edges can be identified by not being part of longer paths. However, while this data structure is effective for checking if a <italic>k</italic>
-mer is contained in the graph, it does not easily allow listing of all vertices or edges. An enhancement of this method, Minia [<xref ref-type="bibr" rid="B6">6</xref>
], avoids critical false positives and also allows retrieval of all vertices, but at the cost of higher memory consumption.</p>
<p>Another memory-efficient solution uses the FM-index [<xref ref-type="bibr" rid="B7">7</xref>
], which is based on the Burrows–Wheeler transform [<xref ref-type="bibr" rid="B8">8</xref>
] used to represent a suffix array [<xref ref-type="bibr" rid="B9">9</xref>
], to store the collection of reads in a compressed form [<xref ref-type="bibr" rid="B10">10</xref>
]. The Burrows–Wheeler transform was originally developed for text compression and has the property that recurrent substrings in the text before the transform result in single-letter repeats in the transformed string. The FM-index adds auxiliary information on top of the Burrows–Wheeler transformed sequence that effectively turns it into a compactly stored suffix array. When concatenating the reads, the coverage makes the Burrows–Wheeler transformed sequence dominated by single-letter repeats which are highly compressible [<xref ref-type="bibr" rid="B10">10</xref>
]. Effectively, it requires 2 bit per edge to store the nucleotide, which corresponds to specifying the in-edge (or out-edge) of a vertex, and additional memory to store the run-length of the nucleotide, which corresponds to the <italic>k</italic>
-mer count. At least up to 50 times coverage, this data structure should be able to store one edge per byte if used to represent the de Bruijn subgraph of <italic>k</italic>
-mers.</p>
<p>It should be noted that the ability of different methods to handle read errors varies. Some of the cited methods are intended to perform error correction by filtering <italic>k</italic>
-mers by their frequency, while other methods assume that read errors for the most part have been corrected or excluded in advance.</p>
<p>I here provide a data structure with strong similarities to the FM-index, but which stores the de Bruijn subgraph representing the <italic>k</italic>
-mer substrings rather than entire sequences. It is based on the idea of storing for each vertex which of the possible in-coming edges are actually present. For each vertex it thus needs one bit of information per letter in the alphabet, i.e. 4 bit per vertex for DNA sequences, plus some additional data. The additional data consists of a grouping of vertices which requires one extra bit per vertex, plus the equivalent to the FM-index for mapping in-coming edges to their parent vertices. This version of the FM-index, which I call the <italic>kFM-index</italic>
since it applies to an index of <italic>k</italic>
-substrings, can be generated from the stored data, but for computational speed a subset of the index is kept in memory. All in all, a de Bruijn subgraph for DNA sequences, including the stored subset if the index, can be stored using 5–6 bits per vertex if memory consumption is critical. In the case where most vertices are of degree 1, i.e. have one in-edge and one out-edge, the stored data may be compressed down to approximately half the size.</p>
<p>Like the FM-index, the kFM-index stores only one strand of DNA sequences, and is suitable for walking the graph in one direction. For genome assembly, one does not know in advance which strand the read is on, and so normally are required to ensure that both the <italic>k</italic>
-mers of the reads and their reverse complements are added to the graph. Some data structures, e.g. most hashing strategies, can combine <italic>k</italic>
-mers and their reverse complements, and thus require roughly half the number of items. For the kFM-index, however, it is necessary to add both the reads and their reverse complements. In doing this, one may walk in the opposite direction by switching to the reverse complement, although there will be some computational overhead in doing so.</p>
<p>The basic operations available on the kFM-index are similar to those of the FM-index. Each vertex is identified by it’s index position, <italic>i</italic>
= 0,1,…,<italic>n</italic>
−1 where <italic>n</italic>
is the number of vertices in the de Bruijn subgraph and the vertices are lexicographically ordered. For a given string, the vertices having that string as a prefix, identified by the interval of index positions, can be found efficiently: the computational time is proportional to the length of the string. Given a vertex, identified by it’s index position <italic>i</italic>
, one can look up directly in the stored data which in-coming edges exist for that vertex. The index positions of the vertices from which the in-edges come can be computed efficiently. Thus, checking if a string exists as a path in the de Bruijn subgraph can be done. The reverse operation of identifying the string representation of a given vertex identified by index position <italic>i</italic>
also exists, but is slower: time complexity is <italic>O</italic>
(<italic>k</italic>
lg<italic>n</italic>
).</p>
<p>The kFM-index can be generated directly from a sorted list of in-edges, which is appropriate for amounts of sequence data that fit into the computer memory, although it should also be feasible to extend this by sorting the in-edges on disk: the time complexity is <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
lg<italic>σ</italic>
lg<italic>N</italic>
) where <italic>N</italic>
is the total length of the sequence data, and thus the number of items to be sorted, and <italic>N</italic>
<italic>k</italic>
lg<italic>σ</italic>
is the amount of data being sorted. Generation of kFM-indexes in memory from sequentially read sequence data can be done by splitting the raw sequence data into parts, generate kFM-indexes for each part, and then perform pairwise merges of these kFM-indexes. The time complexity of generating the kFM-index in this manner is essentially <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
lg(<italic>n</italic>
<italic>m</italic>
)), where <italic>n</italic>
is the number of vertices in the final de Bruijn graph (i.e. not counting identical <italic>k</italic>
-mers), <italic>σ</italic>
is the alphabet size, and <italic>m</italic>
is the number of parts the initial sequence data is partitioned into. This has proven to be quite time consuming: in part because of the time complexity of the provided merge algorithm, but probably also in part due to an inefficient implementation. I expect that there is room for major improvements. In addition, these operations are all open to parallelisation.</p>
<p>Readers familiar with the FM-index will see the similarities to it, despite the fact that the FM-index represents all suffixes while this new data structure only stores information about <italic>k</italic>
-substrings. Not only is the data structure very similar, but the functions and algorithms are also similar, or at least analogous, to those used with the FM-index. I therefore refer to this data structure as the kFM-index: an FM-index for <italic>k</italic>
-substrings. And instead of pointing out the similarities throughout the article, I will point out differences where these are noteworthy.</p>
<p>A Java implementation of the data structure is provided as a demonstration.</p>
</sec>
<sec sec-type="methods"><title>Methods</title>
<sec><title>Notation</title>
<p>Let Σ denote an <italic>alphabet</italic>
of size <italic>σ</italic>
= |Σ|, i.e. an arbitrary set whose elements we refer to as <italic>letters</italic>
: for DNA sequences, Σ = {<italic>A</italic>
,<italic>C</italic>
,<italic>G</italic>
,<italic>T</italic>
} and <italic>σ</italic>
= 4. A string of length <italic>l</italic>
, or an <italic>l</italic>
-string, is an element of <italic>x</italic>
∈ Σ<sup><italic>l</italic>
</sup>
. Let <inline-formula><mml:math id="M1" name="1471-2105-14-313-i1" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="normal">Σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>∗</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>=</mml:mo>
<mml:msubsup><mml:mrow><mml:mo>∪</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>l</mml:mi>
<mml:mo>=</mml:mo>
<mml:mn>0</mml:mn>
</mml:mrow>
<mml:mrow><mml:mi>∞</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:msup><mml:mrow><mml:mi mathvariant="normal">Σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>l</mml:mi>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
denote the set of all strings, including the empty string denoted <italic>ε</italic>
. We denote the length of the string by |<italic>x</italic>
|. If <italic>x</italic>
and <italic>y</italic>
are strings, <italic>xy</italic>
denotes the concatenated string of length |<italic>x</italic>
|+|<italic>y</italic>
|; for sets <italic>U</italic>
and <italic>V</italic>
of strings, the set of concatenated strings is denoted <italic>U</italic>
∘<italic>V</italic>
= {<italic>u</italic>
<italic>v</italic>
|<italic>u</italic>
∈ <italic>U</italic>
,<italic>v</italic>
∈ <italic>V</italic>
}.</p>
<p>We write <italic>x</italic>
<<italic>y</italic>
to indicate that string <italic>x</italic>
sorts lexicographically before <italic>y</italic>
based on an ordering of the letters in Σ. In addition to the letters in Σ, we have two special characters <italic>$</italic>
and <italic>∞</italic>
with the properties that <italic>$</italic>
<<italic>a</italic>
<<italic>∞</italic>
for all <italic>a</italic>
∈ Σ.</p>
<p>If <italic>x</italic>
is an <italic>l</italic>
-string, we write <italic>x</italic>
= <italic>x</italic>
<sub>1</sub>
…<italic>x</italic>
<sub><italic>l</italic>
</sub>
where <italic>x</italic>
<sub><italic>i</italic>
</sub>
∈ Σ are the letters. For <italic>p</italic>
≤<italic>q</italic>
, the [<italic>p</italic>
,<italic>q</italic>
] substring <italic>x</italic>
<sub>[<italic>p</italic>
,<italic>q</italic>
]</sub>
=<italic>x</italic>
<sub><italic>p</italic>
</sub>
…<italic>x</italic>
<sub><italic>q</italic>
</sub>
is a string of length <italic>q</italic>
−<italic>p</italic>
+1: <italic>x</italic>
<sub>[<italic>p</italic>
,<italic>p</italic>
−1]</sub>
is the empty string. A substring <italic>x</italic>
<sub>[1,<italic>p</italic>
]</sub>
at the start is referred to as a <italic>prefix</italic>
, while a substring <italic>x</italic>
<sub>[<italic>p</italic>
,<italic>l</italic>
]</sub>
at the end is referred to as a <italic>suffix</italic>
. The operation of trimming away the last letter is denoted <italic>x</italic>
<sup>−</sup>
=<italic>x</italic>
<sub>[1,<italic>l</italic>
−1]</sub>
=<italic>x</italic>
<sub>1</sub>
…<italic>x</italic>
<sub><italic>l</italic>
−1</sub>
.</p>
<p>For <inline-formula><mml:math id="M2" name="1471-2105-14-313-i2" overflow="scroll"><mml:mi mathvariant="script">S</mml:mi>
<mml:mo>=</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:msub><mml:mrow><mml:mi>s</mml:mi>
</mml:mrow>
<mml:mrow><mml:mn>1</mml:mn>
</mml:mrow>
</mml:msub>
<mml:mo>,</mml:mo>
<mml:mo>…</mml:mo>
<mml:mo>,</mml:mo>
<mml:msub><mml:mrow><mml:mi>s</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>N</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</inline-formula>
a list of strings, i.e. <italic>s</italic>
<sub><italic>i</italic>
</sub>
∈ Σ<sup>∗</sup>
, let <inline-formula><mml:math id="M3" name="1471-2105-14-313-i3" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>⊂</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="normal">Σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
denote the set of length <italic>k</italic>
substrings: i.e. <italic>x</italic>
∈ Σ<sup><italic>k</italic>
</sup>
is contained in <inline-formula><mml:math id="M4" name="1471-2105-14-313-i4" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
if and only if there is a string <inline-formula><mml:math id="M5" name="1471-2105-14-313-i5" overflow="scroll"><mml:mi>s</mml:mi>
<mml:mo>∈</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
</mml:math>
</inline-formula>
with <italic>x</italic>
= <italic>s</italic>
<sub>[<italic>p</italic>
,<italic>p</italic>
+<italic>k</italic>
−1]</sub>
for some position <italic>p</italic>
.</p>
<p>We denote the base 2 logarithm by lg<italic>x</italic>
= log2<italic>x</italic>
which is convenient for quantifying information. Thus, the information required to specify one out of <italic>n</italic>
options is lg <italic>n</italic>
bit.</p>
</sec>
<sec><title>Problem description</title>
<p>Given a set <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i6.gif"></inline-graphic>
</inline-formula>
of strings, e.g. a set of sequencing reads, we will construct a compact representation of <inline-formula><mml:math id="M6" name="1471-2105-14-313-i7" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
, i.e. the set of length <italic>k</italic>
substrings, suitable for quickly checking if any particular <italic>k</italic>
-string is present.</p>
<p>The data structure is best understood in terms of the <italic>de Bruijn subgraph</italic>
representation of <inline-formula><mml:math id="M7" name="1471-2105-14-313-i8" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
. This has vertices <inline-formula><mml:math id="M8" name="1471-2105-14-313-i9" overflow="scroll"><mml:mi>V</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
and edges <inline-formula><mml:math id="M9" name="1471-2105-14-313-i10" overflow="scroll"><mml:mi>E</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
where <italic>e</italic>
∈ <italic>E</italic>
is an edge from <italic>e</italic>
<sub>[1,<italic>k</italic>
−1]</sub>
to <italic>e</italic>
<sub>[2,<italic>k</italic>
]</sub>
. It is a subgraph of the de Bruijn graph of order <italic>k</italic>
−1, i.e. with vertices Σ<sup><italic>k</italic>
−1</sup>
and edges Σ<sup><italic>k</italic>
</sup>
. Some authors may refer to this as a <italic>word graph</italic>
, or even just a <italic>de Bruijn graph</italic>
. Since the set of vertices can be deduced from the edges, storing <inline-formula><mml:math id="M10" name="1471-2105-14-313-i11" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
is effectively the same as storing the information encoded in the de Bruijn subgraph. However, the graph structure highlights the overlap between edges meeting at vertices.</p>
<p>While some authors focus on <italic>k</italic>
as the length of the strings represented by the edges, others focus on the order of the graph which is the <italic>k</italic>
−1 length of the strings represented by the vertices. Since our purpose is to represent the <italic>k</italic>
-mer composition of the sequences, it is natural to focus on <italic>k</italic>
as the <italic>k</italic>
-mer length. However, the implementation of the algorithms is more naturally centered around the vertices, and so the Java implementation focuses on the order of the de Bruijn subgraph which is <italic>k</italic>
−1.</p>
</sec>
<sec><title>The kFM-index data structure</title>
<p>The data structure for storing the <italic>k</italic>
-substrings <inline-formula><mml:math id="M11" name="1471-2105-14-313-i12" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
from a set of strings <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i13.gif"></inline-graphic>
</inline-formula>
has similarities to the FM-index and the Burrows–Wheeler transformation. One similarity is that the data structure stores the prefixing letters, which represent the in-edges to vertices, and backtracks the de Bruijn subgraph through these in-coming edges rather than walking paths from beginning to end; the sequences, including the strings the vertices and edges represent, are thus reconstructed from the in-edge data when backtracking through the graph.</p>
<p>The initial de Bruijn subgraph representing the <italic>k</italic>
-string composition <inline-formula><mml:math id="M12" name="1471-2105-14-313-i14" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
may contain any number of <italic>final</italic>
<italic>vertices</italic>
: i.e. vertices for which there are no out-going edges. These final vertices correspond to <italic>k</italic>
−1-strings found only as suffixes of the strings in <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i15.gif"></inline-graphic>
</inline-formula>
, and represent a problem as they cannot be reached by backtracking the de Bruijn subgraph. As the data structure does not store the <italic>k</italic>
−1-strings for each vertex, but instead reconstructs these strings when walking the graph, these final vertices cannot be thus reconstructed. The solution is to add extra vertices and edges leading from these final vertices to a special final vertex from which we may start the reconstruction. See Figure <xref ref-type="fig" rid="F1">1</xref>
for an example.</p>
<fig id="F1" position="float"><label>Figure 1</label>
<caption><p><bold>The kFM-index data and corresponding de Bruijn subgraph.</bold>
Representation of the data structure for DNA 4-mers. The <italic>vertex strings</italic>
, lexigographically sorted, are not stored, but reconstructed from the edge and group end data. The <italic>edges</italic>
columns indicate in-coming edges to each vertex, i.e. letters that may prefix the vertex strings. The <italic>group end flag</italic>
inidicates groups of vertices with the same <italic>k</italic>
−2-prefix. The <italic>previous position</italic>
data can be generated from the edge set data and group end data and is constant within each vertex group; a subset is stored for computational speed.</p>
</caption>
<graphic xlink:href="1471-2105-14-313-1"></graphic>
</fig>
<p>Let <inline-formula><mml:math id="M13" name="1471-2105-14-313-i16" overflow="scroll"><mml:msub><mml:mrow><mml:mi>V</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>final</mml:mtext>
</mml:mrow>
</mml:msub>
<mml:mo>⊂</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
be a set that includes all <italic>k</italic>
−1-strings which are final vertices in the graph with edge set <inline-formula><mml:math id="M14" name="1471-2105-14-313-i17" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
: i.e. if <inline-formula><mml:math id="M15" name="1471-2105-14-313-i18" overflow="scroll"><mml:mi>v</mml:mi>
<mml:mo>∈</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
and <italic>v</italic>
is not a prefix of any string in <inline-formula><mml:math id="M16" name="1471-2105-14-313-i19" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
, then <italic>v</italic>
has to be in <italic>V</italic>
<sub>final</sub>
. Ideally, in order to get the most compact representation of <inline-formula><mml:math id="M17" name="1471-2105-14-313-i20" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
, we want <italic>V</italic>
<sub>final</sub>
to contain only these strings. However, we might start off by letting <italic>V</italic>
<sub>final</sub>
contain all <italic>k</italic>
−1-suffixes of the strings in <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i21.gif"></inline-graphic>
</inline-formula>
, knowing that the vertices required to be in <italic>V</italic>
<sub>final</sub>
have to be a subset of these, and then later prune away superfluous edges and vertices. Hence, we permit <italic>V</italic>
<sub>final</sub>
to be bigger than strictly required.</p>
<p>We now define the <italic>final-completed</italic>
de Bruijn subgraph with paths added from each <italic>v</italic>
∈ <italic>V</italic>
<sub>final</sub>
to a special vertex, <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
=<italic>$</italic>
…<italic>$</italic>
which we refer to as <italic>the final vertex</italic>
, having vertices</p>
<p><disp-formula id="bmcM1"><label>(1)</label>
<mml:math id="M18" name="1471-2105-14-313-i22" overflow="scroll"><mml:mi>V</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>∪</mml:mo>
<mml:msup><mml:mrow><mml:mfenced close=")" open="("><mml:mrow><mml:msub><mml:mrow><mml:mi>V</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>final</mml:mtext>
</mml:mrow>
</mml:msub>
<mml:mo>∘</mml:mo>
<mml:msup><mml:mrow><mml:mi>$</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:msup>
</mml:mrow>
</mml:mfenced>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>∪</mml:mo>
<mml:mo>{</mml:mo>
<mml:msup><mml:mrow><mml:mi>$</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:msup>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>and edges</p>
<p><disp-formula id="bmcM2"><label>(2)</label>
<mml:math id="M19" name="1471-2105-14-313-i23" overflow="scroll"><mml:mi>E</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>∪</mml:mo>
<mml:msup><mml:mrow><mml:mfenced close=")" open="("><mml:mrow><mml:msub><mml:mrow><mml:mi>V</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>final</mml:mtext>
</mml:mrow>
</mml:msub>
<mml:mo>∘</mml:mo>
<mml:msup><mml:mrow><mml:mi>$</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:msup>
</mml:mrow>
</mml:mfenced>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</disp-formula>
</p>
<p>where <italic>V</italic>
<sub>final</sub>
∘<italic>$</italic>
<sup><italic>k</italic>
−1</sup>
= {<italic>v</italic>
<italic>$</italic>
…<italic>$</italic>
∣ <italic>v</italic>
∈ <italic>V</italic>
<sub>final</sub>
} denotes the strings from which these additional paths are constructed. These are strings over an extended alphabet <inline-formula><mml:math id="M20" name="1471-2105-14-313-i24" overflow="scroll"><mml:mi mathvariant="normal">Σ</mml:mi>
<mml:mo>∪</mml:mo>
<mml:mo>{</mml:mo>
<mml:mi>$</mml:mi>
<mml:mo>}</mml:mo>
</mml:math>
</inline-formula>
, where <italic>$</italic>
is a special character that is sorted before any of the letters of Σ. The added vertices, i.e. those containing one or more <italic>$</italic>
at the end, are referred to as <italic>final-completing vertices</italic>
and are parts of paths leading to the final vertex. In fact, the final-completing vertices form a tree with the final vertex, <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
, as the root. Note that, for the case where <italic>V</italic>
<sub>final</sub>
is empty, we explicitly add the special vertex <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
: this is purely a matter of convenience.</p>
<p>By this extension of the de Bruijn subgraph, we have ensured that there is exactly one final vertex that cannot be reached by backtracking the graph, namely the final vertex <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
. When sorting the vertices lexicographically, this will always come first. Note that we do not require that the final vertex be reachable from the rest of the graph. If the original graph had <italic>V</italic>
<sub>final</sub>
empty, this would be the case.</p>
<p>We may identify <italic>E</italic>
with a subset of Σ×<italic>V</italic>
describing the set of in-coming edges to each vertex, and will by abuse of notation say that the pair (<italic>a</italic>
,<italic>v</italic>
) ∈ Σ×<italic>V</italic>
is an edge if the concatenation <italic>a</italic>
<italic>v</italic>
∈ <italic>E</italic>
. We denote the in-coming edges to <italic>v</italic>
by <italic>E</italic>
<sub><italic>v</italic>
</sub>
⊂Σ: i.e. <italic>E</italic>
<sub><italic>v</italic>
</sub>
= {<italic>a</italic>
∈ Σ ∣<italic>a</italic>
<italic>v</italic>
∈ <italic>E</italic>
}.</p>
<p>Note that backtracking through this de Bruijn subgraph corresponds to reading the strings in the backwards direction, from the end of the string towards the beginning, just as with the FM-index. A variant of the data structure which naturally reads the strings in the forward direction can be obtained by performing the construction on the reversed strings, the only effect of which is on the sorting of strings in the index which would then be based on the reversed string.</p>
<sec><title>Main data</title>
<p>Let <italic>n</italic>
= |<italic>V</italic>
| be the number of vertices of the final-completed de Bruijn subgraph, and let <italic>v</italic>
<sub>0</sub>
,…,<italic>v</italic>
<sub><italic>n</italic>
−1</sub>
denote the vertices of <italic>V</italic>
in lexicographic order; in particular, <italic>v</italic>
<sub>0</sub>
= <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
, which is the only final vertex of the final-completed de Bruijn subgraph. The basic information required to store the final-completed de Bruijn subgraph of <inline-formula><mml:math id="M21" name="1471-2105-14-313-i25" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
is: </p>
<p>Edges: The set <inline-formula><mml:math id="M22" name="1471-2105-14-313-i26" overflow="scroll"><mml:msub><mml:mrow><mml:mi>E</mml:mi>
</mml:mrow>
<mml:mrow><mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
</mml:mrow>
</mml:msub>
<mml:mo>⊂</mml:mo>
<mml:mi mathvariant="normal">Σ</mml:mi>
</mml:math>
</inline-formula>
of edges from each vertex <italic>v</italic>
<sub><italic>i</italic>
</sub>
is stored; i.e. the edge set <italic>E</italic>
identified as a subset of Σ×<italic>V</italic>
. This may be encoded as a <italic>σ</italic>
×<italic>n</italic>
array, <italic>η</italic>
(<italic>a</italic>
,<italic>i</italic>
), with binary values: i.e. <italic>η</italic>
(<italic>a</italic>
,<italic>i</italic>
)∈{<italic>false</italic>
,<italic>true</italic>
} indicates if <italic>av</italic>
<sub><italic>i</italic>
</sub>
∈<italic>E</italic>
. The in-edges <italic>E</italic>
<sub><italic>i</italic>
</sub>
={<italic>a</italic>
∣<italic>av</italic>
<sub><italic>i</italic>
</sub>
∈<italic>E</italic>
} to vertex <italic>v</italic>
<sub><italic>i</italic>
</sub>
may be represented as a bit-mapped number on which set operations correspond to binary operations.</p>
<p>Group end flags: We group vertices <italic>v</italic>
∈ <italic>V</italic>
with the same <italic>k</italic>
−2-prefix together: i.e. <italic>u</italic>
and <italic>v</italic>
are grouped together if <italic>u</italic>
<sup>−</sup>
= <italic>u</italic>
<sub>[1,<italic>k</italic>
−2]</sub>
and <italic>v</italic>
<sup>−</sup>
= <italic>v</italic>
<sub>[1,<italic>k</italic>
−2]</sub>
are identical. We indicate the group end by a flag <italic>f</italic>
<sub><italic>i</italic>
</sub>
which is <italic>true</italic>
if <italic>v</italic>
<sub><italic>i</italic>
</sub>
is the last vertex in its group, <italic>false</italic>
otherwise. This requires one bit of information per vertex.</p>
<p>More formally, these binary arrays take logical values, <italic>true</italic>
or <italic>false</italic>
, as defined by</p>
<p><disp-formula id="bmcM3"><label>(3)</label>
<mml:math id="M23" name="1471-2105-14-313-i27" overflow="scroll"><mml:mi>η</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mover><mml:mrow><mml:mo>⇔</mml:mo>
</mml:mrow>
<mml:mrow><mml:mtext>def</mml:mtext>
</mml:mrow>
</mml:mover>
<mml:mi>a</mml:mi>
<mml:mo>∈</mml:mo>
<mml:msub><mml:mrow><mml:mi>E</mml:mi>
</mml:mrow>
<mml:mrow><mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
</mml:mrow>
</mml:msub>
</mml:math>
</disp-formula>
</p>
<p>and</p>
<p><disp-formula id="bmcM4"><label>(4)</label>
<mml:math id="M24" name="1471-2105-14-313-i28" overflow="scroll"><mml:msub><mml:mrow><mml:mi>f</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mover><mml:mrow><mml:mo>⇔</mml:mo>
</mml:mrow>
<mml:mrow><mml:mtext>def</mml:mtext>
</mml:mrow>
</mml:mover>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>−</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mo>≠</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
<mml:mrow><mml:mo>−</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mtext>or</mml:mtext>
<mml:mi>i</mml:mi>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
</mml:math>
</disp-formula>
</p>
<p>where <italic>v</italic>
<sub><italic>i</italic>
</sub>
<<italic>v</italic>
<sub><italic>i</italic>
+1</sub>
follows from the lexicographic sorting of the vertices. We could have added as a convention that <italic>v</italic>
<sub><italic>n</italic>
</sub>
=<italic>∞</italic>
<sup><italic>k</italic>
−1</sup>
, in which case special handling of the final position would not have been required.</p>
<p>The grouping of vertices with the same <italic>k</italic>
−2-prefix allows us to check which in-edges originate from the same vertices: for <italic>a</italic>
,<italic>b</italic>
∈ Σ, <italic>u</italic>
,<italic>v</italic>
∈ <italic>V</italic>
, edges <italic>au</italic>
and <italic>bv</italic>
originate from vertices <italic>a</italic>
<italic>u</italic>
<sup>−</sup>
and <italic>b</italic>
<italic>v</italic>
<sup>−</sup>
respectively, which is the same vertex if <italic>a</italic>
= <italic>b</italic>
and <italic>u</italic>
<sup>−</sup>
=<italic>v</italic>
<sup>−</sup>
, which corresponds to checking if <italic>u</italic>
and <italic>v</italic>
are in the same vertex group.</p>
</sec>
<sec><title>Index to previous vertex position</title>
<p>In addition to the main data, there is an indexing function which may be generated from the main data. These are values per vertex group, i.e. constant within the groups of vertices with the same <italic>k</italic>
−2-prefix. Storing the entire indexing function as auxiliary data would take a lot of memory, while computing everything from scratch would take a lot of time. Instead, a balance between memory and speed is obtained by storing a sparse subset, e.g. at regular intervals, and recompute the values in-between on demand. This index corresponds to the FM-index and provides a map from a vertex to the origin vertex of its in-edges.</p>
<p>For each letter <italic>a</italic>
∈ Σ, let <italic>τ</italic>
(<italic>a</italic>
) denote the number of vertex groups that contain an <italic>a</italic>
in-edge. For <italic>i</italic>
= 0,…,<italic>n</italic>
, let <italic>c</italic>
(<italic>a</italic>
,<italic>i</italic>
) denote the number of vertex groups prior to position <italic>i</italic>
that contain an <italic>a</italic>
in-edge: the vertex group containing <italic>v</italic>
<sub><italic>i</italic>
</sub>
is not included in this sum. This makes <italic>τ</italic>
(<italic>a</italic>
) = <italic>c</italic>
(<italic>a</italic>
,<italic>n</italic>
), since the vertices all have positions <italic>i</italic>
<<italic>n</italic>
.</p>
<p>For <italic>a</italic>
∈ Σ, <italic>i</italic>
= 0,…,<italic>n</italic>
, let</p>
<p><disp-formula id="bmcM5"><label>(5)</label>
<mml:math id="M25" name="1471-2105-14-313-i29" overflow="scroll"><mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>+</mml:mo>
<mml:munder><mml:mrow><mml:mi mathsize="big">∑</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>b</mml:mi>
<mml:mo><</mml:mo>
<mml:mi>a</mml:mi>
</mml:mrow>
</mml:munder>
<mml:mi>τ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>b</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>+</mml:mo>
<mml:mi>c</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>where the summation of <italic>b</italic>
<<italic>a</italic>
is for all <italic>b</italic>
∈ Σ lexicographically prior to <italic>a</italic>
, and the 1 corresponds to skipping the vertex <italic>v</italic>
<sub>0</sub>
= <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
. Note that if <italic>a</italic>
<sup>′</sup>
is the letter following <italic>a</italic>
in the alphabet Σ, i.e. <italic>a</italic>
<sup>′</sup>
= <italic>a</italic>
+1 if we consider the letters to be enumerated 0,…,<italic>σ</italic>
−1, then <italic>ρ</italic>
(<italic>a</italic>
<sup>′</sup>
,0) = <italic>ρ</italic>
(<italic>a</italic>
,<italic>n</italic>
); and for <italic>a</italic>
the last letter of Σ, i.e. <italic>a</italic>
= <italic>σ</italic>
− 1, we have <italic>ρ</italic>
(<italic>a</italic>
,<italic>n</italic>
) = <italic>n</italic>
.</p>
<p>The position array, <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
), has the property that if vertex <italic>v</italic>
<sub><italic>i</italic>
</sub>
has an in-coming edge <italic>av</italic>
<sub><italic>i</italic>
</sub>
∈<italic>E</italic>
, i.e. <inline-formula><mml:math id="M26" name="1471-2105-14-313-i30" overflow="scroll"><mml:mi>a</mml:mi>
<mml:mo>∈</mml:mo>
<mml:msub><mml:mrow><mml:mi>E</mml:mi>
</mml:mrow>
<mml:mrow><mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
</mml:mrow>
</mml:msub>
</mml:math>
</inline-formula>
, this edge comes from vertex <italic>v</italic>
<sub><italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
)</sub>
. A more general definition is that</p>
<p><disp-formula id="bmcM6"><label>(6)</label>
<mml:math id="M27" name="1471-2105-14-313-i31" overflow="scroll"><mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>min</mml:mo>
<mml:mo>{</mml:mo>
<mml:mi>j</mml:mi>
<mml:mo>∣</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>j</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>≥</mml:mo>
<mml:msubsup><mml:mrow><mml:mtext mathvariant="italic">av</mml:mtext>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>−</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mtext>or</mml:mtext>
<mml:mi>j</mml:mi>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>where, as before, <italic>v</italic>
<sup>−</sup>
= <italic>v</italic>
<sub>[1,<italic>k</italic>
−2]</sub>
for <italic>k</italic>
−1-strings <italic>v</italic>
∈ <italic>V</italic>
and <italic>u</italic>
≥<italic>v</italic>
refers to the lexicographic ordering of strings.</p>
<p>We may also note that, if we represent letters <italic>a</italic>
by integers 0,…,<italic>σ</italic>
−1, we have <italic>ρ</italic>
(<italic>a</italic>
,<italic>n</italic>
) = <italic>ρ</italic>
(<italic>a</italic>
+1,0), and may define <italic>ρ</italic>
(<italic>a</italic>
<italic>n</italic>
+<italic>i</italic>
) = <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
), where <italic>ρ</italic>
(<italic>j</italic>
) is again a non-decreasing function for <inline-formula><mml:math id="M28" name="1471-2105-14-313-i32" overflow="scroll"><mml:mi>j</mml:mi>
<mml:mo>=</mml:mo>
<mml:mn>0</mml:mn>
<mml:mo>,</mml:mo>
<mml:mo>…</mml:mo>
<mml:mo>,</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>×</mml:mo>
<mml:mi>σ</mml:mi>
</mml:math>
</inline-formula>
with <italic>ρ</italic>
(0)=1 and <italic>ρ</italic>
(<italic>n</italic>
·<italic>σ</italic>
)=<italic>n</italic>
. Representing <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) in terms of <italic>ρ</italic>
(<italic>a</italic>
<italic>n</italic>
+<italic>i</italic>
) is sometimes convenient, e.g. when we want to compute the inverse, and similarly we may use <italic>a</italic>
<italic>n</italic>
+<italic>i</italic>
to represent an in-edge, or potential in-edge, (<italic>a</italic>
,<italic>v</italic>
<sub><italic>i</italic>
</sub>
).</p>
<p>As may be noted, the role of <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) in mapping from one vertex to another is essentially the same as the FM-index for mapping from one suffix to another. The main difference is in the grouping of vertices into groups, where counts are over vertex groups rather than individual vertices. The reason this vertex grouping is required is that the de Bruijn subgraph allows branching, i.e. for vertices to have more than one out-edge; the vertices in a vertex group share the same set of in-edges. The traditional FM-index could be envisioned as a de Bruijn subgraph with no branching, where each vertex has exactly one in-edge and one out-edge, and so the vertex groups would all consist of just one vertex.</p>
</sec>
<sec><title>Auxiliary data stored for computation speed</title>
<p>Storing <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) (or equivalently <italic>c</italic>
(<italic>a</italic>
,<italic>i</italic>
)) as an array of integers requires <italic>σ</italic>
×lg <italic>n</italic>
bit for each vertex. However, if <italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
) are known for some nearby <italic>j</italic>
, the number of computational steps to compute <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) from <italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
) is proportional to |<italic>i</italic>
−<italic>j</italic>
|. So by storing only a subset of the <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
), e.g. every <italic>q</italic>
th position, the memory required for storing the auxiliary data is greatly reduced, but at the cost of computational time for determining <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
). The partial storing of <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) is essentially the same as for the FM-index, and can be done in a number of different ways.</p>
<p>Let 0=<italic>i</italic>
<sub>0</sub>
<⋯<<italic>i</italic>
<sub><italic>ζ</italic>
</sub>
=<italic>n</italic>
be the position for which <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) is to be stored, with <italic>i</italic>
<sub><italic>r</italic>
</sub>
−<italic>i</italic>
<sub><italic>r</italic>
−1</sub>
≤<italic>q</italic>
for some chosen <italic>q</italic>
. The stored values then consist of an array <italic>κ</italic>
(<italic>a</italic>
<italic>ζ</italic>
+<italic>r</italic>
)=<italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
<sub><italic>r</italic>
</sub>
) where <italic>a</italic>
= 0,…,<italic>σ</italic>
−1 represent the letters. Thus, we have <italic>κ</italic>
(<italic>j</italic>
) for 0≤<italic>j</italic>
≤<italic>σ</italic>
<italic>ζ</italic>
with increments 0≤<italic>κ</italic>
(<italic>j</italic>
)−<italic>κ</italic>
(<italic>j</italic>
−1)≤<italic>q</italic>
. Storing the entire <italic>κ</italic>
array is, however, still space consuming unless <italic>q</italic>
is allowed to be big, in which case computing <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) will take time.</p>
<p>Knowing that <italic>κ</italic>
(<italic>j</italic>
) increases by values between 0 and <italic>q</italic>
, we can write <italic>κ</italic>
(<italic>j</italic>
)=<italic>u</italic>
<sub><italic>j</italic>
</sub>
+<italic>qU</italic>
<sub><italic>j</italic>
</sub>
where <italic>U</italic>
<sub><italic>j</italic>
</sub>
=⌊<italic>κ</italic>
(<italic>j</italic>
)/<italic>q</italic>
⌋ and 0≤<italic>u</italic>
<sub><italic>j</italic>
</sub>
<<italic>q</italic>
and store the <italic>u</italic>
<sub><italic>j</italic>
</sub>
in a bit-packed array. The values <italic>U</italic>
<sub><italic>j</italic>
</sub>
now have increments <italic>Δ</italic>
<italic>U</italic>
<sub><italic>j</italic>
</sub>
=<italic>U</italic>
<sub><italic>j</italic>
</sub>
−<italic>U</italic>
<sub><italic>j</italic>
−1</sub>
∈{0,1}. We store the increments <italic>Δ</italic>
<italic>U</italic>
<sub><italic>j</italic>
</sub>
as an array of bits, and a subset of the <italic>U</italic>
<sub><italic>j</italic>
</sub>
from which the remaining <italic>U</italic>
<sub><italic>j</italic>
</sub>
can then be computed efficiently. This allows us to select a much smaller value for <italic>q</italic>
than would otherwise be feasible.</p>
</sec>
<sec><title>Java implementation</title>
<p>The Java implementation stores <italic>η</italic>
(<italic>a</italic>
,<italic>i</italic>
) and <italic>f</italic>
<sub><italic>i</italic>
</sub>
as a <italic>σ</italic>
+1 bit block for each vertex <italic>i</italic>
. These blocks are then packed into 64 bit words (long integers). For DNA sequences, each 64 bit word thus stores 12 vertices, each using 5 bit.</p>
<p>The stored values of <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) are expressed in terms of <italic>κ</italic>
(<italic>j</italic>
)=<italic>u</italic>
<sub><italic>j</italic>
</sub>
+<italic>qU</italic>
<sub><italic>j</italic>
</sub>
. The <italic>u</italic>
<sub><italic>j</italic>
</sub>
are bit-packed into an array to preserve memory. For reconstruction of the <italic>U</italic>
<sub><italic>j</italic>
</sub>
, every 64th <italic>U</italic>
<sub><italic>j</italic>
</sub>
is stored, i.e. <italic>U</italic>
<sub>64<italic>r</italic>
</sub>
, and the increments <italic>Δ</italic>
<italic>U</italic>
<sub><italic>j</italic>
</sub>
are stored in blocks of 64 bits. Any <italic>U</italic>
<sub><italic>j</italic>
</sub>
can then be computed efficiently from <italic>U</italic>
<sub>64<italic>r</italic>
</sub>
, <italic>r</italic>
= ⌊ <italic>j</italic>
/64⌋, and the increments <italic>Δ</italic>
<italic>U</italic>
<sub>64<italic>r</italic>
+1</sub>
,…,<italic>Δ</italic>
<italic>U</italic>
<sub><italic>j</italic>
</sub>
using operations on 64 bit words.</p>
</sec>
</sec>
<sec><title>Fundamental functions for utilising the data structure</title>
<p>For a string <italic>x</italic>
and <italic>a</italic>
∈ Σ, we define the function <italic>γ</italic>
(<italic>x</italic>
) recursively by</p>
<p><disp-formula id="bmcM7"><label>(7)</label>
<mml:math id="M29" name="1471-2105-14-313-i33" overflow="scroll"><mml:mtable columnalign="left"><mml:mtr><mml:mtd><mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>ε</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>$</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mn>0</mml:mn>
<mml:mo>,</mml:mo>
<mml:mspace width="1em"></mml:mspace>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>∞</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>,</mml:mo>
</mml:mtd>
</mml:mtr>
<mml:mtr><mml:mtd><mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mn>0</mml:mn>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>,</mml:mo>
<mml:mspace width="1em"></mml:mspace>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mtext mathvariant="italic">ax</mml:mtext>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo stretchy="false">)</mml:mo>
<mml:mi>.</mml:mi>
</mml:mtd>
</mml:mtr>
</mml:mtable>
</mml:math>
</disp-formula>
</p>
<p>This function has a natural interpretation. If |<italic>x</italic>
|<<italic>k</italic>
,<italic>γ</italic>
(<italic>x</italic>
) is the smallest non-negative integer <italic>i</italic>
for which <italic>x</italic>
≤<italic>v</italic>
<sub><italic>i</italic>
</sub>
, or <italic>i</italic>
= <italic>n</italic>
if none such exists. If |<italic>x</italic>
|≥<italic>k</italic>
,<italic>γ</italic>
(<italic>x</italic>
) is the smallest integer <italic>i</italic>
for which <italic>x</italic>
≤<italic>v</italic>
<sub><italic>i</italic>
</sub>
<italic>y</italic>
for some string <italic>y</italic>
∈ Σ<sup>∗</sup>
so that <italic>v</italic>
<sub><italic>i</italic>
</sub>
<italic>y</italic>
can be realised as a path in the de Bruijn subgraph (<italic>V</italic>
,<italic>E</italic>
), i.e. all <italic>k</italic>
-substrings of <italic>v</italic>
<sub><italic>i</italic>
</sub>
<italic>y</italic>
are in <italic>E</italic>
, or <italic>i</italic>
= <italic>n</italic>
if no such string exists. This property is formally proved in Lemma 2 in the Proofs of results appendix.</p>
<p>In order to utilise the data structure, for strings <italic>x</italic>
with length |<italic>x</italic>
|<<italic>k</italic>
, we define two utility functions: the first vertex <italic>v</italic>
≥ <italic>x</italic>
is</p>
<p><disp-formula id="bmcM8"><label>(8)</label>
<mml:math id="M30" name="1471-2105-14-313-i34" overflow="scroll"><mml:mi>α</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>min</mml:mo>
<mml:mo>{</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>∣</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>≥</mml:mo>
<mml:mi>x</mml:mi>
<mml:mtext>or</mml:mtext>
<mml:mi>i</mml:mi>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>while the first vertex with <italic>v</italic>
><italic>x</italic>
<italic>∞</italic>
is</p>
<p><disp-formula id="bmcM9"><label>(9)</label>
<mml:math id="M31" name="1471-2105-14-313-i35" overflow="scroll"><mml:mi>β</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x∞</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>min</mml:mo>
<mml:mo>{</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>∣</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>></mml:mo>
<mml:mi>x∞</mml:mi>
<mml:mspace width="0.3em"></mml:mspace>
<mml:mtext>or</mml:mtext>
<mml:mspace width="0.3em"></mml:mspace>
<mml:mi>i</mml:mi>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>Recall that <italic>∞</italic>
><italic>a</italic>
for all <italic>a</italic>
∈ Σ, so <italic>β</italic>
(<italic>x</italic>
) for <italic>x</italic>
∈ Σ<sup><italic>l</italic>
</sup>
, <italic>l</italic>
<<italic>k</italic>
, finds the first <italic>v</italic>
∈ <italic>V</italic>
for which <italic>v</italic>
<sub>[1,<italic>l</italic>
]</sub>
><italic>x</italic>
, while <italic>α</italic>
(<italic>x</italic>
) finds the first <italic>v</italic>
for which <italic>v</italic>
<sub>[1,<italic>l</italic>
]</sub>
≥<italic>x</italic>
. Thus, <italic>α</italic>
and <italic>β</italic>
are defined by the property</p>
<p><disp-formula id="bmcM10"><label>(10)</label>
<mml:math id="M32" name="1471-2105-14-313-i36" overflow="scroll"><mml:mo>{</mml:mo>
<mml:mi>v</mml:mi>
<mml:mo>∈</mml:mo>
<mml:mi>V</mml:mi>
<mml:mo>∣</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>,</mml:mo>
<mml:mi>l</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msub>
<mml:mo>=</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>}</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>{</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>∣</mml:mo>
<mml:mi>α</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>≤</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo><</mml:mo>
<mml:mi>β</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>for all <italic>x</italic>
∈ Σ<sup><italic>l</italic>
</sup>
, <italic>l</italic>
<<italic>k</italic>
, making them exactly the functions we need to identify all vertices starting with a given prefix.</p>
<p>Note that if we add the vertex <italic>v</italic>
<sub><italic>n</italic>
</sub>
=<italic>∞</italic>
<sup><italic>k</italic>
−1</sup>
to the list, we wouldn’t have to specify the <italic>i</italic>
= <italic>n</italic>
case in the above definitions. Again, this addition would purely be a matter of convenience and not have any practical impact.</p>
</sec>
<sec><title>Algorithms for using the data structure</title>
<p>The above described data structure encodes a de Bruijn subgraph representation of the <italic>k</italic>
-substring composition of the strings <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i37.gif"></inline-graphic>
</inline-formula>
. However, to utilise this representation, we need efficient algorithms.</p>
<p>Throughout the algorithms, vertices of <italic>V</italic>
will be identified by their position <italic>i</italic>
∈ {0,…,<italic>n</italic>
−1} in the lexicographically sorted list <italic>v</italic>
<sub>0</sub>
,…,<italic>v</italic>
<sub><italic>n</italic>
−1</sub>
where <italic>n</italic>
= |<italic>V</italic>
|. The string that each vertex represents will generally not be known.</p>
<p>The alphabet Σ is known from the start and the letters ordered. Computationally, it is natural to represent the letters by numbers 0,…,<italic>σ</italic>
−1 (ignoring the letter <italic>$</italic>
) since they are to be used as array indexes. However, for added readability, I will denote them as letters <italic>a</italic>
∈ Σ in the algorithms rather as numerical indexes.</p>
<sec><title>Computing the previous position <bold><italic>ρ(a,i)</italic>
</bold>
for arbitrary positions</title>
<p>A first step is to be able to compute <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) for arbitrary positions based on the stored data.</p>
<p>Let 0=<italic>i</italic>
<sub>0</sub>
<…<<italic>i</italic>
<sub><italic>ζ</italic>
</sub>
= <italic>n</italic>
be the values for which <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) is stored, i.e. <italic>ρ</italic>
<sub>store</sub>
(<italic>a</italic>
,<italic>i</italic>
<sub><italic>r</italic>
</sub>
)=<italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
<sub><italic>r</italic>
</sub>
), and define functions</p>
<p><disp-formula id="bmcM11"><label>(11)</label>
<mml:math id="M33" name="1471-2105-14-313-i38" overflow="scroll"><mml:msup><mml:mrow><mml:mi>ι</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>+</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>min</mml:mo>
<mml:mo>{</mml:mo>
<mml:msub><mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>|</mml:mo>
<mml:msub><mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>≥</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>}</mml:mo>
<mml:mo>,</mml:mo>
<mml:mspace width="1em"></mml:mspace>
<mml:msup><mml:mrow><mml:mi>ι</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>−</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>max</mml:mo>
<mml:mo>{</mml:mo>
<mml:msub><mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>|</mml:mo>
<mml:msub><mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>≤</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>}</mml:mo>
</mml:math>
</disp-formula>
</p>
<p>for pointing to the next or previous stored value. We may then compute <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) by aggregating from the vertex group containing <italic>ρ</italic>
(<italic>a</italic>
,<italic>ι</italic>
<sup>−</sup>
(<italic>i</italic>
)) as in Algorithm 2.</p>
<p><bold>Algorithm 1</bold>
Compute arbitrary <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) from previous stored value<disp-formula><graphic xlink:href="1471-2105-14-313-i39.gif"></graphic>
</disp-formula>
</p>
<p>An alternative is to start at <italic>ρ</italic>
(<italic>a</italic>
,<italic>ι</italic>
<sup>+</sup>
(<italic>i</italic>
)) and subtract contributions from vertex groups prior to this position, which can be done with a similar algorithm (see Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
). To speed up the procedure, one may identify the nearest stored value, either previous or later, and use whichever of the two algorithms is appropriate. This will on average double the speed, and is done in the Java implementation.</p>
</sec>
<sec><title>Find all vertices with a particular prefix</title>
<p>The functions <italic>α</italic>
(<italic>x</italic>
) and <italic>β</italic>
(<italic>x</italic>
) for strings <italic>x</italic>
with length |<italic>x</italic>
|<<italic>k</italic>
are both naturally expressed in terms of the the function <italic>γ</italic>
. We note that <italic>γ</italic>
gets called either as <italic>γ</italic>
(<italic>x</italic>
) = <italic>γ</italic>
(<italic>x</italic>
<italic>$</italic>
) or as <italic>γ</italic>
(<italic>x</italic>
<italic>∞</italic>
), and so we can express these as <italic>γ</italic>
(<italic>x</italic>
)=<italic>γ</italic>
(<italic>x</italic>
<italic>$</italic>
) = <italic>γ</italic>
(<italic>x</italic>
,0) and <italic>γ</italic>
(<italic>x</italic>
<italic>∞</italic>
) = <italic>γ</italic>
(<italic>x</italic>
,<italic>n</italic>
) where <italic>γ</italic>
(<italic>a</italic>
<italic>x</italic>
,<italic>i</italic>
)=<italic>ρ</italic>
(<italic>a</italic>
,<italic>γ</italic>
(<italic>x</italic>
,<italic>i</italic>
)) and for <italic>x</italic>
= <italic>ε</italic>
the empty string <italic>γ</italic>
(<italic>ε</italic>
,<italic>i</italic>
)=<italic>i</italic>
. Algorithm 2 details the computations.</p>
<p><bold>Algorithm 2</bold>
Algorithm for computing <italic>γ</italic>
(<italic>x</italic>
,<italic>i</italic>
): then, <italic>α</italic>
(<italic>x</italic>
)=<italic>γ</italic>
(<italic>x</italic>
)=<italic>γ</italic>
(<italic>x</italic>
,0) and <italic>β</italic>
(<italic>x</italic>
)=<italic>γ</italic>
(<italic>x</italic>
<italic>∞</italic>
)=<italic>γ</italic>
(<italic>x</italic>
,<italic>n</italic>
)<disp-formula><graphic xlink:href="1471-2105-14-313-i40.gif"></graphic>
</disp-formula>
</p>
<p>By combining the call to <italic>α</italic>
(<italic>x</italic>
) and <italic>β</italic>
(<italic>x</italic>
) into one function (Algorithm 3), it is possible to exploit the fact that when the interval is empty the two computations become identical. The return value [ <italic>α</italic>
(<italic>x</italic>
),<italic>β</italic>
(<italic>x</italic>
)〉 represents the interval <italic>α</italic>
(<italic>x</italic>
),…,<italic>β</italic>
(<italic>x</italic>
)−1, and may be represented by a pair (<italic>α</italic>
,<italic>β</italic>
). If <italic>α</italic>
(<italic>x</italic>
)=<italic>β</italic>
(<italic>x</italic>
), the interval is empty: the function could be modified to abort once it is clear that the resulting interval will be empty, or at least reduce computations by half once it is clear that <italic>α</italic>
(<italic>x</italic>
)=<italic>β</italic>
(<italic>x</italic>
).</p>
<p><bold>Algorithm 3</bold>
Compute [<italic>α</italic>
(<italic>x</italic>
),<italic>β</italic>
(<italic>x</italic>
)〉<disp-formula><graphic xlink:href="1471-2105-14-313-i41.gif"></graphic>
</disp-formula>
</p>
<p>When merging two kFM-indexes, [ <italic>α</italic>
(<italic>x</italic>
),<italic>β</italic>
(<italic>x</italic>
)〉 is computed numerous times on one kFM-index with <italic>x</italic>
being vertices (or vertex prefixes) from the other kFM-index. When the result maps a vertex in one to an vertex in the other kFM-index, the two are merged; when a vertex <italic>v</italic>
is mapped to an empty interval in the other kFM-index, the position <italic>α</italic>
(<italic>v</italic>
)=<italic>β</italic>
(<italic>v</italic>
) tells the merge procedure into which position it should be merged.</p>
</sec>
<sec><title>Backtracking through the de Bruijn subgraph</title>
<p>For a string <italic>x</italic>
of length |<italic>x</italic>
|=<italic>l</italic>
≥<italic>k</italic>
, walking the de Bruijn subgraph path corresponding to <italic>x</italic>
is most easily done by starting at the end of <italic>x</italic>
and backtracking the graph towards the start of <italic>x</italic>
. Algorithm 4 provides the algorithm for doing this: it will start at the <italic>k</italic>
−1-suffix <italic>x</italic>
<sub>[<italic>l</italic>
−<italic>k</italic>
+2,<italic>l</italic>
]</sub>
and backtrack one step at a time, exiting if the string leaves the graph.</p>
<p><bold>Algorithm 4</bold>
Backtrack the de Bruijn subgraph for a string <italic>x</italic>
≥ <italic>k</italic>
<disp-formula><graphic xlink:href="1471-2105-14-313-i42.gif"></graphic>
</disp-formula>
</p>
</sec>
<sec><title>Identifying the string value of a vertex</title>
<p>If we start with a vertex identified by its position <italic>i</italic>
, we can determine the string that vertex represents. In order to do so, we need a function <italic>ρ</italic>
<sup>inv</sup>
:{0,…,<italic>n</italic>
−1}→Σ×{0,…,<italic>n</italic>
−1} which has the property that</p>
<p><disp-formula id="bmcM12"><label>(12)</label>
<mml:math id="M34" name="1471-2105-14-313-i43" overflow="scroll"><mml:msup><mml:mrow><mml:mi>ρ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>inv</mml:mtext>
</mml:mrow>
</mml:msup>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>j</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mspace width="2.77626pt"></mml:mspace>
<mml:mo>⇔</mml:mo>
<mml:mspace width="2.77626pt"></mml:mspace>
<mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>j</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>ρ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>a</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>j</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:math>
</disp-formula>
</p>
<p>and where <italic>ρ</italic>
<sup>inv</sup>
(0)=(<italic>$</italic>
,0). The pair (<italic>a</italic>
,<italic>j</italic>
) can be found through a binary search. However, since the computation of <italic>ρ</italic>
is done in a stepwise manner starting at one of the stored values, a binary search should be performed on the stored values to identify the interval that contains the solution, and the stepwise procedure then followed until the solution is found.</p>
<p>The interpretation of <italic>ρ</italic>
<sup>inv</sup>
(<italic>i</italic>
)=(<italic>a</italic>
,<italic>j</italic>
) is that <italic>a</italic>
is the first letter of <italic>v</italic>
<sub><italic>i</italic>
</sub>
, while <italic>j</italic>
is the last vertex in the vertex group with <italic>k</italic>
−2-prefix equal to the <italic>k</italic>
−2-suffix of <italic>v</italic>
<sub><italic>i</italic>
</sub>
: i.e. there is an edge from <italic>v</italic>
<sub><italic>i</italic>
</sub>
to a vertex in the same vertex group as <italic>v</italic>
<sub><italic>j</italic>
</sub>
. However, since the vertices in the same vertex group only differ by the last letter, and we don’t have to determine this letter, we do not have to determine which vertex (or vertices) in this vertex group has an edge from <italic>v</italic>
<sub><italic>i</italic>
</sub>
. By iterating this procedure <italic>k</italic>
−1 times as in Algorithm 5, we can find the string <italic>v</italic>
<sub><italic>i</italic>
</sub>
.</p>
<p><bold>Algorithm 5</bold>
Return string <italic>v</italic>
<sub><italic>i</italic>
</sub>
for position <italic>i</italic>
<disp-formula><graphic xlink:href="1471-2105-14-313-i44.gif"></graphic>
</disp-formula>
</p>
</sec>
</sec>
<sec><title>Generating the kFM-index from a set of strings</title>
<p>The simplest way to generate the main data, i.e. the in-edge list and vertex group end flags, from a set of strings, is to generate the set of all <italic>k</italic>
-substrings, including the final-completing strings with one or more more <italic>$</italic>
attached at the end, sort and group them by their <italic>k</italic>
−1-suffix, and then generate the in-edge list and group end flags directly from this. Once the main data, i.e. the binary arrays <italic>η</italic>
and <italic>f</italic>
<sub><italic>i</italic>
</sub>
representing the edge set <italic>E</italic>
and the group end flags, have been generated, the auxiliary data can be generated from these.</p>
<p>This brute force approach requires a fair amount of memory since all <italic>k</italic>
letters need to be stored for all <italic>k</italic>
-substrings. The list of <italic>k</italic>
-substrings thus takes up <italic>k</italic>
times as much memory than the original strings from which they are generated, and so is only feasible when the original string data is moderate in size.</p>
<p>If the string data is large, so that not all <italic>k</italic>
-substrings of <inline-formula><mml:math id="M35" name="1471-2105-14-313-i45" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
can be kept in memory, the job may be split up. The set <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i46.gif"></inline-graphic>
</inline-formula>
of strings may be split up into smaller subsets, the kFM-index generated for each subset, and pairwise merging of kFM-indexes may then be performed to combine the subset based indexes into a kFM-index for the whole set.</p>
<p>Note that this procedure will generate a full set of final-completing vertices, i.e. those containing <italic>$</italic>
at the end, even when they are not required by the kFM-index. We may reduce the kFM-index by checking which final-completing vertices are actually required in order to be able to reach the entire graph by backtracking from the final vertex. However, even if we do this for the initially generated kFM-indexes so as to ensure these contain minimal sets of final-completing vertices, when we merge the kFM-indexes for the string subsets, superfluous final-completing vertices may again occur when final-completing vertices required in one kFM-index are rendered superfluous by the edges of the other kFM-index. Hence, we may wish to prune away these final-completing vertices at the end, or in some of the intermediary merges.</p>
<sec><title>Merging two kFM-indexes</title>
<p>If we have two kFM-indexes denoted <italic>A</italic>
and <italic>B</italic>
, one with <italic>n</italic>
<sub><italic>A</italic>
</sub>
elements and the other with <italic>n</italic>
<sub><italic>B</italic>
</sub>
elements, these can be merged in two steps. First, we merge the two lists into a list of length <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
. In the process of merging the two lists, rows representing the same vertex are not combined, but instead we mark the occurences where one vertex merged list is identical to the next one so that these may later be combined. In addition, vertex groups found in both <italic>A</italic>
and <italic>B</italic>
must be merged into one vertex group, which involves removing the group end flag from any vertex not at the end of the merged vertex group. After that, we sequentially pass through the <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
-length merged list, combining identical vertices into one vertex.</p>
<p>Instead of generating the <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
-length list in full, which would require the same amount of memory as the two original kFM-indexes of length <italic>n</italic>
<sub><italic>A</italic>
</sub>
and <italic>n</italic>
<sub><italic>B</italic>
</sub>
, we can represent the merge by a <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
bit array indicating which of the two lists go into each position. Another bit array is used to mark identical vertices, which only needs <italic>n</italic>
<sub><italic>A</italic>
</sub>
bit since we only need to store which vertices in <italic>A</italic>
are also found in <italic>B</italic>
. Finally, we use an <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
bit array to mark vertices in the merged list that should not keep whatever group end flag it might have: this is required for vertex groups found in both <italic>A</italic>
and <italic>B</italic>
to ensure that only the final vertex in the group retains it group end flag.</p>
<p><bold>Algorithm 6</bold>
Merge two kFM-indices<disp-formula><graphic xlink:href="1471-2105-14-313-i47.gif"></graphic>
</disp-formula>
</p>
<p>It is sufficient to find the positions in the <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
-list of the <italic>n</italic>
<sub><italic>A</italic>
</sub>
vertices from the kFM-index <italic>A</italic>
. We may assume <italic>n</italic>
<sub><italic>A</italic>
</sub>
≤<italic>n</italic>
<sub><italic>B</italic>
</sub>
since that will require only <italic>n</italic>
<sub><italic>A</italic>
</sub>
lookups; the <italic>n</italic>
<sub><italic>B</italic>
</sub>
vertices from the kFM-index <italic>B</italic>
will then be in the remaining positions. To do this, for all items <italic>i</italic>
= 0,…,<italic>n</italic>
<sub><italic>A</italic>
</sub>
−1 in the <italic>A</italic>
list, compute the string <inline-formula><mml:math id="M36" name="1471-2105-14-313-i48" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
</mml:math>
</inline-formula>
of that vertex. We then look up the position of <inline-formula><mml:math id="M37" name="1471-2105-14-313-i49" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
</mml:math>
</inline-formula>
in the kFM-index <italic>B</italic>
by computing <inline-formula><mml:math id="M38" name="1471-2105-14-313-i50" overflow="scroll"><mml:mo>[</mml:mo>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>,</mml:mo>
<mml:msub><mml:mrow><mml:mi>β</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>〉</mml:mo>
</mml:math>
</inline-formula>
. If the interval is empty, i.e. <inline-formula><mml:math id="M39" name="1471-2105-14-313-i51" overflow="scroll"><mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:msub><mml:mrow><mml:mi>β</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</inline-formula>
, the vertex goes into position <inline-formula><mml:math id="M40" name="1471-2105-14-313-i52" overflow="scroll"><mml:mi>i</mml:mi>
<mml:mo>+</mml:mo>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</inline-formula>
and so we mark this position as containing a vertex from <italic>A</italic>
. If the interval is not empty, the vertex <inline-formula><mml:math id="M41" name="1471-2105-14-313-i53" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
</mml:math>
</inline-formula>
is found in position <inline-formula><mml:math id="M42" name="1471-2105-14-313-i54" overflow="scroll"><mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</inline-formula>
in the <italic>B</italic>
list (and <inline-formula><mml:math id="M43" name="1471-2105-14-313-i55" overflow="scroll"><mml:msub><mml:mrow><mml:mi>β</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:math>
</inline-formula>
), and so again we mark position <inline-formula><mml:math id="M44" name="1471-2105-14-313-i56" overflow="scroll"><mml:mi>i</mml:mi>
<mml:mo>+</mml:mo>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
</mml:math>
</inline-formula>
as containing an <italic>A</italic>
vertex, while the vertex from <italic>B</italic>
takes position <inline-formula><mml:math id="M45" name="1471-2105-14-313-i57" overflow="scroll"><mml:mi>i</mml:mi>
<mml:mo>+</mml:mo>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:math>
</inline-formula>
; in addition, we mark vertex <italic>i</italic>
in the <italic>A</italic>
list as having a duplicate in the <italic>B</italic>
list.</p>
<p>We similarly need to iterate over all vertex groups in <italic>A</italic>
, i.e. all non-empty [ <italic>α</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
),<italic>β</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)〉 for <italic>u</italic>
∈ Σ<sup><italic>k</italic>
−2</sup>
. If the vertex groups [ <italic>α</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
),<italic>β</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)〉 and [ <italic>α</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
),<italic>β</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
)〉 are both non-empty, we know that the vertices in the interval [ <italic>α</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)+<italic>α</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
),<italic>β</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)+<italic>β</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
)〉 correspond to the <italic>u</italic>
vertex group in the preliminary merged list. The last vertex, i.e. the one in position <italic>β</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)+<italic>β</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
)−1, will have its group end flag set from either list <italic>A</italic>
or <italic>B</italic>
. However, there will be another vertex with its group end flag set from the other list which may be in any of the other positions in the interval, and to ensure that this is unflagged, we mark positions <italic>α</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)+<italic>α</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
),…,<italic>β</italic>
<sub><italic>A</italic>
</sub>
(<italic>u</italic>
)+<italic>β</italic>
<sub><italic>B</italic>
</sub>
(<italic>u</italic>
)−2 for group end flag removal.</p>
<p>Rather than process the items <italic>i</italic>
= 0,…,<italic>n</italic>
<sub><italic>A</italic>
</sub>
−1 sequentially, which requires computing VERTEX(<italic>i</italic>
) for each and then looking these up in <italic>B</italic>
, it is more efficient to recurse over all <italic>p</italic>
-mers for <italic>p</italic>
= 1,…,<italic>k</italic>
−1, each recursion adding all possible one letter prefixes. Thus, <italic>l</italic>
= 0 corresponds to vertices, <italic>l</italic>
=1 to vertex groups, [ <italic>α</italic>
,<italic>β</italic>
〉 refers to index intervals corresponding to a given <italic>p</italic>
-mer prefix in <italic>A</italic>
or <italic>B</italic>
. The function <sc>PREMERGE</sc>
performs this recursion. It is called from <sc>MERGE</sc>
where <italic>l</italic>
=<italic>k</italic>
−1−<italic>p</italic>
is the number of trailing <italic>$</italic>
.</p>
<p><bold>Algorithm 7</bold>
Prepare merge: recurse over <italic>A</italic>
intervals<disp-formula><graphic xlink:href="1471-2105-14-313-i58.gif"></graphic>
</disp-formula>
</p>
<p>Once we have the <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
bit array indicating which positions in the <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
merge comes from <italic>A</italic>
or <italic>B</italic>
, another <italic>n</italic>
<sub><italic>A</italic>
</sub>
bit array telling which vertices in <italic>A</italic>
are also found in <italic>B</italic>
, and a third <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
bit array marking vertices for group end flag removal, we can merge the two lists sequentially using <sc>PERFORMMERGE</sc>
.</p>
<p><bold>Algorithm 8</bold>
Merge subroutine: perform merge based on merge information<disp-formula><graphic xlink:href="1471-2105-14-313-i59.gif"></graphic>
</disp-formula>
</p>
<p>The three bit arrays used to facilitate the merge require 3<italic>n</italic>
<sub><italic>A</italic>
</sub>
+2<italic>n</italic>
<sub><italic>B</italic>
</sub>
bit of extra data. The merge requires <italic>n</italic>
<sub><italic>A</italic>
</sub>
lookups to find <inline-formula><mml:math id="M46" name="1471-2105-14-313-i60" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
</mml:math>
</inline-formula>
and then <inline-formula><mml:math id="M47" name="1471-2105-14-313-i61" overflow="scroll"><mml:mo>[</mml:mo>
<mml:mspace width="0.3em"></mml:mspace>
<mml:msub><mml:mrow><mml:mi>α</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>,</mml:mo>
<mml:msub><mml:mrow><mml:mi>β</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>B</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo stretchy="false">(</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>A</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>〉</mml:mo>
</mml:math>
</inline-formula>
followed by the copying of all <italic>n</italic>
<sub><italic>A</italic>
</sub>
+<italic>n</italic>
<sub><italic>B</italic>
</sub>
elements combining them into one when they represent the same vertex. In addition, the creation of the target list requires a temporary duplication of all the vertex and edge data, but this could be avoided by using a data structure in which the merged list is being created gradually as needed while memory used by <italic>A</italic>
and <italic>B</italic>
is gradually released as they are being merged. The Java implementation provided does this.</p>
</sec>
<sec><title>Pruning away superfluous final-completing vertices</title>
<p>The removal of superfluous final-completing vertices, i.e. vertices ending with one or more <italic>$</italic>
characters that are not required in order to avoid final vertices that have no out-edge, can be done by a few simple rules. We can perform these checks by a recursive approach, exploiting that the final-completing vertices form a tree with the final vertex, <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
, as the root. We start at the final vertex, which is in position 0 of the kFM-index, and recursively backtrack through all in-edges at most <italic>k</italic>
−2 steps to reach all final-completing vertices in <italic>V</italic>
, performing the tests depth-first. We then identify edges and vertices that can be removed. After all final-completing vertices have been processed in this manner, we condense the list by removing the superfluous edges and vertices from the list.</p>
<p><bold>Algorithm 9</bold>
Prune the index of unneeded final-completing vertices<disp-formula><graphic xlink:href="1471-2105-14-313-i62.gif"></graphic>
</disp-formula>
</p>
<p>If <italic>v</italic>
∈ <italic>V</italic>
is a final-completing vertex, it is superfluous and can be removed if it has no in-edges. By having no in-edges, I include cases where the in-edges from vertices marked for exclusion have been removed: this is the reason why the tests must be done depth-first. Since <italic>ρ</italic>
depends on which in-edges exist in each vertex group, superfluous in-edges can be removed immediately only for final-completing vertices where there is another vertex in the same vertex group with an in-edge from the same vertex (i.e. the same in-edge prefix). In general, edges and vertices must be marked for removal while the final-completing vertices are checked, and only removed after the checking is finished.</p>
<p>If <italic>v</italic>
= <italic>u</italic>
<italic>$</italic>
∈ <italic>V</italic>
is a final-completing vertex ending with a single <italic>$</italic>
and <italic>e</italic>
= <italic>a</italic>
<italic>v</italic>
is an in-edge to <italic>v</italic>
for some <italic>a</italic>
∈ Σ, the edge <italic>av</italic>
can be removed if there is an <italic>a</italic>
-in-edge to another vertex in the same vertex group as <italic>v</italic>
: i.e. if there is another vertex <italic>u</italic>
<italic>b</italic>
∈ <italic>V</italic>
which has an in-edge <italic>a</italic>
<italic>u</italic>
<italic>b</italic>
∈ <italic>E</italic>
, the in-edge <italic>a</italic>
<italic>v</italic>
=<italic>a</italic>
<italic>u</italic>
<italic>$</italic>
can be removed from the in-edges to <italic>v</italic>
. The edge <italic>a</italic>
<italic>u</italic>
<italic>$</italic>
is superfluous since <italic>au</italic>
can be reached by backtracking from <italic>ub</italic>
. If all in-edges to <italic>v</italic>
can be removed by this rule, the previous rule then allows <italic>v</italic>
to be removed.</p>
<p><bold>Algorithm 10</bold>
Prune recursal from vertex <italic>i</italic>
ending in <italic>$</italic>
<sup><italic>l</italic>
</sup>
, return <italic>true</italic>
if unneeded<disp-formula><graphic xlink:href="1471-2105-14-313-i63.gif"></graphic>
</disp-formula>
</p>
<p>The pruning away of superfluous final-completing vertices is not required for the kFM-index to work, but it can reduce the memory required in cases where the number of such vertices is big. As such, depending on the number of final-completing vertices at any point of the processing or merging of kFM-indexes, one may choose to perform this pruning at the end or at some of the intermediary merges.</p>
</sec>
</sec>
<sec><title>Pre-assembly</title>
<p>As a first step of sequence assembly, and a good task for assessing both the resulting de Bruijn subgraph and the efficiency of its use, uniquely determined paths of the graph are determined. This consists of two steps. First, the list of vertices are checked to identify all vertices that have in-degree or out-degree different from one:an algorithm is provided in the Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
. The remaining vertices are simple, non-branching vertices that paths just pass through. Iterating over all branching/ending vertices, all possible paths passing through degree-one vertices are generated. When generating the sequence corresponding to a path, the sequence of the last vertex of the path needs to be found using Algorithm 5, while the rest is determined when backtracking through the in-edges.</p>
<p>The result is a list of non-simple vertices, and a list of all uniquely determined paths between these. An estimate of the number of such paths can be found simply from summing over the in-degrees of all branching vertices, but this may include paths consisting entirely of final-completing vertices. When generating the list of uniquely determined paths, those containing only final-completing vertices are excluded.</p>
</sec>
</sec>
<sec sec-type="results"><title>Results</title>
<sec><title>Memory usage</title>
<p>The main data kept in memory is the <italic>σ</italic>
×<italic>n</italic>
binary array <italic>η</italic>
(<italic>a</italic>
,<italic>i</italic>
) and the binary flags <italic>f</italic>
<sub><italic>i</italic>
</sub>
for marking the end of each vertex group. Direct storage of these in bit-packed arrays requires <italic>σ</italic>
+1 bit of information per node, so the total memory for storing the in-edge list and vertex group flags is</p>
<p><disp-formula id="bmcM13"><label>(13)</label>
<mml:math id="M48" name="1471-2105-14-313-i64" overflow="scroll"><mml:mi mathvariant="fraktur">M</mml:mi>
<mml:mi mathvariant="fraktur">e</mml:mi>
<mml:mi mathvariant="fraktur">m</mml:mi>
<mml:mfenced close="]" open="["><mml:mrow><mml:mi>E</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>f</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mo>=</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>×</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>σ</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo stretchy="false">)</mml:mo>
<mml:mtext>bit</mml:mtext>
<mml:mi>.</mml:mi>
</mml:math>
</disp-formula>
</p>
<p>For efficient computation of the previous vertex position <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
), a subset <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
<sub><italic>r</italic>
</sub>
) is permanently stored for positions 0=<italic>i</italic>
<sub>0</sub>
<⋯<<italic>i</italic>
<sub><italic>ζ</italic>
</sub>
=<italic>n</italic>
. Direct storage of <italic>κ</italic>
(<italic>ζ</italic>
<italic>a</italic>
+<italic>r</italic>
)=<italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
<sub><italic>r</italic>
</sub>
), where <italic>a</italic>
=0,…,<italic>σ</italic>
−1 represents the letters, would require <italic>σ</italic>
<italic>ζ</italic>
lg <italic>n</italic>
bit since each position requires lg <italic>n</italic>
bit. However, decomposing <italic>κ</italic>
(<italic>j</italic>
)=<italic>u</italic>
<sub><italic>j</italic>
</sub>
+<italic>qU</italic>
<sub><italic>j</italic>
</sub>
where <italic>i</italic>
<sub><italic>r</italic>
</sub>
−<italic>i</italic>
<sub><italic>r</italic>
−1</sub>
≤<italic>q</italic>
, and storing the <italic>u</italic>
<sub><italic>i</italic>
</sub>
and <italic>Δ</italic>
<italic>U</italic>
<sub><italic>j</italic>
</sub>
=<italic>U</italic>
<sub><italic>j</italic>
</sub>
−<italic>U</italic>
<sub><italic>j</italic>
−1</sub>
∈{0,1}, requires only lg<italic>q</italic>
+1 bit for each value in <italic>κ</italic>
: i.e. <italic>σ</italic>
<italic>ζ</italic>
(lg<italic>q</italic>
+1) bit where <italic>ζ</italic>
≈<italic>n</italic>
/<italic>q</italic>
if the <italic>i</italic>
<sub><italic>r</italic>
</sub>
are evenly spaced.</p>
<p>In order to efficiently compute arbitrary <italic>U</italic>
<sub><italic>j</italic>
</sub>
, the Java implementation stores <italic>U</italic>
<sub>64<italic>r</italic>
</sub>
. Since each of these values require lg(<italic>n</italic>
/<italic>q</italic>
) bit of memory, the total memory requirement for storing the in-edge list, vertex group flags, and the data used to compute the previous vertex position, is</p>
<p><disp-formula id="bmcM14"><label>(14)</label>
<mml:math id="M49" name="1471-2105-14-313-i65" overflow="scroll"><mml:mi mathvariant="fraktur">M</mml:mi>
<mml:mi mathvariant="fraktur">e</mml:mi>
<mml:mi mathvariant="fraktur">m</mml:mi>
<mml:mfenced close="]" open="["><mml:mrow><mml:msub><mml:mrow><mml:mi>ρ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>store</mml:mtext>
</mml:mrow>
</mml:msub>
</mml:mrow>
</mml:mfenced>
<mml:mo>≈</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>nσ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>q</mml:mi>
</mml:mrow>
</mml:mfrac>
<mml:mfenced close=")" open="("><mml:mrow><mml:mo>lg</mml:mo>
<mml:mi>q</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>+</mml:mo>
<mml:mfrac><mml:mrow><mml:mo>lg</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>/</mml:mo>
<mml:mi>q</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mn>64</mml:mn>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:mfenced>
<mml:mtext>bit</mml:mtext>
<mml:mi>.</mml:mi>
</mml:math>
</disp-formula>
</p>
<p>The memory saving construction used to compress <italic>κ</italic>
could be repeated for the stored values <inline-formula><mml:math id="M50" name="1471-2105-14-313-i66" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>κ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>′</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mo>=</mml:mo>
<mml:msub><mml:mrow><mml:mi>U</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>ωr</mml:mi>
</mml:mrow>
</mml:msub>
</mml:math>
</inline-formula>
by writing this as <inline-formula><mml:math id="M51" name="1471-2105-14-313-i67" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi>κ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>′</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mo>=</mml:mo>
<mml:msubsup><mml:mrow><mml:mi>u</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>′</mml:mo>
</mml:mrow>
</mml:msubsup>
<mml:mo>+</mml:mo>
<mml:mn>64</mml:mn>
<mml:msubsup><mml:mrow><mml:mi>U</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>r</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>′</mml:mo>
</mml:mrow>
</mml:msubsup>
</mml:math>
</inline-formula>
, but at an additional computational cost. However, for most practical cases, the term lg(<italic>n</italic>
/<italic>q</italic>
)/64 is already a very minor part of the memory cost and not worth the computational overhead. By the time <italic>n</italic>
>2<sup>64</sup>
becomes an issue, we have probably moved beyond 64 bit computers, in which case increasing the block size of 64 to the higher word size <italic>ω</italic>
changes the memory term to lg(<italic>n</italic>
/<italic>q</italic>
)/<italic>ω</italic>
without increasing the computational time.</p>
<p>Under the assumption that <italic>n</italic>
<2<sup><italic>ω</italic>
</sup>
, where <italic>ω</italic>
=64 is the word size of a 64 bit computer, the total memory requirement is</p>
<p><disp-formula id="bmcM15"><label>(15)</label>
<mml:math id="M52" name="1471-2105-14-313-i68" overflow="scroll"><mml:mi mathvariant="fraktur">M</mml:mi>
<mml:mi mathvariant="fraktur">e</mml:mi>
<mml:mi mathvariant="fraktur">m</mml:mi>
<mml:mfenced close="]" open="["><mml:mrow><mml:mi>E</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>f</mml:mi>
<mml:mo>,</mml:mo>
<mml:mi>ρ</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mo><</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>×</mml:mo>
<mml:mfenced close="]" open="["><mml:mrow><mml:mi>σ</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>+</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>σ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mo>lg</mml:mo>
<mml:mi>q</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>2</mml:mn>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>q</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:mfenced>
<mml:mtext>bit</mml:mtext>
</mml:math>
</disp-formula>
</p>
<p>although there may be some additional overhead depending on how the data is bit-packed into arrays.</p>
<p>For DNA, <italic>σ</italic>
=4, which requires 5 bit of data per vertex. However, storing 12 vertices packed into a single 64 bit word leaves 4 unused bits, and so it effectively consumes ≈ 5.333 bit per vertex in the present Java implementation. For stored previous vertex positions, <italic>ρ</italic>
<sub>store</sub>
, natural step sizes <italic>q</italic>
between stored values are <italic>q</italic>
=16, 32 and 64, which adds 1.5 bit, 0.875 bit and 0.5 bit of memory usage per vertex, respectively.</p>
</sec>
<sec><title>Computational speed</title>
<p>Estimates of computational speeds are based on the assumption that <italic>n</italic>
<2<sup><italic>ω</italic>
</sup>
where <italic>ω</italic>
is the word size: i.e. <italic>ω</italic>
=64 on a 64 bit computer. This means that a number in the range 0 to <italic>n</italic>
can be read from memory in one operation: for arbitrarily large <italic>n</italic>
, this would require at least (lg<italic>n</italic>
)/<italic>ω</italic>
operations. It also means single operations can operate on <italic>ω</italic>
bits at the same time, although this is largely unexploited by the implementation.</p>
<p>The central algorithm that influences most kFM-index computations is that of computing arbitrary <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
): Algorithm 2, or the extension of this provided in the Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
and implemented in the Java program. A subset of the values are stored in a compressed form and can be retrieved in constant time. If every <italic>q</italic>
th value is stored, the time required to reconstruct and arbitrary <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) will on average be of order <italic>O</italic>
(<italic>q</italic>
). However, since we will in practice select a fixed <italic>q</italic>
of moderate size, which is sufficient to keep memory costs of the auxiliary data at a low level, and a fixed computational time remains even as we let <italic>q</italic>
drop towards 1, we may consider the computation of <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) to be of constant time.</p>
<p>Algorithm 2 for computing <italic>γ</italic>
(<italic>x</italic>
,<italic>i</italic>
) for any string <italic>x</italic>
requires |<italic>x</italic>
| calls to <italic>ρ</italic>
, and thus has time complexity <italic>O</italic>
(|<italic>x</italic>
|). Consequently, identifying the interval of vertices with prefix <italic>x</italic>
(Algorithm 3) has time complexity <italic>O</italic>
(|<italic>x</italic>
|). Algorithm 4 for backtracking the graph from vertex <italic>i</italic>
along edges provided by the string <italic>x</italic>
is essentially the same as the computation of <italic>γ</italic>
, just with checks that the edges exist, and also has time complexity <italic>O</italic>
(|<italic>x</italic>
|). The reverse computation of finding the string representation of a given vertex index, provided in Algorithm 5, requires solving for <italic>ρ</italic>
<sup>inv</sup>
(<italic>i</italic>
) using a binary search, and is thus of time complexity <italic>O</italic>
(<italic>k</italic>
lg(<italic>n</italic>
<italic>σ</italic>
)).</p>
<p>Constructing a kFM-index in memory, provided the memory is sufficient to hold a complete list of <italic>k</italic>
-mers from the strings, has time complexity <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
lg<italic>σ</italic>
lg<italic>N</italic>
) where <inline-formula><mml:math id="M53" name="1471-2105-14-313-i69" overflow="scroll"><mml:mi>N</mml:mi>
<mml:mo>=</mml:mo>
<mml:mo>∥</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>∥</mml:mo>
</mml:math>
</inline-formula>
is the total length of the string data. The time is primarily required for sorting the list of in-edges generated from the strings, while construction of the kFM-index from the sorted list is linear in <italic>N</italic>
.</p>
<p>Merging two kFM-indexes of sizes <italic>p</italic>
and <italic>q</italic>
using Algorithm 2 has worst case time complexity <italic>O</italic>
((<italic>p</italic>
+<italic>q</italic>
)<italic>k</italic>
<italic>σ</italic>
). This is due to Algorithm 7. The factor <italic>σ</italic>
stems from checking sequentially for in-edges and could most likely be replaced by something more efficient should large alphabets be of interest. There is also room for improvement, as detailed in hte Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
, e.g. by reducing the number of computations once conditions like <italic>α</italic>
<sub><italic>B</italic>
</sub>
=<italic>β</italic>
<sub><italic>B</italic>
</sub>
are met.</p>
<p>Construction of a kFM-index in memory by dividing the initial string data into <italic>m</italic>
parts, generating kFM-indexes from each, and then merging these pairwise until a single kFM-index remains, has time complexity <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
lg(<italic>n</italic>
<italic>m</italic>
)) using the present algorithms. At the lowest level, <italic>m</italic>
kFM-indexes are generated, each from sorting approximately <italic>N</italic>
/<italic>m</italic>
<italic>k</italic>
-words, which takes <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
lg<italic>σ</italic>
lg(<italic>N</italic>
/<italic>m</italic>
)) time and is generally fast. During the first roughly lg(<italic>n</italic>
<italic>m</italic>
/<italic>N</italic>
) rounds of pairwise merges, while the number of partitions is higher than the coverage, the total sizes of the kFM-indexes may still be ≈<italic>N</italic>
, and so each round requires time <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
). After that, since none of the kFM-indexes have more than <italic>n</italic>
vertices, which is the size of the final de Bruijn subgraph, the time complexity drops by a factor of two for each new round of pairwise merges until a single kFM-index remains. The main part of the computations are the first lg(<italic>n</italic>
<italic>m</italic>
/<italic>N</italic>
) or so rounds of pairwise merges, and so the final kFM-index takes <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
lg(<italic>n</italic>
<italic>m</italic>
/<italic>N</italic>
). As <italic>N</italic>
cannot increase without <italic>m</italic>
increasing in proportion, since <italic>N</italic>
/<italic>m</italic>
in-edge <italic>k</italic>
-words must be kept in memory, but <italic>m</italic>
can increase independently if less memory is to be used, it is more natural to write this <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
lg(<italic>n</italic>
<italic>m</italic>
)).</p>
</sec>
<sec><title>Benchmarking of the Java implementation</title>
<p>The Java implementation has not been optimised for speed: it runs on a single core, and prioritises memory consumption and code generality and readability over speed. However, it can still give a fair indication of the computational speeds, and indicate which are the bottlenecks.</p>
<p>The benchmarks on <italic>E. coli</italic>
and simulated data were run on Java 6 under 64 bit Windows 7 on a standard office laptop: Dell Latitude E6320 with Intel Core i7-2620 2.70 GHz CPU and 8 GiB RAM. For <italic>C. elegans</italic>
and the soil sample, it was run on a server with more memory and roughly twice the computational speed. The amount of RAM available to Java was set with the option <monospace>-Xmx</monospace>
. Note that for specifying computer memory, I use IEC prefixes ki-, Mi-, and Gi- which represent powers of 1024, while SI prefixes k-, M-, and G- represent powers of 1000.</p>
<p>All kFM-index constructions from read data added both reads and their reverse complements, discarding pairing information. Quality filtering consisted of removing bases with quality score less than 30, splitting the reads into fragments with higher quality bases. Unless otherwise stated, <italic>k</italic>
=23 were used: note that the Java implementation specifies the order <italic>k</italic>
−1, i.e. length of the vertex strings. The distance between stored values <italic>ρ</italic>
<sub>store</sub>
was <italic>q</italic>
=32. This should require 6.2 bit per vertex as the actual memory usage on the data, including 0.33 bit due to the 4 unused bits in the pack of 12 vertices stored in a 64 bit Java long integer, although there would be some additional memory overhead from the program itself.</p>
<p>Memory usage during kFM-index construction was largely determined by the size of partitions, i.e. the maximal number of <italic>k</italic>
-mers processed in each partition, which was set to different values to assess the time required to generate kFM-indexes by merging smaller indexes. For runs on the laptop, it was set to process at most 250 M words in each partition, which for <italic>k</italic>
≤28 would require 2 GiB of memory with each word using 2×32 bit integers; on the server, the partition size was limited by implementation of the buffer as a Java array with at most 2 G 32 bit values, allowing at most 1 G words in each partition when <italic>k</italic>
≤28. However, the peak memory usage reported here includes memory used and released by Java, but not yet garbage collected, and may reflect available memory more than actual use.</p>
<sec><title><italic>E. coli</italic>
str. K-12 substr. MG1655</title>
<p>The implementation was evaluated on <italic>E. coli</italic>
str. K-12 substr. MG1655 (SRA accession SRX000429, SRR001665, <ext-link ext-link-type="uri" xlink:href="http://www.ncbi.nlm.nih.gov/sra/SRX000429">http://www.ncbi.nlm.nih.gov/sra/SRX000429</ext-link>
) with 21 M 36 nt reads after discarding pairing information.</p>
<p>The quality filtered graph contained 13.4 M vertices and 13.4 M edges. This was processed in 2 parts and then merged, taking 7.7 minutes, with roughly a fifth of the time spent on merging kFM-indexes. Without quality filtering, the graph contained 81.7 M vertices and 83.7 M edges. For kFM-index construction, this was divided in 5 parts, which were then merged, taking 38 minutes, half of which was spent on merging the kFM-indexes together.</p>
<p>Once the final kFM-indexes had been constructed and the temporary memory freed up, the Java program used 18 MiB holding the quality filtered graph, and 69 MiB holding the unfiltered graph. At startup, before adding data, the Java program used 6–10 MiB of memory.</p>
<p>When given access to 6 GiB of RAM, the peak usage was a bit over 3 GiB. However, by reducing the available memory, peak usage could be reduced to just over 2 GiB, with no substantial change in computational time. The difference is due to memory that has been used and released, but not garbage collected. The main limitation was Java’s ability to allocate the approximately 2 GiB block required to collect and sort in-edges for kFM-index construction.</p>
<p>In the quality filtered graph, 96.3% of the vertices were simple, i.e. had in- and out-degree one. Pre-assembly took 12.9 seconds and produced 427 k uniquely determined paths. In the unfiltered graph, only 89.9% of the vertices were simple, and as a consequence it produced 8.3 M uniquely determined paths using 227 seconds.</p>
</sec>
<sec><title>Simulated read data</title>
<p>Simulated sequence data were generated from two 1 Mnt DNA sequences, which were identical random sequences except from 0.1% random differences, intended to simulate a diploid organism with SNPs. Random 300 k 100 nt reads were generated with error rates 0%, 0.1%, and 1%, intended to represent the true sequences, reads with partial error correction, and raw reads at 30 times coverage.</p>
<p>The reads with no errors resulted in a graph with 2.05 M vertices and 2.05 M edges. This corresponds to 2×1 Mnt plus 22 extra vertices from each strand of the 0.1% SNPs. Accordingly, pre-assembly produced 6358 uniquely determined paths, which corresponds to the sequence between the SNPs and two variants for each SNP.</p>
<p>When the reads were given 0.1% error rate, which may be a realistic error rate after mild error correction, the graph size increased to 3.26 M vertices and 3.31 M edges. Pre-assembly resulted in 153 k uniquely determined paths</p>
<p>Including the full 1% read errors, as is common in uncorrected reads, the size increased to 15.7 M vertices and 16.1 M edges. Pre-assembly resulted in 1.37 M uniquely determined paths.</p>
<p>The time for constructing the kFM-index was 47, 49, and 64 seconds, respectively, for the three cases when enough memory was allocated to process all the data in one part. When the reads were spilt in 6 partitions and then merged, this time increased to 109, 139, and 327 seconds, respectively. The pre-assembly time was proportional to the size of the graph, and was 0.64, 3.7, and 35 seconds, respectively.</p>
</sec>
<sec><title><italic>C. elegans</italic>
str. N2</title>
<p>A kFM-index was generated from 67.6 M 100 nt reads on <italic>C. elegans</italic>
str. N2 (SRA accession <ext-link ext-link-type="uri" xlink:href="http://www.ncbi.nlm.nih.gov/sra/SRX026594">SRX02594, SRR065390</ext-link>
).</p>
<p>With <italic>k</italic>
= 23, this resulted in a graph with 255 M vertices and 259 M edges. With reads processed in 8 parts and merged, this took 5.4 hours on the server. Pre-assembly took 7.3 minutes and resulted in 12.8 M uniquely determined paths.</p>
<p>After completion of the kFM-index, the program holding the index used 290 MiB, some of which is unreleased memory after pruning away 61 M final-completing vertices at the end. The buffer used to store each of the 8 partitions took 8 GiB, while peak memory usage was 12 GiB.</p>
</sec>
<sec><title>Soil sample</title>
<p>An additional run was made on a soil sample (SRA accession SRX128885, SRR444039, <ext-link ext-link-type="uri" xlink:href="http://www.ncbi.nlm.nih.gov/sra/SRX128885">http://www.ncbi.nlm.nih.gov/sra/SRX128885</ext-link>
) with 37 M 76 nt reads.</p>
<p>Quality filtering left 2.59 G 23-mers to be processed, including the reverse complements. The resulting graph consisted of 2.86 G vertices and 2.87 G edges: the increase relative to the number of words added is due to final-completing vertices which represent read suffixes. This took 7.1 hours to generate, processing the data in 4 partitions before merging them. Most of this time was spent merging the kFM-indexes.</p>
<p>After completion, the program only occupied 2.2 GiB of memory, i.e. 6.6 bit per vertex including all overhead, indicating approximately 6% memory overhead relative to the 6.2 bit per vertex required by the data structure. During kFM-index construction, peak memory usage was 14 GiB.</p>
<p>Pre-assembly took 1.08 hours and resulted in 85.6 M uniquely determined paths. These appeared to be mostly from single reads.</p>
</sec>
</sec>
</sec>
<sec sec-type="discussion"><title>Discussion</title>
<sec><title>Memory requirements</title>
<p>The memory required to store <inline-formula><mml:math id="M54" name="1471-2105-14-313-i70" overflow="scroll"><mml:mi>E</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
as a list of strings would be |<italic>E</italic>
|×<italic>k</italic>
lg<italic>σ</italic>
bit. If the edge set had been an arbitrary subset <italic>E</italic>
⊂Σ<sup><italic>k</italic>
</sup>
, optimal storage would require</p>
<p><disp-formula id="bmcM16"><label>(16)</label>
<mml:math id="M55" name="1471-2105-14-313-i71" overflow="scroll"><mml:mtable columnalign="left"><mml:mtr><mml:mtd><mml:mi mathvariant="fraktur">M</mml:mi>
<mml:mi mathvariant="fraktur">e</mml:mi>
<mml:mi mathvariant="fraktur">m</mml:mi>
<mml:mfenced close="]" open="["><mml:mrow><mml:mi>E</mml:mi>
<mml:mo>⊂</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="normal">Σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
</mml:mrow>
</mml:msup>
</mml:mrow>
</mml:mfenced>
<mml:mo>=</mml:mo>
<mml:mo>lg</mml:mo>
<mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:msup><mml:mrow><mml:mi>σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>k</mml:mi>
</mml:mrow>
</mml:msup>
</mml:mrow>
<mml:mrow><mml:mo>|</mml:mo>
<mml:mi>E</mml:mi>
<mml:mo>|</mml:mo>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:mtext>bit</mml:mtext>
</mml:mtd>
</mml:mtr>
<mml:mtr><mml:mtd><mml:mspace width="7.3em"></mml:mspace>
<mml:mo>≈</mml:mo>
<mml:mo>|</mml:mo>
<mml:mi>E</mml:mi>
<mml:mo>|</mml:mo>
<mml:mo>×</mml:mo>
<mml:mfenced close=")" open="("><mml:mrow><mml:mi>k</mml:mi>
<mml:mo>lg</mml:mo>
<mml:mi>σ</mml:mi>
<mml:mo>−</mml:mo>
<mml:mo>lg</mml:mo>
<mml:mfrac><mml:mrow><mml:mo>|</mml:mo>
<mml:mi>E</mml:mi>
<mml:mo>|</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>e</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mrow>
</mml:mfenced>
<mml:mtext>bit</mml:mtext>
</mml:mtd>
</mml:mtr>
</mml:mtable>
</mml:math>
</disp-formula>
</p>
<p>where the approximation assumes that <italic>E</italic>
is a sparse subset of Σ<sup><italic>k</italic>
</sup>
. This is slightly better than storing <italic>E</italic>
as a list of strings since it takes into account that the list of edges is unordered and contains each edge at most once. However, the claim that this is minimal required memory [<xref ref-type="bibr" rid="B1">1</xref>
], is not strictly true, as <inline-formula><mml:math id="M56" name="1471-2105-14-313-i72" overflow="scroll"><mml:mi>E</mml:mi>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
is not an arbitrary subset of Σ<sup><italic>k</italic>
</sup>
: it is induced by the sequences in <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i73.gif"></inline-graphic>
</inline-formula>
. If most of the strings in <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i74.gif"></inline-graphic>
</inline-formula>
are much longer than <italic>k</italic>
, this gives us ample room for reducing the memory usage.</p>
<p>Storing the sequences of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i75.gif"></inline-graphic>
</inline-formula>
, i.e. the data from which <inline-formula><mml:math id="M57" name="1471-2105-14-313-i76" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
is generated, requires</p>
<p><disp-formula id="bmcM17"><label>(17)</label>
<mml:math id="M58" name="1471-2105-14-313-i77" overflow="scroll"><mml:mi mathvariant="fraktur">M</mml:mi>
<mml:mi mathvariant="fraktur">e</mml:mi>
<mml:mi mathvariant="fraktur">m</mml:mi>
<mml:mfenced close="]" open="["><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
</mml:mfenced>
<mml:mo>=</mml:mo>
<mml:mo>∥</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>∥</mml:mo>
<mml:mo>×</mml:mo>
<mml:mo>lg</mml:mo>
<mml:mi>σ</mml:mi>
<mml:mtext>bit</mml:mtext>
</mml:math>
</disp-formula>
</p>
<p>where <inline-formula><mml:math id="M59" name="1471-2105-14-313-i78" overflow="scroll"><mml:mo>∥</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>∥</mml:mo>
<mml:mo>=</mml:mo>
<mml:msub><mml:mrow><mml:mi mathsize="big">∑</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
<mml:mo>∈</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mo>|</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>|</mml:mo>
</mml:math>
</inline-formula>
is the total length of the strings, assuming we do not have to store information about the lengths of the strings: this is true if all strings <inline-formula><mml:math id="M60" name="1471-2105-14-313-i79" overflow="scroll"><mml:mi>x</mml:mi>
<mml:mo>∈</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
</mml:math>
</inline-formula>
have the same length |<italic>x</italic>
|=<italic>l</italic>
, and a good approximation if the average length of the strings is much greater than the alphabet size.</p>
<p>If the strings of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i80.gif"></inline-graphic>
</inline-formula>
are very different, in the sense that they do not share <italic>k</italic>
-substrings to any particular extent, it will be more memory efficient to store the strings of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i81.gif"></inline-graphic>
</inline-formula>
directly than storing <inline-formula><mml:math id="M61" name="1471-2105-14-313-i82" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
, and little can be done to reduce this memory requirement. This was the case with the soil sample data analysed. In this case, the FM-index [<xref ref-type="bibr" rid="B11">11</xref>
], which is based on the Burrows–Wheeler transform, provides a compact index for representing all substrings of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i83.gif"></inline-graphic>
</inline-formula>
: the Burrows–Wheeler transform requires <inline-formula><mml:math id="M62" name="1471-2105-14-313-i84" overflow="scroll"><mml:mo>∥</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>∥</mml:mo>
<mml:mo>×</mml:mo>
<mml:mo>lg</mml:mo>
<mml:mi>σ</mml:mi>
<mml:mtext>bit</mml:mtext>
</mml:math>
</inline-formula>
, i.e. no more than the raw sequences.</p>
<p>When there is substantial overlap between the strings in <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i85.gif"></inline-graphic>
</inline-formula>
, there are more compact representations of <inline-formula><mml:math id="M63" name="1471-2105-14-313-i86" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
. For example, if the strings of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i87.gif"></inline-graphic>
</inline-formula>
can be assembled into a smaller number of strings, <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i88.gif"></inline-graphic>
</inline-formula>
’, of which the strings of <inline-formula><inline-graphic xlink:href="1471-2105-14-313-i89.gif"></inline-graphic>
</inline-formula>
are substrings, we could use these strings instead to represent <inline-formula><mml:math id="M64" name="1471-2105-14-313-i90" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
: if each <italic>k</italic>
-string in <inline-formula><mml:math id="M65" name="1471-2105-14-313-i91" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
is found on average <italic>ν</italic>
times, this would approximately reduce the required memory by a factor of <italic>ν</italic>
. However, since assembly is a difficult problem, this is not a practical approach. In addition, the strings may not assemble well, e.g. due to read sequencing errors.</p>
<p>One fairly direct way to represent a de Bruijn subgraph, without storing a complete list of all <italic>k</italic>
-mers, is to represent edges as pointers between vertices: e.g. an out-edge from a vertex may be stored as a pointer to the target vertex. Storing edges as pointers as well as the letters they correspond to requires |<italic>E</italic>
|×(lg|<italic>V</italic>
|+ lg<italic>σ</italic>
) bit of memory, which can be quite demanding for large graphs. For the 13.4 M graph representing the quality filtered <italic>E. coli</italic>
reads, this would be 25.7 bit per vertex: more than four times as much as the kFM-index.</p>
<p>If most vertices are simple, i.e. have only one in-edge and out-edge, the number of pointers required may be drastically reduced by combining them into uniquely determined paths in the graph, as is done in Velvet [<xref ref-type="bibr" rid="B12">12</xref>
]. Only one pointer would then be required for each such path, which for the quality filtered <italic>E. coli</italic>
graph would be 427 k pointers each requiring 18.7 bit, resulting in 2+0.6 bit per vertex for storing the nucleotide and the pointers. By combining vertices representing reverse complements into duplex vertices, the number of vertices and paths is halved, but pointers in both directions must be maintained, making this 2+2×0.6 bit per duplex vertex.</p>
<p>Even if merging non-branching vertices allows the graph itself to be stored more compactly, a map from arbitrary <italic>k</italic>
−1-mers to vertices of the graph is required, and storing these pointers would cost at least |<italic>V</italic>
|× lg|<italic>V</italic>
| bit of memory. A regular hash map would use additional memory to identify <italic>V</italic>
⊂Σ<sup>[<italic>k</italic>
−1]</sup>
, but that is not strictly needed and could be avoided by smart hashing schemes. Still, for the quality filtered <italic>E. coli</italic>
reads, a full map for the 13.4 M 22-mer vertices would require at least 23 bit per duplex vertex, and this would increase for larger graphs. If the 22-mers are mapped to the uniquely determined paths rather than to the individual vertices, this could be reduced to 18.7 bit per duplex vertex, which with the 3.1 bit per duplex vertex for storing the graph, still adds up to twice as much as required by the kFM-index, and would increase with the size and complexity of the graph. Many genome assemblers, such as ABySS [<xref ref-type="bibr" rid="B13">13</xref>
], hash either vertices or edges, and are thus subject to this requirement. In fact, for any data structure that does not throughout make use of the fact that the vertices and edges tend to form long paths, the memory bound of equation (16) applies.</p>
<p>A natural method to compare the kFM-index against is the compressed Burrows–Wheeler transform of the concatenated reads used by SGA [<xref ref-type="bibr" rid="B10">10</xref>
], due to the similarity between the kFM-index and the Burrows–Wheeler based FM-index. The Burrows–Wheeler transform of the reads would result in runs of identical bases corresponding to the coverage of the reads (unless broken up due to sequencing errors), and the SGA stores each run by its base and run length in a single byte. A naive comparison of memory requirements could be made against the in-edge data of the kFM-index which requires 5 bit per vertex; if most vertices have degree one, the in-edge data can be stored more compactly using only 2–3 bit per vertex since most vertices only require the base of the single in-edge to be stored. However, this is an unfair comparison since the kFM-index only stores the <italic>k</italic>
-mers for a specific <italic>k</italic>
, while the Burrows–Wheeler transform used by SGA stores all substrings, and thus allows <italic>k</italic>
-mer frequencies to be found for all <italic>k</italic>
. While the kFM-index specifically stores the de Bruijn <italic>k</italic>
-mer subgraph, SGA uses overlap-based assembly and was not made with de Bruijn graphs in mind. SGA also does frequency based read error correction.</p>
<p>Memorywise, the kFM-index is comparable to the probabilistic de Bruijn graph using a Bloom filter [<xref ref-type="bibr" rid="B5">5</xref>
], which requires approximately 4 bit of data per vertex. However, this can merge <italic>k</italic>
-mers with their reverse complements, and this reduces the memory requirement by a factor of two relative to data structures like the kFM-index which has to store both. On the other hand, the Bloom filter is probabilistic, with a risk of introducing false vertices. While it can be used for checking if an arbitrary vertiex is present in the graph, although this requires a lower error rate and thus a little more memory spent per vertex, additional information is required to actually reproduce the graph. Certain removal of false vertices as well information required to reproduce the graph can be added [<xref ref-type="bibr" rid="B6">6</xref>
], but requires more memory. In comparison, on the same <italic>E. coli</italic>
read data, Minia [<xref ref-type="bibr" rid="B6">6</xref>
] represented 4.7 M “solid” 23-mers (frequency at least 3) using 13.62+0.49 bit per duplex vertex, where each duplex vertex represents both a <italic>k</italic>
-mer and its reverse complement. The 0.49 bit were used to store the marking structure required to reconstruct the graph. As such, the amount of memory per vertex is just slightly above the kFM-index, given that kFM-index needs two vertices to represent reverse complements where Minia only needs one.</p>
<p>As can be seen, the different data structures have different strength and weaknesses. Reductions in memory consumption tends to come at the expense of accessibilty of the stored information, computational speed and simplicity. Choice of a suitable data structure for any given problem thus depends on the computational needs, and there is no single best data structure for storing <italic>k</italic>
-mer data from high throughput sequencing reads. The kFM-index is particularly made for storing the <italic>k</italic>
-mer de Bruijn subgraph representation of sequence reads in a compact manner, yet allowing efficient random access of vertices and edges.</p>
<sec><title>Further reduction in memory usage</title>
<p>The main memory usage of the kFM-index is the bit arrays <italic>η</italic>
(<italic>a</italic>
,<italic>i</italic>
) and <italic>f</italic>
<sub><italic>i</italic>
</sub>
representing the in-edges and group end flags. These contain <italic>σ</italic>
+1 binary values per vertex: 5 bit per vertex for DNA sequence data. For arbitrary de Bruijn subgraphs, little can be done to reduce this substantially.</p>
<p>De Bruijn subgraphs constructed from real sequence data will, however, tend to be dominated by vertices with exactly one in-edge and no other vertices in its vertex group. In this case, for the majority of vertices, the data could simply be summarised by one letter, <italic>a</italic>
<sub><italic>i</italic>
</sub>
∈Σ, representing the letter of the in-edge to vertex <italic>i</italic>
: i.e. <italic>E</italic>
<sub><italic>i</italic>
</sub>
={<italic>a</italic>
} and <italic>f</italic>
<sub><italic>i</italic>
</sub>
=<italic>true</italic>
. This would reduce the required memory from <italic>σ</italic>
+1 bit per vertex, and potentially towards lg(<italic>σ</italic>
) bit per vertex. The current implementation targets cases with small alphabets, like DNA which has <italic>σ</italic>
=4, and little emphasis has been placed on handling large <italic>σ</italic>
where lg(<italic>σ</italic>
) bit per vertex would make a big difference.</p>
<p>Since not all vertices can be thus represented, there would have to be some way of representing more general vertices as well, which would require both some memory overhead as well as computational overhead. For DNA sequencing reads, the conditions might be met where this approach could be useful, and could possibly reduce the memory consumption for storing the kFM-index by a factor of 2. The entropy of the vertex data, in-edge sets and group end flags, for typical kFM-indexes on DNA sequencing read data tends to be 2 to 2.5 bit per vertex, even for sequence data with read errors included.</p>
</sec>
<sec><title>Effects of read errors</title>
<p>I have not explicitly addressed to problem of read errors. Each read error may result in up to <italic>k</italic>
−1 additional vertices, one for each of the <italic>k</italic>
−1-substrings containing the read error. If the error rate or coverage is high, this may result in a substantial increase in the number of vertices. For example, if the error rate is <italic>ε</italic>
, the chance that a particular <italic>k</italic>
-word from a sequence will contain an error is approximately <italic>k</italic>
<italic>ε</italic>
. If the average coverage is <italic>γ</italic>
, this means there will tend to be <italic>γ</italic>
<italic>k</italic>
<italic>ε</italic>
incorrect vertices for each correct vertex: i.e. the number of vertices in the de Bruijn subgraph when incorrect vertices are included will be <italic>n</italic>
≈(1+<italic>γ</italic>
<italic>k</italic>
<italic>ε</italic>
)<italic>n</italic>
<sub>correct</sub>
where <italic>n</italic>
<sub>correct</sub>
is the number of correct vertices. E.g. with 1% error rate, 30 times coverage, and <italic>k</italic>
=35, this would make ten times as many incorrect vertices than correct vertices. The simulated read data illustrate this trend.</p>
<p>By also storing vertex counts, the kFM-index could be used for error correction based on <italic>k</italic>
−1-mer frequencies. However, there already exist multiple algorithms and applications for excluding infrequent <italic>k</italic>
-mers [<xref ref-type="bibr" rid="B10">10</xref>
,<xref ref-type="bibr" rid="B14">14</xref>
-<xref ref-type="bibr" rid="B18">18</xref>
]. Furthermore, much of the advantage of the kFM-index over the compressed Burrows–Wheeler transform of the concatenated reads [<xref ref-type="bibr" rid="B10">10</xref>
] is lost if the frequency count is to be stored, which is needed for error correction. Hence, the basic assumption has been that the primary usefulness of the kFM-index occurs when the majority of read errors have been removed or corrected in advance, and that error correction is more efficiently done prior to kFM-index construction.</p>
<p>The Java implementation allows filtering by base quality scores, removing bases with low reliability and splitting the sequence accordingly. On a number of benchmarking runs, this simple approach seemed to be able to remove the majority of read errors, and reduce the size of the resulting de Bruijn graph substantially. However, for genome assembly, further error correction would be required.</p>
</sec>
<sec><title>Effect of adding final-completing vertices</title>
<p>The vertices <italic>V</italic>
consist of <inline-formula><mml:math id="M66" name="1471-2105-14-313-i92" overflow="scroll"><mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
with vertices added to allow paths from <italic>V</italic>
<sub>final</sub>
to <italic>$</italic>
<sup><italic>k</italic>
−1</sup>
. There may be up to <italic>k</italic>
−1 vertices added to <italic>V</italic>
for each vertex in <italic>V</italic>
<sub>final</sub>
. However, as long as |<italic>V</italic>
<sub>final</sub>
| is small compared to <inline-formula><mml:math id="M67" name="1471-2105-14-313-i93" overflow="scroll"><mml:mo>|</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="script">S</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>[</mml:mo>
<mml:mi>k</mml:mi>
<mml:mo>−</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>]</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>|</mml:mo>
</mml:math>
</inline-formula>
, this has little impact on the memory requirements. We may note that we can always get <inline-formula><mml:math id="M68" name="1471-2105-14-313-i94" overflow="scroll"><mml:mo>|</mml:mo>
<mml:msub><mml:mrow><mml:mi>V</mml:mi>
</mml:mrow>
<mml:mrow><mml:mtext>final</mml:mtext>
</mml:mrow>
</mml:msub>
<mml:mo>|</mml:mo>
<mml:mo>≤</mml:mo>
<mml:mo>|</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>|</mml:mo>
</mml:math>
</inline-formula>
, so if the strings on average are much longer than <italic>k</italic>
letters, the contribution of <italic>V</italic>
<sub>final</sub>
is likely to be small.</p>
<p>For final-completing vertices to contribute substantially to the memory usage, there would have to be a substantial portion of read ends not found internally in other reads. This could happen for read data consisting of short reads with low coverage. It could also happen if there are frequent read errors at the flanks of the reads which are not filtered out or corrected.</p>
</sec>
</sec>
<sec><title>Computational speed</title>
<p>The central operation in most uses of the kFM-index is the computation of the in-coming vertex position, <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
). Algorithm 1 gives an implementation whose time complexity on average is <italic>O</italic>
(<italic>q</italic>
), where <italic>q</italic>
is the distance between the stored values <italic>ρ</italic>
<sub>store</sub>
.</p>
<p>The Java implementation combines algorithm 2 with a similar algorithm provided in the Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
for computing <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) from the next stored value rather than the previous one, and selects the closest stored value, effectively halving the number of steps needed. A good balance between speed and memory usage is then to use <italic>q</italic>
=32.</p>
<p>In the Java implementation, the average computational time of <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) is linear in <italic>q</italic>
as could be expected. In the benchmarking, time per call to <italic>ρ</italic>
during large kFM-index was estimated to 75.8+2.8<italic>q</italic>
ns. Although some of this is likely overhead related to the merge operations, and the numbers will depend on the computer and implementation, it does give an indication that reducing <italic>q</italic>
much below 30 is of limited use. One likely reason for this is the time required for random memory access is high, while repeated accessed to the same block of memory is fast due to caching.</p>
<p>I will treat calls to <italic>ρ</italic>
as constant time in the subsequent analyses, although the present implementation does depend on <italic>q</italic>
, under the assumption that <italic>q</italic>
will remain fixed, typically between 30 and 64, and that in this range the memory overhead of the stored values <italic>ρ</italic>
<sub>store</sub>
is moderate.</p>
<sec><title><bold>Low-level parallel computing of <italic>ρ(a,i) </italic>
using 64 bit words</bold>
</title>
<p>Algorithm 1 works by processing one bit at a time. When doing this, the average number of steps required to compute <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) is proportional to the distance, <italic>q</italic>
, between the stored values. It is, however, possible to parallell process these bit operations and thus exploit that e.g. a 64 bit processor can process a 64 bit word in one operation.</p>
<p>One such method is described in the Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
, in which the number of steps for processing one word of data is proportional to the alphabet size <italic>σ</italic>
. This method requires that the flags indicating if <italic>a</italic>
∈ <italic>E</italic>
<sub><italic>j</italic>
</sub>
for consecutive <italic>j</italic>
are stored in one word, and the same for the group end flags <italic>f</italic>
<sub><italic>j</italic>
</sub>
, so that the data for an entire interval of <italic>j</italic>
positions can be retrieved from memory in a single operation. A replacement for Algorithm 1, provided in the Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
, will then compute arbitrary <italic>ρ</italic>
(<italic>a</italic>
,<italic>i</italic>
) from one word of containing in-edge data for the letter <italic>a</italic>
and one word with group end flags, allowing a distance <italic>q</italic>
=64−<italic>σ</italic>
+1 between stored values: reducing the distance below this has no benefit.</p>
<p>The present Java implementation, however, does not use this approach.</p>
</sec>
<sec><title>Construction of the kFM-index</title>
<p>The main bottleneck at present consist of constructing the kFM-index from the strings. The provided algorithm in which the strings are partitioned into subsets, each subset converted to kFM-indices, and these kFM-indices recursively merged together, introduces substantial overhead in terms of memory and in computational time during construction.</p>
<p>In the FM-index setting, where <italic>n</italic>
=<italic>N</italic>
, a similar approach would have required time <italic>O</italic>
(<italic>n</italic>
ln<italic>n</italic>
): if we split the data into 2<sup><italic>r</italic>
</sup>
sets, each iteration merges these pairwise using time <italic>O</italic>
(<italic>n</italic>
) per round, with <italic>r</italic>
rounds required. However, for the kFM-index, in the initial steps when the sequences are partitioned, the total number of vertices may be much greater due to <italic>k</italic>
−1-words present multiple times in the reads and thus entering into a large number of the subset kFM-indexes. The time consumption may therefore increase by a factor proportional to the coverage and become of order <italic>O</italic>
(<italic>N</italic>
<italic>k</italic>
<italic>σ</italic>
lg(<italic>n</italic>
<italic>m</italic>
)) where <inline-formula><mml:math id="M69" name="1471-2105-14-313-i95" overflow="scroll"><mml:mi>N</mml:mi>
<mml:mo>=</mml:mo>
<mml:mo>∥</mml:mo>
<mml:mi mathvariant="script">S</mml:mi>
<mml:mo>∥</mml:mo>
</mml:math>
</inline-formula>
is the total size of the sequence data and <italic>m</italic>
is the number of partitions into which it is divided.</p>
<p>The algorithm for merging kFM-indexes could most likely be improved substantially, and the Java implementation provided is far from optimal: neither in terms of speed, nor in memory usage. Some minor improvements have been made in the implementation, reducing the number of calls to <italic>ρ</italic>
when certain conditions are met (see Additional file <xref ref-type="supplementary-material" rid="S1">1</xref>
for details). However, even with further improvements, the method of partitioning and pairwise merging is inherently slow.</p>
<p>The construction of the kFM-index may be split up and run on separate CPUs; even the final mergers of two kFM-indexes can be split up, e.g. into <italic>σ</italic>
<sup><italic>r</italic>
</sup>
different threads based on the first <italic>r</italic>
levels of recursion. However, if the reads have high coverage, each of the subset kFM-indexes may already contain many of the same high-coverage vertices, and thus require almost as much memory and processing power as the final kFM-index.</p>
<p>For constructing the Burrows–Wheeler transform and the FM-index, there are more efficient algorithms [<xref ref-type="bibr" rid="B19">19</xref>
,<xref ref-type="bibr" rid="B20">20</xref>
] which rely on reformulating the Burrows–Wheeler transform in terms of a shorter sequence over a larger alphabet. These do not easily generalise to the kFM-index. In particular, a <italic>k</italic>
-word in the original kFM-index may correspond to multiple different sequence locations, and these may appear as several different <italic>k</italic>
-words in the the reformulated sequences. However, I have some hope that the induced sorting approach [<xref ref-type="bibr" rid="B19">19</xref>
,<xref ref-type="bibr" rid="B21">21</xref>
] may be adapted, although perhaps not quite as successfully as for the FM-index.</p>
<p>An alternative approach to kFM-index construction in memory is to split the reads up into edges representing the <italic>k</italic>
-words of the sequences, and use the disk to help make a sorted list. A simple way to do this can be to partition the read data into parts that are small enough that the in-edge set can be stored as <italic>k</italic>
-words and sorted in memory, write each partition to disk as a single file, and then merge these files to construct the final kFM-index. While this may require substantial temporary disk space, particularly for high coverage sequence data, it will most likely be much faster than the in-memory construction of the kFM-index presently implemented. This approach could also be divided between several computers.</p>
</sec>
<sec><title>Use with large alphabets</title>
<p>The algorithms, and the Java implementation, have been written with small alphabets in mind: in particular, DNA with <italic>σ</italic>
=4. Technically, they work for general alphabets, although the Java implementation cannot at present handle alphabets with <italic>σ</italic>
> 63 since the vertex data are packed into a 64 bit word. However, the routines for merging two kFM-indexes involve iterating over the entire alphabet, adding a time factor <italic>σ</italic>
to the merge procedure. For large alphabets, one might store the in-edge data in a more compact form than a bit vector, and could identify the relevant letters without having to check them one by one.</p>
</sec>
</sec>
</sec>
<sec sec-type="conclusions"><title>Conclusions</title>
<p>The kFM-index is a data structure that stores the <italic>k</italic>
-words corresponding to the edges of a de Bruijn subgraph in a compact manner, while allowing efficient random access to vertices and edges. The data structure is made compact by avoiding the direct storage of <italic>k</italic>
-words and pointers, which often are the main memory expense for storing de Bruijn subgraphs. The vertex and edge information is stored in a direct manner with each line in the data table representing a vertex, and each bit set in the in-edge bit array representing an edge. Thus, the compactness of the kFM-index data structure does not rely on compactification of the graph or compression of the data, and additional compression of the index is feasible.</p>
<p>The presently implemented method for in-memory construction of the kFM-index is uncompetitive for large data sets. However, there are multiple ways in which this could be improved. Also, as with the FM-index used by SGA [<xref ref-type="bibr" rid="B10">10</xref>
], after the index has been constructed, the user can reuse it to try different assembly options and parameters.</p>
<p>One of the main approaches to de novo genome assembly using high throughput sequencing is to generate the de Bruijn subgraph representing the <italic>k</italic>
-mers of the reads, and multiple applications exist already for doing this. For large genomes and in meta-genomics, the memory required for representing the de Bruijn subgraph is one of the limiting factors. The kFM-index could replace existing, more memory demanding, data structures in existing genome assembly applications to allow them to process larger genomes or to run on off-the-shelf hardware where special, high-RAM computers have previously been required.</p>
</sec>
<sec><title>Availability</title>
<p>A Java implementation of the data structure and algorithms, together with additional technical documentation of the implementation, are freely available from <ext-link ext-link-type="uri" xlink:href="http://folk.uio.no/einarro/Projects/KFM-index/">http://folk.uio.no/einarro/Projects/KFM-index/</ext-link>
. Improvements to the implementation, removing memory limitations and introducing parallel processing, and updated benchmarks, are provided on this web site.</p>
</sec>
<sec><title>Appendix</title>
<sec><title>Mathematical approximations</title>
<p>Based on <bold>Stirling’s approximation</bold>
, <inline-formula><mml:math id="M70" name="1471-2105-14-313-i96" overflow="scroll"><mml:mo>ln</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>!</mml:mo>
<mml:mo>≈</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>·</mml:mo>
<mml:mo>ln</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>e</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:math>
</inline-formula>
, we can approximate binomials by</p>
<p><disp-formula id="bmcM18"><label>(18)</label>
<mml:math id="M71" name="1471-2105-14-313-i97" overflow="scroll"><mml:mo>ln</mml:mo>
<mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:mo>=</mml:mo>
<mml:mo>ln</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>n</mml:mi>
<mml:mo>⋯</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
<mml:mo>!</mml:mo>
</mml:mrow>
</mml:mfrac>
<mml:mo>≲</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>·</mml:mo>
<mml:mo>ln</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
<mml:mo>/</mml:mo>
<mml:mi>e</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:math>
</disp-formula>
</p>
<p>which is a good approximation as long as <italic>x</italic>
≪ <italic>n</italic>
. Another bound is</p>
<p><disp-formula id="bmcM19"><label>(19)</label>
<mml:math id="M72" name="1471-2105-14-313-i98" overflow="scroll"><mml:mo>ln</mml:mo>
<mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:mo>≤</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>ln</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
<mml:mo>+</mml:mo>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>ln</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
<mml:mo>≤</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>ln</mml:mo>
<mml:mn>2</mml:mn>
</mml:math>
</disp-formula>
</p>
<p>where the first inequality follows from <inline-formula><mml:math id="M73" name="1471-2105-14-313-i99" overflow="scroll"><mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:msup><mml:mrow><mml:mi>p</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:msup>
<mml:msup><mml:mrow><mml:mo stretchy="false">(</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>−</mml:mo>
<mml:mi>p</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
</mml:mrow>
</mml:msup>
<mml:mo>≤</mml:mo>
<mml:mn>1</mml:mn>
</mml:math>
</inline-formula>
upon entering <italic>p</italic>
=<italic>x</italic>
/<italic>n</italic>
, where <inline-formula><mml:math id="M74" name="1471-2105-14-313-i100" overflow="scroll"><mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:msup><mml:mrow><mml:mo stretchy="false">(</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
</mml:mfrac>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:msup>
<mml:msup><mml:mrow><mml:mo stretchy="false">(</mml:mo>
<mml:mn>1</mml:mn>
<mml:mo>−</mml:mo>
<mml:mfrac><mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
</mml:mfrac>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
</mml:mrow>
</mml:msup>
<mml:mo>≈</mml:mo>
<mml:msqrt><mml:mrow><mml:mi>n</mml:mi>
<mml:mo>/</mml:mo>
<mml:mn>2</mml:mn>
<mml:mi>πx</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>n</mml:mi>
<mml:mo>−</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
</mml:mrow>
</mml:msqrt>
</mml:math>
</inline-formula>
indicating that the inequality is fairly tight, while the second inequality follows from <inline-formula><mml:math id="M75" name="1471-2105-14-313-i101" overflow="scroll"><mml:msubsup><mml:mrow><mml:mi mathsize="big">∑</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
<mml:mo>=</mml:mo>
<mml:mn>0</mml:mn>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
</mml:msubsup>
<mml:mfenced close=")" open="("><mml:mfrac linethickness="0.0pt"><mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>x</mml:mi>
</mml:mrow>
</mml:mfrac>
</mml:mfenced>
<mml:mo>=</mml:mo>
<mml:msup><mml:mrow><mml:mn>2</mml:mn>
</mml:mrow>
<mml:mrow><mml:mi>n</mml:mi>
</mml:mrow>
</mml:msup>
</mml:math>
</inline-formula>
and is only tight for <italic>x</italic>
/<italic>n</italic>
≈1/2.</p>
</sec>
<sec><title>Proofs of results</title>
<sec><title></title>
<p><bold>Definition 1. </bold>
<italic>For a de Bruijn subgraph G</italic>
= (<italic>V</italic>
,<italic>E) as defined in equations (1) and (2), we say that a string x corresponds to a path in G if |x|≥ k and all k-substrings of x are contained in E: i.e. x = x</italic>
<sub>1</sub>
…<italic>x</italic>
<sub><italic>l</italic>
</sub>
<italic> corresponds to the path e</italic>
<sub><italic>i</italic>
</sub>
=<italic>x</italic>
<sub>[<italic>i</italic>
,<italic>i</italic>
+<italic>k</italic>
−1]</sub>
for <italic>i</italic>
=1,…,<italic>l</italic>
−<italic>k</italic>
+1.<italic> For a string x of any length, we say that x is compatible with G if either x corresponds to a path in G (for |x|≥k) or x is a substring of a vertex v ∈ V (for | x| < k). We write x ∼ G to indicate that x is compatible with G</italic>
.</p>
<p>For convenience, we will include <italic>v</italic>
<sub><italic>n</italic>
</sub>
=<italic>∞</italic>
<sup><italic>k</italic>
−1</sup>
in the vertex list, although it is strictly speaking not part of the graph, and apply the convention that <italic>∞</italic>
<sup><italic>k</italic>
</sup>
corresponds to a path in <italic>G</italic>
. The main effect of this is that the min{<italic>i</italic>
∣…} expressions below take the value <italic>n</italic>
if criteria for <italic>i</italic>
are not otherwise met.</p>
</sec>
<sec><title></title>
<p><bold>Lemma 2. </bold>
<italic>Let ρ (a,i) be defined as in equation (6) and γ as in (7). For x a string in</italic>
Σ<sup>∗</sup>
or Σ<sup>∗</sup>
∘{<italic>$</italic>
,<italic>∞</italic>
},</p>
<p><disp-formula id="bmcM20"><label>(20)</label>
<mml:math id="M76" name="1471-2105-14-313-i102" overflow="scroll"><mml:mi>γ</mml:mi>
<mml:mo stretchy="false">(</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo stretchy="false">)</mml:mo>
<mml:mo>=</mml:mo>
<mml:mo>min</mml:mo>
<mml:mo>{</mml:mo>
<mml:mi>i</mml:mi>
<mml:mo>∣</mml:mo>
<mml:mi>x</mml:mi>
<mml:mo>≤</mml:mo>
<mml:msub><mml:mrow><mml:mi>v</mml:mi>
</mml:mrow>
<mml:mrow><mml:mi>i</mml:mi>
</mml:mrow>
</mml:msub>
<mml:mi>z</mml:mi>
<mml:mo>∼</mml:mo>
<mml:mi>G</mml:mi>
<mml:mtext>for some</mml:mtext>
<mml:mi>z</mml:mi>
<mml:mo>∈</mml:mo>
<mml:msup><mml:mrow><mml:mi mathvariant="normal">Σ</mml:mi>
</mml:mrow>
<mml:mrow><mml:mo>∗</mml:mo>
</mml:mrow>
</mml:msup>
<mml:mo>}</mml:mo>
<mml:mi>.</mml:mi>
</mml:math>
</disp-formula>
</p>
<p><italic>For |x| < k, this is just min{i ∣ x ≤ v</italic>
<sub><italic>i</italic>
</sub>
<italic>}, while for |x| ≥ k it requires a path starting at v</italic>
<sub><italic>i</italic>
</sub>
(<italic>unless x ≤ v</italic>
<sub><italic>i</italic>
</sub>
).</p>
</sec>
<sec><title></title>
<p><italic>Proof.</italic>
For the empty string, <italic>γ</italic>
(<italic>ε</italic>
)=0, making equation (20) true. For <italic>a</italic>
∈ Σ, <italic>γ</italic>
(<italic>a</italic>
)=<italic>ρ</italic>
(<italic>a</italic>
,0), and equation (20) is essentially the definition of <italic>ρ</italic>
; for <italic>γ</italic>
(<italic>$</italic>
)=0 the result follows as all <italic>v</italic>
<sub><italic>i</italic>
</sub>
≥<italic>$</italic>
, while for <italic>γ</italic>
(<italic>∞</italic>
)=<italic>n</italic>
only <italic>v</italic>
<sub><italic>n</italic>
</sub>
≥<italic>∞</italic>
. We will then complete the proof by induction on |<italic>x</italic>
| using (20) as the induction hypothesis.</p>
<p>For 2≤|<italic>x</italic>
|<<italic>k</italic>
, write <italic>x</italic>
=<italic>a</italic>
<italic>y</italic>
where <italic>a</italic>
∈ Σ. By the induction hypothesis, we know that <italic>y</italic>
≤<italic>v</italic>
<sub><italic>j</italic>
</sub>
when <italic>j</italic>
≥<italic>γ</italic>
(<italic>y</italic>
). Since |<italic>y</italic>
|≤<italic>k</italic>
−2, this is the same as <italic>y</italic>
≤<italic>v</italic>
<italic>j</italic>
−, and thus equivalent to <italic>x</italic>
=<italic>a</italic>
<italic>y</italic>
≤<italic>a</italic>
<italic>v</italic>
<italic>j</italic>
−. If <italic>x</italic>
=<italic>a</italic>
<italic>y</italic>
≤<italic>v</italic>
<sub><italic>i</italic>
</sub>
, then either <italic>v</italic>
<sub><italic>i</italic>
</sub>
=<italic>a</italic>
<italic>v</italic>
<italic>j</italic>
− for some <italic>j</italic>
in which case <italic>x</italic>
≤<italic>v</italic>
<sub><italic>i</italic>
</sub>
=<italic>a</italic>
<italic>v</italic>
<italic>j</italic>
− and <italic>i</italic>
≥<italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
), or no such <italic>v</italic>
<sub><italic>j</italic>
</sub>
exists in which case the first letter <italic>v</italic>
<sub><italic>i</italic>
,1</sub>
><italic>a</italic>
and <italic>i</italic>
≥<italic>ρ</italic>
(<italic>a</italic>
,<italic>n</italic>
). The smallest <italic>i</italic>
for which this makes <italic>x</italic>
≤<italic>v</italic>
<sub><italic>i</italic>
</sub>
in either case corresponds to <italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
) where <italic>j</italic>
=<italic>γ</italic>
(<italic>y</italic>
).</p>
<p>For |<italic>x</italic>
|≥<italic>k</italic>
, again write <italic>x</italic>
=<italic>a</italic>
<italic>y</italic>
where we know that <italic>y</italic>
≤<italic>v</italic>
<sub><italic>j</italic>
</sub>
<italic>z</italic>
∼<italic>G</italic>
when <italic>j</italic>
≥<italic>γ</italic>
(<italic>y</italic>
). This means that <italic>x</italic>
=<italic>a</italic>
<italic>y</italic>
≤<italic>av</italic>
<sub><italic>j</italic>
</sub>
<italic>z</italic>
=<italic>v</italic>
<sub><italic>i</italic>
</sub>
<italic>b</italic>
<italic>z</italic>
∼<italic>G</italic>
for <italic>i</italic>
=<italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
) and where the condition <italic>j</italic>
≥<italic>γ</italic>
(<italic>y</italic>
) becomes <italic>i</italic>
≥<italic>ρ</italic>
(<italic>a</italic>
,<italic>j</italic>
). □</p>
</sec>
</sec>
</sec>
<sec><title>Competing interests</title>
<p>The author declares that he has no competing interests.</p>
</sec>
<sec sec-type="supplementary-material"><title>Supplementary Material</title>
<supplementary-material content-type="local-data" id="S1"><caption><title>Additional file 1</title>
<p>Supplementary information on the kFM-index.</p>
</caption>
<media xlink:href="1471-2105-14-313-S1.pdf"><caption><p>Click here for file</p>
</caption>
</media>
</supplementary-material>
</sec>
</body>
<back><sec><title>Acknowledgements</title>
<p>I am most grateful to Prof. Wen-Lian Hsu and his research group at the Institute of Information Science at Academia Sinica for hosting me during my stays in Taipei, Taiwan, during which parts of this work was conducted.</p>
</sec>
<ref-list><ref id="B1"><mixed-citation publication-type="journal"><name><surname>Conway</surname>
<given-names>TC</given-names>
</name>
<name><surname>Bromage</surname>
<given-names>AJ</given-names>
</name>
<article-title>Succinct data structures for assembling large genomes</article-title>
<source>Bioinformatics</source>
<year>2011</year>
<volume>14</volume>
<issue>4</issue>
<fpage>479</fpage>
<lpage>486</lpage>
<pub-id pub-id-type="doi">10.1093/bioinformatics/btq697</pub-id>
<pub-id pub-id-type="pmid">21245053</pub-id>
</mixed-citation>
</ref>
<ref id="B2"><mixed-citation publication-type="journal"><name><surname>Ning</surname>
<given-names>Z</given-names>
</name>
<name><surname>Cox</surname>
<given-names>AJ</given-names>
</name>
<name><surname>Mullikin</surname>
<given-names>JC</given-names>
</name>
<article-title>SSAHA: a fast search method for large DNA databases</article-title>
<source>Genome Res</source>
<year>2001</year>
<volume>14</volume>
<issue>10</issue>
<fpage>1725</fpage>
<lpage>1729</lpage>
<pub-id pub-id-type="doi">10.1101/gr.194201</pub-id>
<pub-id pub-id-type="pmid">11591649</pub-id>
</mixed-citation>
</ref>
<ref id="B3"><mixed-citation publication-type="journal"><name><surname>Roberts</surname>
<given-names>M</given-names>
</name>
<name><surname>Hayes</surname>
<given-names>W</given-names>
</name>
<name><surname>Hunt</surname>
<given-names>BR</given-names>
</name>
<name><surname>Mount</surname>
<given-names>SM</given-names>
</name>
<name><surname>Yorke</surname>
<given-names>JA</given-names>
</name>
<article-title>Reducing storage requirements for biological sequence comparison</article-title>
<source>Bioinformatics</source>
<year>2004</year>
<volume>14</volume>
<issue>18</issue>
<fpage>3363</fpage>
<lpage>3369</lpage>
<pub-id pub-id-type="doi">10.1093/bioinformatics/bth408</pub-id>
<pub-id pub-id-type="pmid">15256412</pub-id>
</mixed-citation>
</ref>
<ref id="B4"><mixed-citation publication-type="journal"><name><surname>Ye</surname>
<given-names>C</given-names>
</name>
<name><surname>Ma</surname>
<given-names>ZS</given-names>
</name>
<name><surname>Cannon</surname>
<given-names>CH</given-names>
</name>
<name><surname>Pop</surname>
<given-names>M</given-names>
</name>
<name><surname>Yu</surname>
<given-names>DW</given-names>
</name>
<article-title>Exploiting sparseness in de novo genome assembly</article-title>
<source>BMC Bioinformatics</source>
<year>2012</year>
<volume>14</volume>
<issue>Suppl 6</issue>
<fpage>S1</fpage>
<pub-id pub-id-type="doi">10.1186/1471-2105-13-S6-S1</pub-id>
<pub-id pub-id-type="pmid">22537038</pub-id>
</mixed-citation>
</ref>
<ref id="B5"><mixed-citation publication-type="journal"><name><surname>Pell</surname>
<given-names>J</given-names>
</name>
<name><surname>Hintze</surname>
<given-names>A</given-names>
</name>
<name><surname>Canino-Koning</surname>
<given-names>R</given-names>
</name>
<name><surname>Howe</surname>
<given-names>A</given-names>
</name>
<name><surname>Tiedje</surname>
<given-names>JM</given-names>
</name>
<name><surname>Brown</surname>
<given-names>CT</given-names>
</name>
<article-title>Scaling metagenome sequence assembly with probabilistic de Bruijn graphs</article-title>
<source>Proc Natl Acad Sci U S A</source>
<year>2012</year>
<volume>14</volume>
<issue>33</issue>
<fpage>13272</fpage>
<lpage>13277</lpage>
<pub-id pub-id-type="doi">10.1073/pnas.1121464109</pub-id>
<pub-id pub-id-type="pmid">22847406</pub-id>
</mixed-citation>
</ref>
<ref id="B6"><mixed-citation publication-type="book"><name><surname>Chikhi</surname>
<given-names>R</given-names>
</name>
<name><surname>Rizk</surname>
<given-names>G</given-names>
</name>
<person-group person-group-type="editor">Raphel B, Tang J</person-group>
<article-title>Space-efficient and exact de Bruijn graph representation based on a Bloom filter</article-title>
<source>Algorithms in Bioinformatics, Lecture Notes in Computer Science</source>
<year>2012</year>
<publisher-name>Springer</publisher-name>
<fpage>236</fpage>
<lpage>248</lpage>
</mixed-citation>
</ref>
<ref id="B7"><mixed-citation publication-type="other"><name><surname>Ferragina</surname>
<given-names>P</given-names>
</name>
<name><surname>Manzini</surname>
<given-names>G</given-names>
</name>
<article-title>Opportunistic data structures with applications</article-title>
<source>41st Annual Symposium on Foundations of Computer Science</source>
<year>2000</year>
<fpage>390</fpage>
<lpage>398</lpage>
</mixed-citation>
</ref>
<ref id="B8"><mixed-citation publication-type="other"><name><surname>Burrows</surname>
<given-names>M</given-names>
</name>
<name><surname>Wheeler</surname>
<given-names>DJ</given-names>
</name>
<article-title>A block-sorting lossless data compression algorithm</article-title>
<comment>Tech. Rep. May 10, SRC Research Report 1994.</comment>
</mixed-citation>
</ref>
<ref id="B9"><mixed-citation publication-type="book"><name><surname>Grossi</surname>
<given-names>R</given-names>
</name>
<name><surname>Vitter</surname>
<given-names>JS</given-names>
</name>
<article-title>Compressed suffix arrays and suffix trees with applications to text indexing and string matching</article-title>
<source>STOC ‘00 Proceedings of the Thirty-second Annual ACM Symposium on Theory of Computing</source>
<year>2000</year>
<publisher-name>New York: ACM</publisher-name>
<fpage>397</fpage>
<lpage>406</lpage>
</mixed-citation>
</ref>
<ref id="B10"><mixed-citation publication-type="journal"><name><surname>Simpson</surname>
<given-names>JT</given-names>
</name>
<name><surname>Durbin</surname>
<given-names>R</given-names>
</name>
<article-title>Efficient de novo assembly of large genomes using compressed data structures</article-title>
<source>Genome Res</source>
<year>2012</year>
<volume>14</volume>
<issue>3</issue>
<fpage>549</fpage>
<lpage>556</lpage>
<pub-id pub-id-type="doi">10.1101/gr.126953.111</pub-id>
<pub-id pub-id-type="pmid">22156294</pub-id>
</mixed-citation>
</ref>
<ref id="B11"><mixed-citation publication-type="journal"><name><surname>Ferragina</surname>
<given-names>P</given-names>
</name>
<name><surname>Manzini</surname>
<given-names>G</given-names>
</name>
<article-title>Indexing compressed text</article-title>
<source>J ACM</source>
<year>2005</year>
<volume>14</volume>
<issue>4</issue>
<fpage>552</fpage>
<lpage>581</lpage>
<pub-id pub-id-type="doi">10.1145/1082036.1082039</pub-id>
</mixed-citation>
</ref>
<ref id="B12"><mixed-citation publication-type="journal"><name><surname>Zerbino</surname>
<given-names>DR</given-names>
</name>
<name><surname>Birney</surname>
<given-names>E</given-names>
</name>
<article-title>Velvet: algorithms for de novo short read assembly using de Bruijn graphs</article-title>
<source>Genome Res</source>
<year>2008</year>
<volume>14</volume>
<issue>5</issue>
<fpage>821</fpage>
<lpage>829</lpage>
<pub-id pub-id-type="doi">10.1101/gr.074492.107</pub-id>
<pub-id pub-id-type="pmid">18349386</pub-id>
</mixed-citation>
</ref>
<ref id="B13"><mixed-citation publication-type="journal"><name><surname>Simpson</surname>
<given-names>JT</given-names>
</name>
<name><surname>Wong</surname>
<given-names>K</given-names>
</name>
<name><surname>Jackman</surname>
<given-names>SD</given-names>
</name>
<name><surname>Schein</surname>
<given-names>JE</given-names>
</name>
<name><surname>Jones</surname>
<given-names>SJM</given-names>
</name>
<name><surname>Birol</surname>
<given-names>I</given-names>
</name>
<article-title>ABySS: a parallel assembler for short read sequence data</article-title>
<source>Genome Res</source>
<year>2009</year>
<volume>14</volume>
<issue>6</issue>
<fpage>1117</fpage>
<lpage>1123</lpage>
<pub-id pub-id-type="doi">10.1101/gr.089532.108</pub-id>
<pub-id pub-id-type="pmid">19251739</pub-id>
</mixed-citation>
</ref>
<ref id="B14"><mixed-citation publication-type="journal"><name><surname>Kelley</surname>
<given-names>DR</given-names>
</name>
<name><surname>Schatz</surname>
<given-names>MC</given-names>
</name>
<name><surname>Salzberg</surname>
<given-names>SL</given-names>
</name>
<article-title>Quake: quality-aware detection and correction of sequencing errors</article-title>
<source>Genome Biol</source>
<year>2010</year>
<volume>14</volume>
<issue>11</issue>
<fpage>R116</fpage>
<pub-id pub-id-type="doi">10.1186/gb-2010-11-11-r116</pub-id>
<pub-id pub-id-type="pmid">21114842</pub-id>
</mixed-citation>
</ref>
<ref id="B15"><mixed-citation publication-type="journal"><name><surname>Yang</surname>
<given-names>X</given-names>
</name>
<name><surname>Dorman</surname>
<given-names>KS</given-names>
</name>
<name><surname>Aluru</surname>
<given-names>S</given-names>
</name>
<article-title>Reptile: representative tiling for short read error correction</article-title>
<source>Bioinformatics</source>
<year>2010</year>
<volume>14</volume>
<issue>20</issue>
<fpage>2526</fpage>
<lpage>2533</lpage>
<pub-id pub-id-type="doi">10.1093/bioinformatics/btq468</pub-id>
<pub-id pub-id-type="pmid">20834037</pub-id>
</mixed-citation>
</ref>
<ref id="B16"><mixed-citation publication-type="journal"><name><surname>Melsted</surname>
<given-names>P</given-names>
</name>
<name><surname>Pritchard</surname>
<given-names>JK</given-names>
</name>
<article-title>Efficient counting of k-mers in DNA sequences using a bloom filter</article-title>
<source>BMC Bioinformatics</source>
<year>2011</year>
<volume>14</volume>
<fpage>333</fpage>
<pub-id pub-id-type="doi">10.1186/1471-2105-12-333</pub-id>
<pub-id pub-id-type="pmid">21831268</pub-id>
</mixed-citation>
</ref>
<ref id="B17"><mixed-citation publication-type="journal"><name><surname>Marçais</surname>
<given-names>G</given-names>
</name>
<name><surname>Kingsford</surname>
<given-names>C</given-names>
</name>
<article-title>A fast, lock-free approach for efficient parallel counting of occurrences of k-mers</article-title>
<source>Bioinformatics</source>
<year>2011</year>
<volume>14</volume>
<issue>6</issue>
<fpage>764</fpage>
<lpage>770</lpage>
<pub-id pub-id-type="doi">10.1093/bioinformatics/btr011</pub-id>
<pub-id pub-id-type="pmid">21217122</pub-id>
</mixed-citation>
</ref>
<ref id="B18"><mixed-citation publication-type="journal"><name><surname>Liu</surname>
<given-names>Y</given-names>
</name>
<name><surname>Schröder</surname>
<given-names>J</given-names>
</name>
<name><surname>Schmidt</surname>
<given-names>B</given-names>
</name>
<article-title>Musket: a multistage k-mer spectrum-based error corrector for Illumina sequence data</article-title>
<source>Bioinformatics</source>
<year>2013</year>
<volume>14</volume>
<issue>3</issue>
<fpage>308</fpage>
<lpage>315</lpage>
<pub-id pub-id-type="doi">10.1093/bioinformatics/bts690</pub-id>
<pub-id pub-id-type="pmid">24131777</pub-id>
</mixed-citation>
</ref>
<ref id="B19"><mixed-citation publication-type="book"><name><surname>Nong</surname>
<given-names>G</given-names>
</name>
<name><surname>Zhang</surname>
<given-names>S</given-names>
</name>
<name><surname>Chan</surname>
<given-names>WH</given-names>
</name>
<article-title>Linear suffix array construction by almost pure induced-sorting</article-title>
<source>2009 Data Compression Conference</source>
<year>2009</year>
<publisher-name>IEEE</publisher-name>
<fpage>193</fpage>
<lpage>202</lpage>
</mixed-citation>
</ref>
<ref id="B20"><mixed-citation publication-type="journal"><name><surname>Hon</surname>
<given-names>WK</given-names>
</name>
<name><surname>Sadakane</surname>
<given-names>K</given-names>
</name>
<name><surname>Sung</surname>
<given-names>WK</given-names>
</name>
<article-title>Breaking a time-and-space barrier in constructing full-text indices</article-title>
<source>SIAM J Comput</source>
<year>2009</year>
<volume>14</volume>
<issue>6</issue>
<fpage>2162</fpage>
<lpage>2178</lpage>
<pub-id pub-id-type="doi">10.1137/070685373</pub-id>
</mixed-citation>
</ref>
<ref id="B21"><mixed-citation publication-type="journal"><name><surname>Okanohara</surname>
<given-names>D</given-names>
</name>
<name><surname>Sadakane</surname>
<given-names>K</given-names>
</name>
<article-title>A linear-time burrows-wheeler transform using induced sorting</article-title>
<source>Lecture Notes Comput Sci: String Process Inf Retrieval</source>
<year>2009</year>
<volume>14</volume>
<fpage>90</fpage>
<lpage>101</lpage>
<pub-id pub-id-type="doi">10.1007/978-3-642-03784-9_9</pub-id>
</mixed-citation>
</ref>
</ref-list>
</back>
</pmc>
</record>
Pour manipuler ce document sous Unix (Dilib)
EXPLOR_STEP=$WICRI_ROOT/Sante/explor/MersV1/Data/Pmc/Corpus
HfdSelect -h $EXPLOR_STEP/biblio.hfd -nk 000947 | SxmlIndent | more
Ou
HfdSelect -h $EXPLOR_AREA/Data/Pmc/Corpus/biblio.hfd -nk 000947 | SxmlIndent | more
Pour mettre un lien sur cette page dans le réseau Wicri
{{Explor lien |wiki= Sante |area= MersV1 |flux= Pmc |étape= Corpus |type= RBID |clé= PMC:4015147 |texte= Compact representation of k-mer de Bruijn graphs for genome read assembly }}
Pour générer des pages wiki
HfdIndexSelect -h $EXPLOR_AREA/Data/Pmc/Corpus/RBID.i -Sk "pubmed:24152242" \ | HfdSelect -Kh $EXPLOR_AREA/Data/Pmc/Corpus/biblio.hfd \ | NlmPubMed2Wicri -a MersV1
![]() | This area was generated with Dilib version V0.6.33. | ![]() |