]> git.donarmstrong.com Git - mothur.git/blobdiff - catchallcommand.cpp
added unix to ifdefs. minor changes while testing 1.24.0.
[mothur.git] / catchallcommand.cpp
index 1e89cdcca0d5230867356d37f8c6404a98639da6..bf866cbedca07b7ee8b732eec683c64520ee2017 100644 (file)
@@ -72,6 +72,7 @@ CatchAllCommand::CatchAllCommand(string option)  {
                
                //allow user to run help
                if(option == "help") { help(); abort = true; calledHelp = true; }
+               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
                
                else {
                        vector<string> myArray = setParameters();
@@ -118,10 +119,12 @@ CatchAllCommand::CatchAllCommand(string option)  {
                        sabundfile = validParameter.validFile(parameters, "sabund", true);
                        if (sabundfile == "not open") { sabundfile = ""; abort = true; }
                        else if (sabundfile == "not found") { sabundfile = "";  }
+                       else { m->setSabundFile(sabundfile); }
                        
                        sharedfile = validParameter.validFile(parameters, "shared", true);
                        if (sharedfile == "not open") { sharedfile = ""; abort = true; }
                        else if (sharedfile == "not found") { sharedfile = "";   }
+                       else { m->setSharedFile(sharedfile); }
                        
                        string label = validParameter.validFile(parameters, "label", false);                    
                        if (label == "not found") { label = ""; }
@@ -173,7 +176,7 @@ int CatchAllCommand::execute() {
                
                savedOutputDir = outputDir;
                string catchAllCommandExe = ""; 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                        catchAllCommandExe += "mono " + path + "CatchAllcmdL.exe ";
                        if (outputDir == "") { outputDir = "./"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd.
                #else
@@ -210,7 +213,7 @@ int CatchAllCommand::execute() {
                        
                        //for each label the user selected
                        while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-
+                               
                                                
                                if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
                                                m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
@@ -218,10 +221,10 @@ int CatchAllCommand::execute() {
                                                //create catchall input file from mothur's inputfile
                                                string filename = process(sabund, inputFileNames[p]);
                                                string outputPath = m->getPathName(filename);
-                                       
+                                                                                       
                                                //create system command
                                                string catchAllCommand = "";
-                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                                #else
                                                        if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
@@ -233,7 +236,7 @@ int CatchAllCommand::execute() {
                                                //run catchall
                                                system(catchAllCommand.c_str());
                                        
-                                               remove(filename.c_str());
+                                               m->mothurRemove(filename);
                                        
                                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
@@ -245,7 +248,7 @@ int CatchAllCommand::execute() {
                                        
                                                createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
                                                                                        
-                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str());    }  delete input;  delete sabund;  return 0; }
+                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);   }  delete input;  delete sabund;  return 0; }
 
                                                processedLabels.insert(sabund->getLabel());
                                                userLabels.erase(sabund->getLabel());
@@ -263,10 +266,10 @@ int CatchAllCommand::execute() {
                                                //create catchall input file from mothur's inputfile
                                                string filename = process(sabund, inputFileNames[p]);
                                                string outputPath = m->getPathName(filename);
-                                               
+                                                                                       
                                                //create system command
                                                string catchAllCommand = "";
-                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                                #else
                                                        if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
@@ -277,7 +280,7 @@ int CatchAllCommand::execute() {
                                                //run catchall
                                                system(catchAllCommand.c_str());
                                        
-                                               remove(filename.c_str());
+                                               m->mothurRemove(filename);
                                        
                                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
@@ -289,7 +292,7 @@ int CatchAllCommand::execute() {
                                        
                                                createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
                                        
-                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str());    }  delete input;  delete sabund;  return 0; }
+                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);   }  delete input;  delete sabund;  return 0; }
 
                                                processedLabels.insert(sabund->getLabel());
                                                userLabels.erase(sabund->getLabel());
@@ -331,7 +334,7 @@ int CatchAllCommand::execute() {
                                
                                //create system command
                                string catchAllCommand = "";
-                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
                                        catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
                                #else
                                        if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
@@ -342,7 +345,7 @@ int CatchAllCommand::execute() {
                                //run catchall
                                system(catchAllCommand.c_str());
                                
-                               remove(filename.c_str());
+                               m->mothurRemove(filename);
                                
                                filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
                                if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
@@ -360,7 +363,7 @@ int CatchAllCommand::execute() {
                        out.close();
                        delete input; 
                        
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {remove(outputNames[i].c_str()); } return 0; }
+                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);        } return 0; }
                                
                }
                
@@ -468,7 +471,7 @@ string CatchAllCommand::combineSummmary(vector<string>& outputNames) {
                        numLines = thisFilesLines.size();
                        
                        temp.close();
-                       remove(outputNames[i].c_str());
+                       m->mothurRemove(outputNames[i]);
                }
                
                //for each label
@@ -576,7 +579,7 @@ vector<string> CatchAllCommand::parseSharedFile(string filename) {
                
                //clears file before we start to write to it below
                for (int i=0; i<lookup.size(); i++) {
-                       remove((sharedFileRoot + lookup[i]->getGroup() + ".sabund").c_str());
+                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
                        filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
                        groups.push_back(lookup[i]->getGroup());
                }