5 * Created by Pat Schloss on 12/29/08.
6 * Copyright 2008 Patrick D. Schloss. All rights reserved.
11 #include "database.hpp"
12 #include "sequence.hpp"
13 #include "distancedb.hpp"
16 /**************************************************************************************************/
18 DistanceDB::DistanceDB(string fastaFileName, string distanceFileName) : Database(fastaFileName) {
21 openInputFile(distanceFileName, inputData);
22 int numCandSeqs=count(istreambuf_iterator<char>(inputData),istreambuf_iterator<char>(), '\n'); // count the number of
23 inputData.seekg(0); // sequences
26 string candidateSeqName;
29 mostSimSequenceVector.resize(numCandSeqs);
31 for(int i=0;i<numCandSeqs;i++){
32 inputData >> candidateSeqName >> closestMatch.seqName >> closestMatch.indexNumber >> closestMatch.simScore;
33 // getline(inputData, junk);
34 mostSimSequenceVector[i] = closestMatch;
36 cout << numCandSeqs << endl;
41 /**************************************************************************************************/
43 Sequence DistanceDB::findClosestSequence(Sequence* candidateSeq){
45 hit simAccession = mostSimSequenceVector[searchIndex];
46 // string candidateSeqName, closestMatchSeqName, junk;
47 // int closestMatchIndexNumber;
48 // float closestMatchSimScore;
50 // inputData >> candidateSeqName >> closestMatchSeqName >> closestMatchIndexNumber >> closestMatchSimScore;
51 // getline(inputData, junk);
53 // searchScore = 100. * closestMatchSimScore;
55 searchScore = 100. * simAccession.simScore;
57 // return templateSequences[closestMatchIndexNumber];
58 return templateSequences[simAccession.indexNumber];
62 /**************************************************************************************************/