Hey,
the problem lies in the hash(indexShape(index), kmer) function.
The hash function only takes an iterator or pointer as second argument.
So in your case the simple solution would be to call the function hash(indexShape(index), it), while using an iterator to iterate over the text instead of using the unsigned integer. This little behaviour does not seem obvious, as in the tutorial
you pass a string literal. But in fact a string literal is just a const char *, so it works.
Here you see an example code to work with a) using the finder interface and b) directly operating on the index.
IHTH.
cheers,
René
typedef
Index<DnaString,
IndexQGram<UngappedShape<12> > > TQGramIndex;
typedef
Finder<TQGramIndex> TFinder;
typedef
Iterator<DnaString,
Standard>::Type TIterator;
typedef
Fibre<TQGramIndex,
QGramShape>::Type TShape;
TQGramIndex index(ref);
indexRequire(index,
QGramSADir());
// On-demand index creation.
// a) Using the finder interface.
TFinder finder(index);
for (TIterator it =
begin(query,
Standard()); it !=
end(query,
Standard()) - 12; ++it)
{
std::cout <<
"Occ at: ";
while(find(finder,
infix(query, it, it+12)))
std::cout <<
position(finder) <<
" ";
std::cout <<
std::endl;
clear(finder);
// Clear finder for next search.
}
// b) Using the index interface.
TShape & shape =
indexShape(index);
hashInit(shape,
begin(query,
Standard()));
for (TIterator it =
begin(query,
Standard()); it !=
end(query,
Standard()) - 12; ++it)
{
std::cout <<
"Occ at: ";
hashNext(shape, it);
for (unsigned i = 0; i <
length(getOccurrences(index, shape)); ++i)
std::cout <<
getOccurrences(index, shape)[i] <<
" ";
std::cout <<
std::endl;
}
---
René Rahn
Ph.D. Student
--------------------------------
Institute of Computer Science
Algorithmic Bioinformatics (ABI)
--------------------------------
Freie Universität Berlin
Takustraße 9
14195 Berlin
--------------------------------
|