]> git.donarmstrong.com Git - mothur.git/blobdiff - summarytaxcommand.cpp
added code to format fast files for uchime. started work on sff.multiple command
[mothur.git] / summarytaxcommand.cpp
index a19986aba92ffeae80d3786c2322dc3d7d5bb461..3e16e74005c5f0b7cfc62d32df7c172be805e511 100644 (file)
@@ -48,7 +48,26 @@ string SummaryTaxCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string SummaryTaxCommand::getOutputFileNameTag(string type, string inputName=""){      
+       try {
+        string outputFileName = "";
+               map<string, vector<string> >::iterator it;
+        
+        //is this a type this command creates
+        it = outputTypes.find(type);
+        if (it == outputTypes.end()) {  m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
+        else {
+            if (type == "summary")            {   outputFileName =  "tax.summary";   }
+            else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true;  }
+        }
+        return outputFileName;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "SummaryTaxCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 SummaryTaxCommand::SummaryTaxCommand(){        
        try {
@@ -157,6 +176,12 @@ SummaryTaxCommand::SummaryTaxCommand(string option)  {
                                outputDir = ""; 
                                outputDir += m->hasPath(taxfile); //if user entered a file with a path then preserve it 
                        }
+                       
+                       if (namefile == "") {
+                               vector<string> files; files.push_back(taxfile);
+                               parser.getNameFile(files);
+                       }
+                       
                }
        }
        catch(exception& e) {
@@ -219,7 +244,7 @@ int SummaryTaxCommand::execute(){
                
                //print summary file
                ofstream outTaxTree;
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "tax.summary";
+               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + getOutputFileNameTag("summary");
                m->openOutputFile(summaryFile, outTaxTree);
                taxaSum->print(outTaxTree);
                outTaxTree.close();