+ }
+
+ //if the users entered no valid calculators don't execute command
+ if (rDisplays.size() == 0) { return 0; }
+
+ input = new InputData(sharedfile, "sharedfile");
+ lookup = input->getSharedRAbundVectors();
+ string lastLabel = lookup[0]->getLabel();
+
+ if (m->control_pressed) {
+ m->clearGroups();
+ delete input;
+ for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ return 0;
+ }
+
+
+ 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;
+ }
+
+ //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+ set<string> processedLabels;
+ set<string> userLabels = labels;
+
+ //as long as you are not at the end of the file or done wih the lines you want
+ while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
+ if (m->control_pressed) {
+ m->clearGroups();
+ delete input;
+ for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ return 0;
+ }
+
+ if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ rCurve = new Rarefact(lookup, rDisplays);
+ rCurve->getSharedCurve(freq, nIters);
+ delete rCurve;
+
+ processedLabels.insert(lookup[0]->getLabel());
+ userLabels.erase(lookup[0]->getLabel());
+ }
+
+ if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
+ string saveLabel = lookup[0]->getLabel();
+
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ lookup = input->getSharedRAbundVectors(lastLabel);
+
+ m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
+ rCurve = new Rarefact(lookup, rDisplays);
+ rCurve->getSharedCurve(freq, nIters);
+ delete rCurve;
+
+ processedLabels.insert(lookup[0]->getLabel());
+ userLabels.erase(lookup[0]->getLabel());
+
+ //restore real lastlabel to save below
+ lookup[0]->setLabel(saveLabel);
+ }
+
+
+ lastLabel = lookup[0]->getLabel();
+
+ //get next line to process
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ lookup = input->getSharedRAbundVectors();
+ }
+
+ if (m->control_pressed) {
+ m->clearGroups();
+ delete input;
+ for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
+ return 0;
+ }
+
+ //output error messages about any remaining user labels
+ set<string>::iterator it;
+ bool needToRun = false;
+ for (it = userLabels.begin(); it != userLabels.end(); it++) {
+ m->mothurOut("Your file does not include the label " + *it);
+ if (processedLabels.count(lastLabel) != 1) {
+ m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
+ needToRun = true;
+ }else {
+ m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();