Class
Index
Contains preprocessing data of a fixed text. In combination with a Finder or a VSTree Iterator it allows fast dictionary look-up and advanced computations.
Index<TText[, TSpec]>
Include Headers
seqan/index.h
Parameters
TText
The text type.
Metafunctions: Host
TSpec
The index type.
Metafunctions: Spec
Default: The result of DefaultIndexSpec: IndexEsa
Remarks
Indices allow fast dictionary look-ups and other advanced computations because they contain pre-computated information about the underlying text. These information are stored in so called fibres (see Fibre).
In order to search for a pattern one can use a Finder or a VSTree Iterator. The Finder is especially useful when searching for exact matches while the VSTree Iterator allows to iterate an index as if traversing a tree/trie.
These fibres are created on demand depending on the requirements of an algorithm.
Specializations
FMIndexAn index based on the Burrows-Wheeler transform.
IndexEsaThe enhanced suffix array index is very fast index, requiring more memory than other indices. In addition to the suffix array an lcp (longest common prefix) table and a child table (containing structural information of the suffix tree) are provided.
IndexQGramAn index based on an array of sorted q-grams. Especially useful for q-gram/k-mer searches.
IndexSaAn index based on a suffix array.
IndexWotdThis index represents a lazy suffix tree, meaning that a path from the tree of the index in only computed, if it is traversed. For details see Giegerich et al., "Efficient implementation of lazy suffix trees".
Pizza & Chili IndexAn adapter for the Pizza & Chili index API.
Metafunctions
FibreType of a specific container member (fibre).
SAValueThe default alphabet type of a suffix array, i.e. the type to store a position of a string or string set.
Functions
clearResets an object.
countSequencesReturn the number of sequences in an index' underlying text.
endThe end of a container.
getFibreReturns a specific fibre of a container.
indexCreateCreates a specific Fibre.
indexRequireOn-demand creation of a specific Fibre.
indexSAShortcut for getFibre(.., FibreSA).
indexSuppliedReturns whether a specific Fibre is present.
indexTextShortcut for getFibre(index, FibreText()).
lengthThe number of characters in the underlying text of the index is returned.
openThis functions opens an index from disk.
saveThis functions saves an index to disk.
setHaystackSets the haystack of a Finder object.
Examples
The following code shows how to search for exact matches between the reference "tobeornottobe" and the pattern "to" with the means of a Finder.
1#include <seqan/index.h>
2
3using namespace seqan;
4
5int main ()
6{
7    typedef Index<CharString> TIndex;
8
9    TIndex index("tobeornottobe");
10    Finder<TIndex> finder(index);
11
12    // The Finder object has a pointer to the first, current and last hit
13    // Each consecutive call sets the current pointer to the appropriate hit
14    while (find(finder, "to"))
15        std::cout << "Hit at position: " << position(finder) << std::endl;
16
17    return 0;
18}
Hit at position: 9
Hit at position: 0
This code shows how an index can be used with iterators to achieve a pre-order tree like traversal in DFS of the text "tobeornottobe". In order to do so a Top-Down History iterator is used.
1#include <seqan/index.h>
2
3using namespace seqan;
4
5int main ()
6{
7    typedef Index<CharString> TIndex;
8
9    TIndex index("tobeornottobe");
10    Iterator<TIndex, TopDown<ParentLinks<> > >::Type it(index);
11
12    do {
13        // Print theletters from the root to the current node
14        std::cout << representative(it) << std::endl;
15
16        if (!goDown(it) && !goRight(it))
17            while (goUp(it) && !goRight(it)) ;
18    } while (!isRoot(it));
19
20    return 0;
21}
be
beornottobe
e
eornottobe
nottobe
o
obe
obeornottobe
ornottobe
ottobe
rnottobe
t
tobe
tobeornottobe
ttobe
Note that you can also use specialised iterators such as:
Iterator<TIndex, TopDown<ParentLinks<PreOrder> > >::Type
or
Iterator<TIndex, TopDown<ParentLinks<PostOrder> > >::Type
You can achieve a post-order traversal like this:
1    Iterator< TIndex, TopDown< ParentLinks<Postorder> > >::Type it(index);
2
3    goBegin(it);
4    while (!atEnd(it))
5    {
6        std::cout << representative(it) << std::endl;
7        ++it;
8    }
beornottobe
be
eornottobe
e
nottobe
obeornottobe
obe
ornottobe
ottobe
o
rnottobe
tobeornottobe
tobe
ttobe
t
SeqAn - Sequence Analysis Library - www.seqan.de
 

Page built @2013/07/11 09:12:34