Re: [Seqan-dev] Trouble Hashing Kmers into Qgram Index
- From: Rahn, René <rene.maerker@fu-berlin.de>
- To: SeqAn Development <seqan-dev@lists.fu-berlin.de>
- Date: Wed, 19 Nov 2014 13:25:20 +0100
- Reply-to: SeqAn Development <seqan-dev@lists.fu-berlin.de>
- Subject: Re: [Seqan-dev] Trouble Hashing Kmers into Qgram Index
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
--------------------------------
|
- Follow-Ups:
- Re: [Seqan-dev] Trouble Hashing Kmers into Qgram Index
- From: Brett Bowman <bnbowman@gmail.com>
- Re: [Seqan-dev] Trouble Hashing Kmers into Qgram Index
- References:
- [Seqan-dev] Trouble Hashing Kmers into Qgram Index
- From: Brett Bowman <bnbowman@gmail.com>
- [Seqan-dev] Trouble Hashing Kmers into Qgram Index
-
seqan-dev - November 2014 - Archives indexes sorted by:
[ thread ] [ subject ] [ author ] [ date ] - Complete archive of the seqan-dev mailing list
- More info on this list...