]> git.donarmstrong.com Git - mothur.git/blobdiff - parselistscommand.cpp
Merge remote-tracking branch 'origin/master'
[mothur.git] / parselistscommand.cpp
index bb096d8646873f74c42bd8970b9eef9693a3252e..61cb2454b52ee9e05cf1027995906371b5463762 100644 (file)
 //**********************************************************************************************************************
 vector<string> ParseListCommand::setParameters(){      
        try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               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", "", "", "none", "none", "none","list",false,true,true); parameters.push_back(plist);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pgroup);
+               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,6 +46,21 @@ string ParseListCommand::getHelpString(){
        }
 }
 //**********************************************************************************************************************
+string ParseListCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        
+        if (type == "list") {  pattern = "[filename],[group],list"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "ParseListCommand", "getOutputPattern");
+        exit(1);
+    }
+}
+//**********************************************************************************************************************
 ParseListCommand::ParseListCommand(){  
        try {
                abort = true; calledHelp = true; 
@@ -170,7 +185,8 @@ int ParseListCommand::execute(){
                if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //set fileroot
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
+               map<string, string> variables; 
+        variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
                
                //fill filehandles with neccessary ofstreams
                int i;
@@ -180,7 +196,8 @@ int ParseListCommand::execute(){
                        temp = new ofstream;
                        filehandles[gGroups[i]] = temp;
                        
-                       string filename = fileroot +  gGroups[i] + ".list";
+            variables["[group]"] = gGroups[i];
+                       string filename = getOutputFileName("list",variables);
                        outputNames.push_back(filename); outputTypes["list"].push_back(filename);
                        m->openOutputFile(filename, *temp);
                }