[Seqan-dev] questions about FindPattern
Hi!
Here is a simple code extract:
vector<SearchResult> StringUtils::findDnaPattern(const CharString&
query, const CharString &source, int minScore)
{
using namespace seqan;
vector<SearchResult> results;
// Question:Why do we have to copy to be able perform search!?
CharString sourceCopy(source);
CharString queryCopy(query);
Finder<CharString> directFinder(sourceCopy);
Pattern<CharString, DPSearch<SimpleScore> > pattern(queryCopy,
SimpleScore(0, -2, -1));
while (seqan::find(directFinder, pattern, minScore)) {
while (seqan::findBegin(directFinder, pattern, getScore(pattern))) {
// Question: how do I get the score of the alignment?
SearchResult r(beginPosition(directFinder), true);
results.push_back(r);
}
}
seqan::reverseComplement(queryCopy);
Pattern<CharString, DPSearch<SimpleScore> > revPattern(queryCopy,
SimpleScore(0, -2, -1));
Finder<CharString> revFinder(sourceCopy);
while (seqan::find(revFinder, revPattern, minScore)) {
while (seqan::findBegin(revFinder, revPattern, getScore(revPattern))) {
SearchResult r(beginPosition(revFinder), false);
results.push_back(r);
}
}
return results;
}
Questions are the following:
1) How is it possible to instance Pattern and Finder objects using
const references? Code doesn't compile if I am not copying the
sequences.
2) How can I get the score of the alignment (while iterating over
pattern results)?
3) Is there an easier way to search for pattern in reverse complement sequence?
Env: Ubuntu 12.04, gcc 4.7, seqan rev 13572
Thanks in advance,
Konstantin