]> git.donarmstrong.com Git - mothur.git/blobdiff - makegroupcommand.cpp
added distance option to summary.shared
[mothur.git] / makegroupcommand.cpp
index 1a2ffe65fd17c79cc28c6a1e7106012ad2e987c7..8dd1d67b294517437648f314321324ca8f1baf11 100644 (file)
@@ -37,10 +37,6 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
                        }
 
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-
                        //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 = "";          }
@@ -82,12 +78,17 @@ MakeGroupCommand::MakeGroupCommand(string option)  {
                                        }else{  filename += m->getRootName(m->getSimpleName(fastaFileNames[i]));  }
                                }
                                
-                               filename += "groups";
+                               //prevent giantic file name
+                               if (fastaFileNames.size() > 3) { filename = outputDir + "merge.groups"; }
+                               else {  filename += "groups";  }
                                
                                //make sure there is at least one valid file left
                                if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
                        }
                        
+                       //if the user changes the output directory command factory will send this info to us in the output parameter 
+                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
+                       
                        groups = validParameter.validFile(parameters, "groups", false);                 
                        if (groups == "not found") { m->mothurOut("groups is a required parameter for the make.group command."); m->mothurOutEndLine(); abort = true;  }
                        else { m->splitAtDash(groups, groupsNames);     }
@@ -130,6 +131,10 @@ int MakeGroupCommand::execute(){
        try {
                if (abort == true) {    return 0;       }
                
+               if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[0]); }
+               
+               filename = outputDir + filename;
+               
                ofstream out;
                m->openOutputFile(filename, out);