+
+ GroupMap designMap;
+ if (designfile == "") { //fake out designMap to run with process
+ process(designMap, "");
+ }else {
+ designMap.readDesignMap(designfile);
+
+ //fill Sets - checks for "all" and for any typo groups
+ SharedUtil util;
+ vector<string> nameSets = designMap.getNamesOfGroups();
+ util.setGroups(Sets, nameSets);
+
+ for (int i = 0; i < Sets.size(); i++) {
+ process(designMap, Sets[i]);
+ }
+ }
+
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+
+ m->mothurOutEndLine();
+ m->mothurOut("Output File Names: "); m->mothurOutEndLine();
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
+ m->mothurOutEndLine();
+
+ return 0;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "RareFactSharedCommand", "execute");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+
+int RareFactSharedCommand::process(GroupMap& designMap, string thisSet){
+ try {
+ Rarefact* rCurve;
+ vector<Display*> rDisplays;
+
+ InputData input(sharedfile, "sharedfile");
+ lookup = input.getSharedRAbundVectors();
+ if (lookup.size() < 2) {
+ m->mothurOut("I cannot run the command without at least 2 valid groups.");
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ return 0;
+ }
+
+ string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(sharedfile));
+
+ vector<string> newGroups = m->getGroups();
+ if (thisSet != "") { //make groups only filled with groups from this set so that's all inputdata will read
+ vector<string> thisSets; thisSets.push_back(thisSet);
+ newGroups = designMap.getNamesSeqs(thisSets);
+ fileNameRoot += thisSet + ".";
+ }
+
+ vector<SharedRAbundVector*> subset;
+ if (thisSet == "") { subset.clear(); subset = lookup; }
+ else {//fill subset with this sets groups
+ subset.clear();
+ for (int i = 0; i < lookup.size(); i++) {
+ if (m->inUsersGroups(lookup[i]->getGroup(), newGroups)) {
+ subset.push_back(lookup[i]);
+ }
+ }
+ }