]> git.donarmstrong.com Git - mothur.git/blob - distancedb.cpp
added alignment code
[mothur.git] / distancedb.cpp
1 /*
2  *  distancedb.cpp
3  *  
4  *
5  *  Created by Pat Schloss on 12/29/08.
6  *  Copyright 2008 Patrick D. Schloss. All rights reserved.
7  *
8  */
9
10
11 using namespace std;
12
13
14 #include "database.hpp"
15 #include "sequence.hpp"
16 #include "distancedb.hpp"
17
18
19 /**************************************************************************************************/
20
21 DistanceDB::DistanceDB(string fastaFileName, string distanceFileName) : Database(fastaFileName) {
22         
23         ifstream inputData;
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
27
28         hit closestMatch;
29         string candidateSeqName;
30         string junk;
31         
32         mostSimSequenceVector.resize(numCandSeqs);
33         
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;
38         }
39         cout << numCandSeqs << endl;
40         searchIndex = 0;
41         inputData.close();
42 }
43
44 /**************************************************************************************************/
45
46 Sequence* DistanceDB::findClosestSequence(Sequence* candidateSeq){
47         
48         hit simAccession = mostSimSequenceVector[searchIndex];
49 //      string candidateSeqName, closestMatchSeqName, junk;
50 //      int closestMatchIndexNumber;
51 //      float closestMatchSimScore;
52 //      
53 //      inputData >> candidateSeqName >> closestMatchSeqName >> closestMatchIndexNumber >> closestMatchSimScore;
54 //      getline(inputData, junk);       
55
56 //      searchScore = 100. * closestMatchSimScore;
57
58         searchScore = 100. * simAccession.simScore;
59         searchIndex++;
60 //      return templateSequences[closestMatchIndexNumber];
61         return templateSequences[simAccession.indexNumber];
62         
63 }
64
65 /**************************************************************************************************/