5 * Created by Pat Schloss on 12/29/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
14 #include "database.hpp"
15 #include "sequence.hpp"
16 #include "distancedb.hpp"
19 /**************************************************************************************************/
21 DistanceDB::DistanceDB(string fastaFileName, string distanceFileName) : Database(fastaFileName) {
24 openInputFile(distanceFileName, inputData);
25 int numCandSeqs=count(istreambuf_iterator<char>(inputData),istreambuf_iterator<char>(), '\n'); // count the number of
26 inputData.seekg(0); // sequences
29 string candidateSeqName;
32 mostSimSequenceVector.resize(numCandSeqs);
34 for(int i=0;i<numCandSeqs;i++){
35 inputData >> candidateSeqName >> closestMatch.seqName >> closestMatch.indexNumber >> closestMatch.simScore;
36 // getline(inputData, junk);
37 mostSimSequenceVector[i] = closestMatch;
39 cout << numCandSeqs << endl;
44 /**************************************************************************************************/
46 Sequence* DistanceDB::findClosestSequence(Sequence* candidateSeq){
48 hit simAccession = mostSimSequenceVector[searchIndex];
49 // string candidateSeqName, closestMatchSeqName, junk;
50 // int closestMatchIndexNumber;
51 // float closestMatchSimScore;
53 // inputData >> candidateSeqName >> closestMatchSeqName >> closestMatchIndexNumber >> closestMatchSimScore;
54 // getline(inputData, junk);
56 // searchScore = 100. * closestMatchSimScore;
58 searchScore = 100. * simAccession.simScore;
60 // return templateSequences[closestMatchIndexNumber];
61 return templateSequences[simAccession.indexNumber];
65 /**************************************************************************************************/