]> git.donarmstrong.com Git - mothur.git/blob - phylotype.cpp
started work on classify.seqs command. changed the database class so that it does...
[mothur.git] / phylotype.cpp
1 /*
2  *  phylotype.cpp
3  *  Mothur
4  *
5  *  Created by westcott on 11/3/09.
6  *  Copyright 2009 Schloss Lab. All rights reserved.
7  *
8  */
9
10 #include "phylotype.h"
11
12 /**************************************************************************************************/
13 PhyloType::PhyloType(string tfile, string tempFile, string method, int kmerSize, int gapOpen, int gapExtend, int match, int misMatch) 
14 : Classify(tfile, tempFile, method, kmerSize, gapOpen, gapExtend, match, misMatch)  {}
15 /**************************************************************************************************/
16 string PhyloType::getTaxonomy(Sequence* seq) {
17         try {
18                 string tax;
19                 
20                 //use database to find closest seq
21                 vector<int> closest = database->findClosestSequences(seq, 1);
22                 
23                 //find that sequences taxonomy in map
24                 it = taxonomy.find(names[closest[0]]);
25                 
26                 //is this sequence in the taxonomy file
27                 if (it == taxonomy.end()) { //error not in file
28                         mothurOut("Error: sequence " + names[closest[0]] + " is not in the taxonomy file.  It is the closest match to sequence " + seq->getName() + ". " + seq->getName() + " will be disregarded."); mothurOutEndLine();
29                         tax = "bad seq";
30                 }else {
31                         tax = it->second;
32                 }
33                 
34                 return tax;     
35         }
36         catch(exception& e) {
37                 errorOut(e, "PhyloType", "getTaxonomy");
38                 exit(1);
39         }
40 }
41 /**************************************************************************************************/
42