+ if (abort == true) { if (calledHelp) { return 0; } return 2; }
+
+
+ //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 == "") {
+
+ m->setTreeFile(treefile);
+
+ if (groupfile != "") {
+ //read in group map info.
+ tmap = new TreeMap(groupfile);
+ tmap->readMap();
+ }else{ //fake out by putting everyone in one group
+ Tree* tree = new Tree(treefile); delete tree; //extracts names from tree to make faked out groupmap
+ tmap = new TreeMap();
+
+ for (int i = 0; i < m->Treenames.size(); i++) { tmap->addSeq(m->Treenames[i], "Group1"); }
+ }
+
+ if (namefile != "") { readNamesFile(); }
+
+ read = new ReadNewickTree(treefile);
+ int readOk = read->read(tmap);
+
+ if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine(); delete tmap; delete read; return 0; }
+
+ read->AssembleTrees();
+ T = read->getTrees();
+ delete read;
+
+ //make sure all files match
+ //if you provide a namefile we will use the numNames in the namefile as long as the number of unique match the tree names size.
+ int numNamesInTree;
+ if (namefile != "") {
+ if (numUniquesInName == m->Treenames.size()) { numNamesInTree = nameMap.size(); }
+ else { numNamesInTree = m->Treenames.size(); }
+ }else { numNamesInTree = m->Treenames.size(); }
+
+
+ //output any names that are in group file but not in tree
+ if (numNamesInTree < tmap->getNumSeqs()) {
+ for (int i = 0; i < tmap->namesOfSeqs.size(); i++) {
+ //is that name in the tree?
+ int count = 0;
+ for (int j = 0; j < m->Treenames.size(); j++) {
+ if (tmap->namesOfSeqs[i] == m->Treenames[j]) { break; } //found it
+ count++;
+ }
+
+ if (m->control_pressed) {
+ delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
+ for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear();
+ m->Groups.clear();
+ return 0;
+ }
+
+ //then you did not find it so report it
+ if (count == m->Treenames.size()) {
+ //if it is in your namefile then don't remove
+ map<string, string>::iterator it = nameMap.find(tmap->namesOfSeqs[i]);
+
+ if (it == nameMap.end()) {
+ m->mothurOut(tmap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); m->mothurOutEndLine();
+ tmap->removeSeq(tmap->namesOfSeqs[i]);
+ i--; //need this because removeSeq removes name from namesOfSeqs
+ }
+ }
+ }
+ }
+
+ if(outputDir == "") { outputDir += m->hasPath(treefile); }
+ output = new ColumnFile(outputDir + m->getSimpleName(treefile) + ".parsimony", itersString);
+ outputNames.push_back(outputDir + m->getSimpleName(treefile) + ".parsimony");
+ outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(treefile) + ".parsimony");
+
+ sumFile = outputDir + m->getSimpleName(treefile) + ".psummary";
+ m->openOutputFile(sumFile, outSum);
+ outputNames.push_back(sumFile);
+ outputTypes["psummary"].push_back(sumFile);
+ }else { //user wants random distribution
+ 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(m->Groups, tmap->namesOfGroups, allGroups, numGroups, "parsimony"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, m->Groups, numComp);
+ delete util;
+
+ if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
+
+ pars = new Parsimony(tmap);
+ counter = 0;