| Example Program Index Finder StringSet Example for using a Finder of an Index of a StringSet. This example shows how to use the Finder class for an Index search. The Index was build for a given StringSet. File "index_find_stringset.cpp"
1 | #include <iostream>
2 | #include <seqan/index.h>
3 |
4 | using namespace std;
5 | using namespace seqan;
6 |
7 | int main ()
8 | {
First, we create a StringSet of 3 Strings.
9 | StringSet< String<char> > mySet;
10 | resize(mySet, 3);
11 | mySet[0] = "tobeornottobe";
12 | mySet[1] = "thebeeonthecomb";
13 | mySet[2] = "beingjohnmalkovich";
14 |
Then we create an Index of our StringSet and a Finder of the Index.
15 | Index< StringSet<String<char> > > myIndex(mySet);
16 | Finder< Index<StringSet<String<char> > > > myFinder(myIndex);
17 |
Finally we search for the string "be" and output all occurences
18 | cout << "hit at ";
19 | while (find(myFinder, "be"))
20 | cout << position(myFinder) << " ";
21 | cout << endl;
22 |
23 | return 0;
24 | }
Output weese@tanne:~/seqan$ cd demos weese@tanne:~/seqan/demos$ make index_find_stringset weese@tanne:~/seqan/demos$ ./index_find_stringset hit at < 0 , 11 > < 1 , 3 > < 2 , 0 > < 0 , 2 > weese@tanne:~/seqan/demos$ See find, Finder, Index, StringSet SeqAn - Sequence Analysis Library - www.seqan.de