- int minValue = 2000;
- int closestSequenceNo = 0;
- string processedSeq = candidateSeq->convert2ints(); // the candidate sequence needs to be a string of ints
- for(int i=0;i<suffixForest.size();i++){ // scan through the forest and see what the minimum
- int count = suffixForest[i].countSuffixes(processedSeq, minValue); // return score is and keep track of the
- if(count == minValue){ // template sequence index that corresponds to that score
- closestSequenceNo = i;
+/**************************************************************************************************/
+//assumes sequences have been added using addSequence
+vector<int> SuffixDB::findClosestSequences(Sequence* candidateSeq, int num){
+ try {
+ vector<int> topMatches;
+ string processedSeq = candidateSeq->convert2ints(); // the candidate sequence needs to be a string of ints
+
+ vector<seqMatch> seqMatches;
+ for(int i=0;i<suffixForest.size();i++){ // scan through the forest and see what the minimum
+ int count = suffixForest[i].countSuffixes(processedSeq); // return score is and keep track of the
+ seqMatch temp(i, count);
+ seqMatches.push_back(temp);
+ }
+
+ //sorts putting smallest matches first
+ sort(seqMatches.begin(), seqMatches.end(), compareSeqMatchesReverse);
+
+ searchScore = seqMatches[0].match;
+ searchScore = 100 * (1. - searchScore / (float)processedSeq.length());
+
+ //save top matches
+ for (int i = 0; i < num; i++) {
+ topMatches.push_back(seqMatches[i].seq);