| Class Finder Holds the haystack and a current search context.
Finder
Backtracking | Pigeonhole | Swift
SwiftLocal | SwiftSemiGlobal
Finder<THaystack[, TSpec]> Include Headers seqan/find.h Parameters
TSpec | The index-algorithm to search with (Optional). Types: Backtracking, Pigeonhole, Swift Default: The result of DefaultFinder Remarks: Leave empty for online pattern matching (see Pattern). If THaystack is an Index, then TSpec specifies the index search algorithm.
THaystack | The haystack type. Types: Index, String
Remarks position(finder) returns the position of the current hit in the haystack. If THaystack is a set of strings or an index of a set of strings, then position(finder) returns a Pair$(hayNo, pos), in which hayNo is the haystack index and pos the local position of the hit. To reset the finder object and use it on another text or different text position, use clear(finder) Note that clear(finder) doesn't move the text iterator. To start the search from the beginning or somewhere else in the text, use goBegin or setPosition. Specializations
Backtracking | Provides approximate string matching via backtracking on a substring index.
Pigeonhole | Provides a fast filter alogrithm that uses the pigeonhole lemma, i.e. if a pattern matches with k errors in the text, every partition into k+1 parts contains one part that matches without error.
Swift | Provides a fast filter alogrithm that guarantees to find all regions overlapping with potential ε-matches. An ε-match is a matching region of minimal length and an error rate of at most ε.
Metafunctions
Container | Type of the container given an iterator.
Difference | Type of an object that stores the difference between two iterators.
Haystack | Returns the haystack type of a Finder type.
Host | Type of the object a given object depends on.
Iterator | Type of iterator objects that are used to traverse the container.
Position | Type of an object that represents a position in a container.
Reference | Reference type.
Value | Type of the items in the container or behind an iterator.
Member Functions
Finder | Constructor
Functions
begin | The begin of a container.
beginPosition | Begin position of object in host.
clear | Resets an object.
end | The end of a container.
endPosition | End position of object in host.
find | Search for a Pattern in a Finder object.
findBegin | Search the begin of an approximate match.
haystack | Returns the haystack of a Finder object.
infix | Returns the segment of the last found match in haystack.
length | The number of items/characters.
position | Position of an iterator.
setHaystack | Sets the haystack of a Finder object.
setPosition | Sets the position of a finder.
Examples The following example shows how one can search online for a pattern in a haystack. Note that it is neccessary to reset the finder befor searching for another pattern. File "finder_online.cpp"
1 | #include <seqan/find.h>
2 |
3 | using namespace seqan;
4 |
5 | int main()
6 | {
7 | CharString hstck = "I spy with my little eye something that is yellow";
8 | Finder<CharString> finder(hstck);
9 |
10 | Pattern<CharString, Horspool> p1("y");
11 |
12 | while(find(finder, p1))
13 | std::cout << "Hit at position: " << position(finder)<<std::endl;
14 |
15 | goBegin(finder); // move Finder to the beginning of the text
16 | clear(finder); // reset Finder
17 |
18 | Pattern<CharString, Horspool> p2("t");
19 | while(find(finder, p2))
20 | std::cout << "Hit at position: " << position(finder)<<std::endl;
21 | }
Hit at position: 4 Hit at position: 12 Hit at position: 22 Hit at position: 43 Hit at position: 8 Hit at position: 16 Hit at position: 17 Hit at position: 29 Hit at position: 35 Hit at position: 38 In contrast to the example above the code below shows how one can use a Finder with an index as base. Again, note that it is neccessary to reset the finder befor searching for another pattern. File "finder_index.cpp"
1 | #include <seqan/find.h>
2 | #include <seqan/index.h>
3 |
4 | using namespace seqan;
5 |
6 | int main()
7 | {
8 | CharString hstck = "I spy with my little eye something that is yellow";
9 | Index<CharString, FMIndex<> > index(hstck);
10 | Finder<Index<CharString, FMIndex<> > > finder(hstck);
11 |
12 | while(find(finder, "y"))
13 | std::cout << "Hit at position: " << position(finder)<<std::endl;
14 |
15 | clear(finder); // reset Finder
16 |
17 | while(find(finder, "t"))
18 | std::cout << "Hit at position: " << position(finder)<<std::endl;
19 | }
Hit at position: 12 Hit at position: 4 Hit at position: 22 Hit at position: 43 Hit at position: 38 Hit at position: 8 Hit at position: 35 Hit at position: 29 Hit at position: 17 Hit at position: 16 Example Programs Index Finder, Index Finder StringSet SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:56