]> git.donarmstrong.com Git - mothur.git/blobdiff - mergegroupscommand.cpp
changed random forest output filename
[mothur.git] / mergegroupscommand.cpp
index e30558cbe69d3069135e0432f2eda7f9623095b5..bfd1b8484eee963c897000a20024aae831c531f5 100644 (file)
 //**********************************************************************************************************************
 vector<string> MergeGroupsCommand::setParameters(){    
        try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none","shared",false,false,true); parameters.push_back(pshared);
+               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none","group",false,false,true); parameters.push_back(pgroup);
+               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pdesign);
+               CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+               CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+               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);          }
@@ -52,6 +52,23 @@ string MergeGroupsCommand::getHelpString(){
                exit(1);
        }
 }
+
+//**********************************************************************************************************************
+string MergeGroupsCommand::getOutputPattern(string type) {
+    try {
+        string pattern = "";
+        
+        if (type == "shared") {  pattern = "[filename],merge,[extension]"; } 
+        else if (type == "group") {  pattern = "[filename],merge,[extension]"; } 
+        else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true;  }
+        
+        return pattern;
+    }
+    catch(exception& e) {
+        m->errorOut(e, "MergeGroupsCommand", "getOutputPattern");
+        exit(1);
+    }
+}
 //**********************************************************************************************************************
 MergeGroupsCommand::MergeGroupsCommand(){      
        try {
@@ -284,8 +301,11 @@ int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "merge" +  m->getExtension(sharedfile);
-               outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile));
+        variables["[extension]"] = m->getExtension(sharedfile);
+               string outputFileName = getOutputFileName("shared", variables);
+        outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;
                m->openOutputFile(outputFileName, out);
@@ -387,7 +407,10 @@ int MergeGroupsCommand::processGroupFile(GroupMap*& designMap){
                
                string thisOutputDir = outputDir;
                if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "merge" +  m->getExtension(groupfile);
+        map<string, string> variables; 
+        variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+        variables["[extension]"] = m->getExtension(groupfile);
+               string outputFileName = getOutputFileName("group", variables);
                outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
                
                ofstream out;