}
timesKmerFound[kmerNumber] = 1; // ok, we've seen the kmer now
}
-
- vector<seqMatch> seqMatches;
- for(int i=0;i<numSeqs;i++){
- seqMatch temp(i, matches[i]);
- seqMatches.push_back(temp);
- }
- //sorts putting largest matches first
- sort(seqMatches.begin(), seqMatches.end(), compareSeqMatches);
+ if (num != 1) {
+ vector<seqMatch> seqMatches; seqMatches.resize(numSeqs);
+ for(int i=0;i<numSeqs;i++){
+ seqMatches[i].seq = i;
+ seqMatches[i].match = matches[i];
+ }
+
+ //sorts putting largest matches first
+ sort(seqMatches.begin(), seqMatches.end(), compareSeqMatches);
+
+ searchScore = seqMatches[0].match;
+ searchScore = 100 * searchScore / (float) numKmers; // return the Sequence object corresponding to the db
- searchScore = seqMatches[0].match;
- searchScore = 100 * searchScore / (float) numKmers; // return the Sequence object corresponding to the db
-
- //save top matches
- for (int i = 0; i < num; i++) {
- topMatches.push_back(seqMatches[i].seq);
+ //save top matches
+ for (int i = 0; i < num; i++) {
+ topMatches.push_back(seqMatches[i].seq);
+ }
+ }else{
+ int bestIndex = 0;
+ int bestMatch = -1;
+ for(int i=0;i<numSeqs;i++){
+
+ if (matches[i] > bestMatch) {
+ bestIndex = i;
+ bestMatch = matches[i];
+ }
+ }
+
+ searchScore = bestMatch;
+ searchScore = 100 * searchScore / (float) numKmers; // return the Sequence object corresponding to the db
+ topMatches.push_back(bestIndex);
}
-
return topMatches;
}
catch(exception& e) {
try {
ofstream kmerFile; // once we have the kmerLocations folder print it out
- openOutputFile(kmerDBName, kmerFile); // to a file
+ m->openOutputFile(kmerDBName, kmerFile); // to a file
+
+ //output version
+ kmerFile << "#" << m->getVersion() << endl;
for(int i=0;i<maxKmer;i++){ // step through all of the possible kmer numbers
kmerFile << i << ' ' << kmerLocations[i].size(); // print the kmer number and the number of sequences with
kmerDBFile.seekg(0); // start at the beginning of the file
+ //read version
+ string line = m->getline(kmerDBFile); m->gobble(kmerDBFile);
+
string seqName;
int seqNumber;
exit(1);
}
}
-#ifdef USE_MPI
-/**************************************************************************************************/
-int KmerDB::MPISend(int receiver) {
- try {
-
- //send kmerSize - int
- MPI_Send(&kmerSize, 1, MPI_INT, receiver, 2001, MPI_COMM_WORLD);
-
- return 0;
- }
- catch(exception& e) {
- m->errorOut(e, "KmerDB", "MPISend");
- exit(1);
- }
-}
-/**************************************************************************************************/
-int KmerDB::MPIRecv(int sender) {
- try {
- MPI_Status status;
-
- //receive kmerSize - int
- MPI_Recv(&kmerSize, 1, MPI_INT, sender, 2001, MPI_COMM_WORLD, &status);
-
- //set maxKmer
- int power4s[14] = { 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864 };
- count = 0;
- maxKmer = power4s[kmerSize];
- kmerLocations.resize(maxKmer+1);
-
- return 0;
- }
- catch(exception& e) {
- m->errorOut(e, "KmerDB", "MPIRecv");
- exit(1);
- }
-}
-#endif
/**************************************************************************************************/