- //if the user only entered invalid groups
- if (globaldata->Groups.size() == 0) {
- cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl;
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- globaldata->Groups.push_back(tmap->namesOfGroups[i]);
- }
- }
- }else {
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- globaldata->Groups.push_back(tmap->namesOfGroups[i]);
+ randomtree = validParameter.validFile(parameters, "random", false); if (randomtree == "not found") { randomtree = ""; }
+
+ //are you trying to use parsimony without reading a tree or saying you want random distribution
+ if (randomtree == "") {
+ if (globaldata->gTree.size() == 0) {
+ m->mothurOut("You must read a treefile and a groupfile or set the randomtree parameter to the output filename you wish, before you may execute the parsimony command."); m->mothurOutEndLine(); abort = true; }
+ }
+
+ //if the user changes the output directory command factory will send this info to us in the output parameter
+ string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; if (randomtree == "") { outputDir += m->hasPath(globaldata->inputFileName); } }
+
+ //check for optional parameter and set defaults
+ // ...at some point should added some additional type checking...
+ groups = validParameter.validFile(parameters, "groups", false);
+ if (groups == "not found") { groups = ""; globaldata->Groups.clear(); }
+ else {
+ m->splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; }
+ convert(itersString, iters);
+
+ string temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = "1"; }
+ convert(temp, processors);
+
+ if (abort == false) {
+ //randomtree will tell us if user had their own treefile or if they just want the random distribution
+ //user has entered their own tree
+ if (randomtree == "") {
+ T = globaldata->gTree;
+ tmap = globaldata->gTreemap;
+
+ if(outputDir == "") { outputDir += m->hasPath(globaldata->getTreeFile()); }
+ output = new ColumnFile(outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".parsimony", itersString);
+ outputNames.push_back(outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".parsimony");
+ outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".parsimony");
+
+ sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".psummary";
+ m->openOutputFile(sumFile, outSum);
+ outputNames.push_back(sumFile);
+ outputTypes["psummary"].push_back(sumFile);
+ }else { //user wants random distribution
+ savetmap = globaldata->gTreemap;
+ getUserInput();
+
+ if(outputDir == "") { outputDir += m->hasPath(randomtree); }
+ output = new ColumnFile(outputDir+ m->getSimpleName(randomtree), itersString);
+ outputNames.push_back(outputDir+ m->getSimpleName(randomtree));
+ outputTypes["parsimony"].push_back(outputDir+ m->getSimpleName(randomtree));