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 mostSimSequenceVector[i] = closestMatch;
35 mothurOut(toString(numCandSeqs)); mothurOutEndLine();
40 /**************************************************************************************************/
42 Sequence DistanceDB::findClosestSequence(Sequence* candidateSeq){
44 hit simAccession = mostSimSequenceVector[searchIndex];
45 // string candidateSeqName, closestMatchSeqName, junk;
46 // int closestMatchIndexNumber;
47 // float closestMatchSimScore;
49 // inputData >> candidateSeqName >> closestMatchSeqName >> closestMatchIndexNumber >> closestMatchSimScore;
50 // getline(inputData, junk);
52 // searchScore = 100. * closestMatchSimScore;
54 searchScore = 100. * simAccession.simScore;
56 // return templateSequences[closestMatchIndexNumber];
57 if (templateValid) { return templateSequences[simAccession.indexNumber]; }
58 else { return emptySequence; }
62 /**************************************************************************************************/