]> git.donarmstrong.com Git - mothur.git/blobdiff - getsabundcommand.cpp
added load.logfile command. changed summary.single output for subsample=t.
[mothur.git] / getsabundcommand.cpp
index 799d8dced192019f65a633e946262db92c1e615f..5425c41a917f4b02d67c5b4dfcb63e1b2fc6159b 100644 (file)
@@ -45,7 +45,26 @@ string GetSAbundCommand::getHelpString(){
                exit(1);
        }
 }
-
+//**********************************************************************************************************************
+string GetSAbundCommand::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 == "sabund")            {   outputFileName = "sabund";  }
+            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, "GetSAbundCommand", "getOutputFileNameTag");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 GetSAbundCommand::GetSAbundCommand(){  
        try {
@@ -166,7 +185,7 @@ int GetSAbundCommand::execute(){
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "sabund";
+               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("sabund");
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);
@@ -178,7 +197,7 @@ int GetSAbundCommand::execute(){
                set<string> processedLabels;
                set<string> userLabels = labels;
                
-               if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete sabund; delete input; return 0; }
+               if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete sabund; delete input; return 0; }
 
                
                while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
@@ -188,7 +207,7 @@ int GetSAbundCommand::execute(){
                                        
                                        sabund->print(out);
                                        
-                               if (m->control_pressed) { outputTypes.clear();  out.close(); remove(filename.c_str());  delete sabund; delete input;  return 0; }
+                               if (m->control_pressed) { outputTypes.clear();  out.close(); m->mothurRemove(filename);  delete sabund; delete input;  return 0; }
 
                                        processedLabels.insert(sabund->getLabel());
                                        userLabels.erase(sabund->getLabel());
@@ -203,7 +222,7 @@ int GetSAbundCommand::execute(){
                                        m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
                                        sabund->print(out);
                                        
-                                       if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete sabund; delete input;  return 0; }
+                                       if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete sabund; delete input;  return 0; }
 
                                        processedLabels.insert(sabund->getLabel());
                                        userLabels.erase(sabund->getLabel());
@@ -241,7 +260,7 @@ int GetSAbundCommand::execute(){
                        sabund->print(out);
                        delete sabund;
                        
-                       if (m->control_pressed) {  outputTypes.clear(); out.close(); remove(filename.c_str());  delete input; return 0; }
+                       if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete input; return 0; }
                        
                }