Index Finder

| Example Program Index Finder Example for using a Finder of an Index. This example shows how to use the Finder class for an Index search. File "index_find.cpp" A tutorial about find algorithms using an index.
1 | #include <iostream>
2 | #include <seqan/index.h>
3 |
4 | using namespace seqan;
5 |
6 | int main ()
7 | {
The following code creates an Index of "tobeornottobe". As there is no second template parameter given to Index<..>, the default index based on an enhanced suffix array is used.
8 | Index< String<char> > index_esa("tobeornottobe");
9 | Finder< Index< String<char> > > finder_esa(index_esa);
10 |
11 | ::std::cout << "hit at ";
12 | while (find(finder_esa, "be"))
13 | ::std::cout << position(finder_esa) << " ";
14 | ::std::cout << ::std::endl;
15 |
Now we explicitly create a q-gram index using an ungapped 2-gram and do the same. Instead of this fixed-size shape you can use arbitrary shapes and assign them before calling find via indexShape.
16 | typedef Index< String<char>, IndexQGram< UngappedShape<2> > > TQGramIndex;
17 | TQGramIndex index_2gram("tobeornottobe");
18 | Finder< TQGramIndex > finder_2gram(index_2gram);
19 |
20 | ::std::cout << "hit at ";
21 | while (find(finder_2gram, "be"))
22 | ::std::cout << position(finder_2gram) << " ";
23 | ::std::cout << ::std::endl;
24 |
25 | return 0;
26 | }
Output weese@tanne:~/seqan$ cd demos weese@tanne:~/seqan/demos$ make index_find weese@tanne:~/seqan/demos$ ./index_find hit at 11 2 hit at 2 11 weese@tanne:~/seqan/demos$ See Index, find, Finder SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2012/03/14 16:34:45