Class
Finder
Holds the haystack and a current search context.
Finder<THaystack[, TSpec]>
Include Headers
seqan/find.h
Parameters
THaystack
The haystack type.
Types: Index, String
TSpec
The index-algorithm to search with (Optional).
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.
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
BacktrackingProvides approximate string matching via backtracking on a substring index.
PigeonholeProvides 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.
SwiftProvides 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
ContainerType of the container given an iterator.
DifferenceType of an object that stores the difference between two iterators.
HaystackReturns the haystack type of a Finder type.
HostType of the object a given object depends on.
IteratorType of iterator objects that are used to traverse the container.
ValueType of the items in the container or behind an iterator.
Member Functions
FinderConstructor
Functions
beginThe begin of a container.
beginPositionBegin position of object in host.
clearResets an object.
endThe end of a container.
endPositionEnd position of object in host.
findSearch for a Pattern in a Finder object.
findBeginSearch the begin of an approximate match.
haystackReturns the haystack of a Finder object.
infixReturns the segment of the last found match in haystack.
lengthThe number of items/characters.
positionPosition of an iterator.
setHaystackSets the haystack of a Finder object.
setPositionSets 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.
1#include <seqan/find.h>
2
3using namespace seqan;
4
5int 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.
1#include <seqan/find.h>
2#include <seqan/index.h>
3
4using namespace seqan;
5
6int 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
SeqAn - Sequence Analysis Library - www.seqan.de
 

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