]> git.donarmstrong.com Git - mothur.git/blobdiff - catchallcommand.cpp
cluster.split fix
[mothur.git] / catchallcommand.cpp
index 434c2730bf9a551d4ca3b5282d2c653e776878b2..d6264db3309bd867696ee0b89041b9e34d3b6556 100644 (file)
 #include "catchallcommand.h"
 #include "globaldata.hpp"
 
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getValidParameters(){  
+       try {
+               string AlignArray[] =  {"sabund","label","inputdir","outputdir"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+CatchAllCommand::CatchAllCommand(){    
+       try {
+               //initialize outputTypes
+               
+               //need to determine outputFIles and types
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getRequiredParameters(){       
+       try {
+               string AlignArray[] =  {"sabund"};
+               vector<string> myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> CatchAllCommand::getRequiredFiles(){    
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CatchAllCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 /**************************************************************************************/
 CatchAllCommand::CatchAllCommand(string option)  {     
        try {
@@ -36,6 +83,11 @@ CatchAllCommand::CatchAllCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
                        
+                       
+                       //initialize outputTypes
+                       //need to determine outputFIles and types
+                       
+                       
                        //if the user changes the input directory command factory will send this info to us in the output parameter 
                        string inputDir = validParameter.validFile(parameters, "inputdir", false);              
                        if (inputDir == "not found"){   inputDir = "";          }
@@ -44,7 +96,7 @@ CatchAllCommand::CatchAllCommand(string option)  {
                                it = parameters.find("sabund");
                                //user has given a template file
                                if(it != parameters.end()){ 
-                                       path = hasPath(it->second);
+                                       path = m->hasPath(it->second);
                                        //if the user has not given a path then, add inputdir. else leave path alone.
                                        if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
                                }
@@ -53,13 +105,13 @@ CatchAllCommand::CatchAllCommand(string option)  {
                        //check for required parameters
                        sabundfile = validParameter.validFile(parameters, "sabund", true);
                        if (sabundfile == "not open") { sabundfile = ""; abort = true; }
-                       else if (sabundfile == "not found") { sabundfile = "";  m->mothurOut("You must provide either a sabund file for the catchall command."); m->mothurOutEndLine(); abort=true; }
+                       else if (sabundfile == "not found") { sabundfile = "";  m->mothurOut("You must provide a sabund file for the catchall command."); m->mothurOutEndLine(); abort=true; }
                        else { globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
                        
                        string label = validParameter.validFile(parameters, "label", false);                    
                        if (label == "not found") { label = ""; }
                        else { 
-                               if(label != "all") {  splitAtDash(label, labels);  allLines = 0;  }
+                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
                                else { allLines = 1;  }
                        }
                
@@ -99,16 +151,14 @@ int CatchAllCommand::execute() {
                
                if (abort == true) { return 0; }
                
-               vector<string> outputNames;
-               
                //prepare full output directory
-               outputDir = getFullPathName(outputDir);
+               outputDir = m->getFullPathName(outputDir);
                
                //get location of catchall
                GlobalData* globaldata = GlobalData::getInstance();
                string path = globaldata->argv;
                path = path.substr(0, (path.find_last_of('m')));
-               path = getFullPathName(path);
+               path = m->getFullPathName(path);
 
                string catchAllCommandExe = ""; 
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
@@ -159,7 +209,7 @@ cout << catchAllCommand << endl;
                                        userLabels.erase(sabund->getLabel());
                        }
                        
-                       if ((anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+                       if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
                                        string saveLabel = sabund->getLabel();
                                        
                                        delete sabund;          
@@ -264,11 +314,11 @@ cout << catchAllCommand << endl;
 //**********************************************************************************************************************
 string CatchAllCommand::process(SAbundVector* sabund) {
        try {
-               string filename = outputDir + getRootName(getSimpleName(sabundfile)) + sabund->getLabel() + ".catchall";
-               filename = getFullPathName(filename);
+               string filename = outputDir + m->getRootName(m->getSimpleName(sabundfile)) + sabund->getLabel() + ".catchall";
+               filename = m->getFullPathName(filename);
        
                ofstream out;
-               openOutputFile(filename, out);
+               m->openOutputFile(filename, out);
                
                for (int i = 1; i <= sabund->getMaxRank(); i++) {
                        int temp = sabund->get(i);