]> git.donarmstrong.com Git - mothur.git/blobdiff - classifyotucommand.cpp
added sequence name to error string in fastq.info. Changed np_shannon to npshannon.
[mothur.git] / classifyotucommand.cpp
index 7b1a04f3658bcb0a3e919fefe34a30dedcfaa882..c8896375b016ef6c45462351a18e8e520bfe75c2 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) {
@@ -368,7 +373,7 @@ int ClassifyOtuCommand::readTaxonomyFile() {
                        m->gobble(in);
                        
                        //are there confidence scores, if so remove them
-                       if (tax.find_first_of('(') != -1) {  removeConfidences(tax);    }
+                       if (tax.find_first_of('(') != -1) {  m->removeConfidences(tax); }
                        
                        taxMap[name] = tax;
                        
@@ -550,7 +555,7 @@ int ClassifyOtuCommand::process(ListVector* processList) {
                        out << (i+1) << '\t' << size << '\t' << conTax << endl;
                        
                        string noConfidenceConTax = conTax;
-                       removeConfidences(noConfidenceConTax);
+                       m->removeConfidences(noConfidenceConTax);
                        
                        //add this bins taxonomy to summary
                        if (basis == "sequence") {
@@ -604,36 +609,6 @@ string ClassifyOtuCommand::addUnclassifieds(string tax, int maxlevel) {
                exit(1);
        }
 }
-
-/**************************************************************************************************/
-void ClassifyOtuCommand::removeConfidences(string& tax) {
-       try {
-               
-               string taxon;
-               string newTax = "";
-               
-               while (tax.find_first_of(';') != -1) {
-                       //get taxon
-                       taxon = tax.substr(0,tax.find_first_of(';'));
-                       
-                       int pos = taxon.find_first_of('(');
-                       if (pos != -1) {
-                               taxon = taxon.substr(0, pos); //rip off confidence 
-                       }
-                       
-                       taxon += ";";
-                       
-                       tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-                       newTax += taxon;
-               }
-               
-               tax = newTax;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "removeConfidences");
-               exit(1);
-       }
-}
 //**********************************************************************************************************************