| Example Program Approximate Searching Approximate string matching. File "find_approx.cpp"
1 | #include <iostream>
2 | #include <seqan/find.h>
3 |
4 | using namespace seqan;
5 | using namespace std;
6 |
This program finds all occurrences of CCT in AACTTAACCTAA with ≤ 1 error using the MyersUkkonen approximate search algorithm.
7 | int main()
8 | {
9 | String<char> haystk("AACTTAACCTAA");
10 | String<char> ndl("CCT");
11 |
12 | Finder<String<char> > fnd(haystk);
13 | Pattern<String<char>, MyersUkkonen> pat(ndl);
The function setScoreLimit sets the limit score an occurrence must reach. Since the used scoring scheme is a distance measure (edit distance), all scores are negative. A score limit of ≥ -1 therefore means a edit distance ≤ 1.
14 | setScoreLimit(pat, -1);
15 | while (find(fnd, pat))
16 | {
17 | cout << position(fnd) << ": " << getScore(pat) << "\n";
Note that position returns the end position of the found occurrence.
18 | }
19 |
20 | return 0;
21 | }
22 |
Output 3: -1 4: -1 8: -1 9: 0 10: -1 See Also Searching SeqAn - Sequence Analysis Library - www.seqan.de