]> git.donarmstrong.com Git - mothur.git/blobdiff - classifyotucommand.cpp
added forward and reverse barcodes to trim.seqs to process illumina seqs
[mothur.git] / classifyotucommand.cpp
index f36631a0590725867dffc402f74fd73af6168e20..ef41ee1bab8853f6741938005f775076b60723ab 100644 (file)
@@ -182,7 +182,7 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
                        else if (refTaxonomy == "not open") { abort = true; }
        
                        namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
+                       if (namefile == "not open") { namefile = ""; abort = true; }    
                        else if (namefile == "not found") { namefile = ""; }
                        else { m->setNameFile(namefile); }
                        
@@ -206,7 +206,7 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
                        if ((basis != "otu") && (basis != "sequence")) { m->mothurOut("Invalid option for basis. basis options are otu and sequence, using otu."); m->mothurOutEndLine(); }
                        
                        string temp = validParameter.validFile(parameters, "cutoff", false);                    if (temp == "not found") { temp = "51"; }
-                       convert(temp, cutoff); 
+                       m->mothurConvert(temp, cutoff); 
                        
                        temp = validParameter.validFile(parameters, "probs", false);                                    if (temp == "not found"){       temp = "true";                  }
                        probs = m->isTrue(temp);
@@ -214,6 +214,11 @@ ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
                        
                        if ((cutoff < 51) || (cutoff > 100)) { m->mothurOut("cutoff must be above 50, and no greater than 100."); m->mothurOutEndLine(); abort = true;  }
                        
+                       if (namefile == ""){
+                               vector<string> files; files.push_back(taxfile);
+                               parser.getNameFile(files);
+                       }
+                       
                }
        }
        catch(exception& e) {
@@ -470,6 +475,9 @@ vector<string> ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* th
                                }
                                
                        }
+            
+            //phylotree adds an extra unknown so we want to remove that
+            if (bestChild.name == "unknown") { bestChildSize--; }
                                
                        //is this taxonomy above cutoff
                        int consensusConfidence = ceil((bestChildSize / (float) size) * 100);
@@ -536,7 +544,9 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                        taxaSum = new PhyloSummary(groupfile);
                }
                
+
                //for each bin in the list vector
+        string snumBins = toString(processList->getNumBins());
                for (int i = 0; i < processList->getNumBins(); i++) {
                        
                        if (m->control_pressed) { break; }
@@ -547,7 +557,15 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                        if (m->control_pressed) { out.close();  return 0; }
                        
                        //output to new names file
-                       out << (i+1) << '\t' << size << '\t' << conTax << endl;
+            string binLabel = "Otu";
+            string sbinNumber = toString(i+1);
+            if (sbinNumber.length() < snumBins.length()) { 
+                int diff = snumBins.length() - sbinNumber.length();
+                for (int h = 0; h < diff; h++) { binLabel += "0"; }
+            }
+            binLabel += sbinNumber;
+
+                       out << binLabel << '\t' << size << '\t' << conTax << endl;
                        
                        string noConfidenceConTax = conTax;
                        m->removeConfidences(noConfidenceConTax);