]> git.donarmstrong.com Git - mothur.git/blobdiff - getsabundcommand.cpp
fixed bug in phylo.diversity rooting. added filename patterns and create filename...
[mothur.git] / getsabundcommand.cpp
index 50692495b9c87f83cfde870168c5214a41b9a7ac..237506e666641ab80e263db5573aec13756e3429 100644 (file)
 //**********************************************************************************************************************
 vector<string> GetSAbundCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);            
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none","sabund",false,false, true); parameters.push_back(plist);
+               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none","sabund",false,false, true); parameters.push_back(prabund);             
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
                
                vector<string> myArray;
                for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
@@ -46,24 +46,19 @@ string GetSAbundCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
-string GetSAbundCommand::getOutputFileNameTag(string type, string inputName=""){       
-       try {
-        string outputFileName = "";
-               map<string, vector<string> >::iterator it;
+string GetSAbundCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
         
-        //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);
-       }
+        if (type == "sabund")      {   pattern = "[filename],sabund";    }
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "GetRAbundCommand", "getOutputPattern");
+        exit(1);
+    }
 }
 //**********************************************************************************************************************
 GetSAbundCommand::GetSAbundCommand(){  
@@ -185,7 +180,9 @@ int GetSAbundCommand::execute(){
        try {
                
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("sabund");
+        map<string, string> variables; 
+               variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputfile));
+               filename = getOutputFileName("sabund", variables);
                m->openOutputFile(filename, out);
                
                input = new InputData(inputfile, format);