+ //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["unweighted"] = tempOutNames;
+ outputTypes["uwsummary"] = tempOutNames;
+ outputTypes["phylip"] = tempOutNames;
+ outputTypes["column"] = tempOutNames;
+
+ if (globaldata->gTree.size() == 0) {//no trees were read
+ m->mothurOut("You must execute the read.tree command, before you may execute the unifrac.unweighted command."); 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 = "";
+ outputDir += m->hasPath(globaldata->inputFileName); //if user entered a file with a path then preserve it
+ }
+
+ //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 = ""; }
+ 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, "distance", false);
+ if (temp == "not found") { phylip = false; outputForm = ""; }
+ else{
+ if ((temp == "lt") || (temp == "column") || (temp == "square")) { phylip = true; outputForm = temp; }
+ else { m->mothurOut("Options for distance are: lt, square, or column. Using lt."); m->mothurOutEndLine(); phylip = true; outputForm = "lt"; }
+ }
+
+ temp = validParameter.validFile(parameters, "random", false); if (temp == "not found") { temp = "f"; }
+ random = m->isTrue(temp);
+
+ temp = validParameter.validFile(parameters, "root", false); if (temp == "not found") { temp = "F"; }
+ includeRoot = m->isTrue(temp);
+
+ temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = "1"; }
+ convert(temp, processors);
+
+ if (!random) { iters = 0; } //turn off random calcs
+
+ //if user selects distance = true and no groups it won't calc the pairwise
+ if ((phylip) && (Groups.size() == 0)) {
+ groups = "all";
+ m->splitAtDash(groups, Groups);
+ globaldata->Groups = Groups;
+ }
+
+ if (abort == false) {
+ T = globaldata->gTree;
+ tmap = globaldata->gTreemap;
+ sumFile = outputDir + m->getSimpleName(globaldata->getTreeFile()) + ".uwsummary";
+ outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile);
+ m->openOutputFile(sumFile, outSum);
+
+ util = new SharedUtil();
+ util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, globaldata->Groups, numComp);
+
+ if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
+
+ unweighted = new Unweighted(tmap, includeRoot);
+
+ }
+