- //user has entered their own tree
- if (randomtree == "") {
- T = globaldata->gTree;
- tmap = globaldata->gTreemap;
- parsFile = globaldata->getTreeFile() + ".parsimony";
- openOutputFile(parsFile, out);
- sumFile = globaldata->getTreeFile() + ".psummary";
- openOutputFile(sumFile, outSum);
- //set users groups to analyze
- setGroups();
- }else { //user wants random distribution
- savetmap = globaldata->gTreemap;
- getUserInput();
- parsFile = randomtree + ".rd_parsimony";
- openOutputFile(parsFile, out);
+ //check to make sure all parameters are valid for command
+ for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
+ if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
+ }
+
+ //initialize outputTypes
+ vector<string> tempOutNames;
+ outputTypes["parsimony"] = tempOutNames;
+ outputTypes["psummary"] = tempOutNames;
+
+ 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));
+ }
+
+ //set users groups to analyze
+ util = new SharedUtil();
+ util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "parsimony"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, globaldata->Groups, numComp);
+
+ if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
+
+ pars = new Parsimony(tmap);
+ counter = 0;
+
+ }
+