X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=kmerdb.cpp;h=9652ac472fe38e14bff9707afdaba95526c35bff;hp=27e6997d27878577e9121e6ecfb8950cee02e0c7;hb=544469443afe44920bdf279aefd26d29534cabaf;hpb=a6c698b20eda3671d22466ab6b98b36331a30804 diff --git a/kmerdb.cpp b/kmerdb.cpp index 27e6997..9652ac4 100644 --- a/kmerdb.cpp +++ b/kmerdb.cpp @@ -57,20 +57,19 @@ KmerDB::KmerDB(string fastaFileName, int kSize) : Database(fastaFileName), kmerS /**************************************************************************************************/ Sequence* KmerDB::findClosestSequence(Sequence* candidateSeq){ - - vector matches(numSeqs, 0); // a record of the sequences with shared kmers - vector timesKmerFound(kmerLocations.size()+1, 0); // a record of the kmers that we have already found + + Kmer kmer(kmerSize); searchScore = 0; int maxSequence = 0; - - string query = candidateSeq->getUnaligned(); // we want to search using an unaligned dna sequence - int numKmers = query.length() - kmerSize + 1; - Kmer kmer(kmerSize); - + vector matches(numSeqs, 0); // a record of the sequences with shared kmers + vector timesKmerFound(kmerLocations.size()+1, 0); // a record of the kmers that we have already found + + int numKmers = candidateSeq->getNumBases() - kmerSize + 1; + for(int i=0;igetUnaligned(), i); // go through the query sequence and get a kmer number if(timesKmerFound[kmerNumber] == 0){ // if we haven't seen it before... for(int j=0;j searchScore){ // the query sequence + if(matches[i] > searchScore){ // the query sequence searchScore = matches[i]; maxSequence = i; } } - searchScore = 100 * searchScore / (float)numKmers; - return templateSequences[maxSequence]; // return the Sequence object corresponding to the db - // sequence with the most shared kmers. + + searchScore = 100 * searchScore / (float) numKmers; // return the Sequence object corresponding to the db + return templateSequences[maxSequence]; // sequence with the most shared kmers. } /**************************************************************************************************/