Interface Functions Detail
TIter begin(finder[, tag]);
Return begin iterator of the match in the haystack.
Parameters
finder
|
The Finder to query. |
tag
|
The tag to select the iterator type. |
Returns
TIter |
The iterator to the begin of the match in the haystack. TIter is the same type as returned by
begin(haystack[, tag]) where haystack is the haystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TPosition beginPosition(finder);
Return begin position of match.
Parameters
finder
|
The Finder to query. |
Returns
TPosition |
The begin position of the finder. TPosition is the position type of THaystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void clear(finder);
Parameters
finder
|
The Finder to clear. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TIter end(finder[, tag]);
Return end iterator of the match in the haystack.
Parameters
finder
|
The Finder to query. |
tag
|
The tag to select the iterator type. |
Returns
TIter |
The iterator to the end of the match in the haystack. TIter is the same type as returned by
end(haystack[, tag]) where haystack is the haystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TPosition endPosition(finder);
Return end position of match.
Parameters
finder
|
The Finder to query. |
Returns
TPosition |
The end position of the finder. TPosition is the position type of THaystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool find(finder, pattern[, k]);
Parameters
finder
|
The Finder object to search through. |
pattern
|
The Pattern to search for. For index finders, pattern can also be a text.
Types: Pattern, TextConcept. |
k
|
Desired minimal score (for approximate matching). k is a number <= 0.
Differences are deletions, insertions, and substitutions. |
Returns
bool |
true if an occurrence was found and false if not. |
Repeated calls of this function iterate through all occurrences of pattern.
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 before searching for another pattern.
#include <seqan/find.h>
using namespace seqan2;
int main()
{
CharString hstck = "I spy with my little eye something that is yellow";
Finder<CharString> finder(hstck);
Pattern<CharString, Horspool> p1("y");
while (find(finder, p1))
std::cout << "Hit at position: " << position(finder) << std::endl;
goBegin(finder); // move Finder to the beginning of the text
clear(finder); // reset Finder
Pattern<CharString, Horspool> p2("t");
while (find(finder, p2))
std::cout << "Hit at position: " << position(finder) << std::endl;
}
The output is as follows.
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 before searching for another pattern.
#include <seqan/find.h>
#include <seqan/index.h>
using namespace seqan2;
int main()
{
CharString hstck = "I spy with my little eye something that is yellow";
Index<CharString, FMIndex<> > index(hstck);
Finder<Index<CharString, FMIndex<> > > finder(hstck);
while (find(finder, "y"))
std::cout << "Hit at position: " << position(finder) << std::endl;
clear(finder); // reset Finder
while (find(finder, "t"))
std::cout << "Hit at position: " << position(finder) << std::endl;
}
The output is as follows.
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
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
bool findBegin(finder, pattern[, limit]);
Search the begin of an approximate match.
Parameters
finder
|
The Finder object to search through. |
pattern
|
The Pattern object to search for. This must be a pattern for approximate string matching. |
limit
|
The score limit. The default is the limit used during the last find call, see
getScore. All occurrences that score at least limit are reported. |
Returns
bool |
true indicates a match, false indicates no match. |
The function find successfully called be called - that is an end position was found - before calling
findBegin to find a begin position.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void goBegin(finder);
Go to the beginning of the text.
Parameters
finder
|
The finder to reset to the beginning of the text. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void goEnd(finder);
Go to the end of the text.
Parameters
finder
|
The finder to reset to the end of the text. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
THaystack haystack(finder);
Returns the haystack of a Finder.
Parameters
finder
|
The Finder to query for its haystack. |
Returns
THaystack |
The result type can be retrieved using Haystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TInfix infix(finder);
Returns the segment of the last found match in the haystack.
Parameters
finder
|
The Finder to query. |
Returns
TInfix |
The Infix of the match in the haystack. |
This function works only correct if the begin position of the match was already found, see findBegin
For finders or patterns of filtering algorithms (e.g. @Spec.Swift@) the returned infix is a potential match.
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TSize length(finder);
Return the length of the match.
Parameters
finder
|
The finder to query for its match length. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
TPosition position(finder);
Return current position of the finder in the haystack.
Parameters
finder
|
The Finder to query. |
Returns
TPosition |
The current position. TPosition is the position type of the haystack. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void setHaystack(finder, haystack);
Sets the haystack of a
Finder object.
Parameters
finder
|
The finder to set the haystack for. |
haystack
|
The haystack to set. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.
void setPosition(finder, pos);
Sets the position of a finder.
Parameters
finder
|
The Findre to set the position for. |
pos
|
The position to set the finder to. |
Data Races
If not stated otherwise, concurrent invocation is not guaranteed to be thread-safe.