+//**********************************************************************************************************************
+int GetGroupsCommand::readShared(){
+ try {
+ string thisOutputDir = outputDir;
+ if (outputDir == "") { thisOutputDir += m->hasPath(sharedfile); }
+
+ InputData input(sharedfile, "sharedfile");
+ vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
+
+ bool wroteSomething = false;
+
+ while(lookup[0] != NULL) {
+
+ string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
+ ofstream out;
+ m->openOutputFile(outputFileName, out);
+ outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
+
+ if (m->control_pressed) { out.close(); m->mothurRemove(outputFileName); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
+
+ lookup[0]->printHeaders(out);
+
+ for (int i = 0; i < lookup.size(); i++) {
+ out << lookup[i]->getLabel() << '\t' << lookup[i]->getGroup() << '\t';
+ lookup[i]->print(out);
+ wroteSomething = true;
+
+ }
+
+ //get next line to process
+ //prevent memory leak
+ for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
+ lookup = input.getSharedRAbundVectors();
+
+ out.close();
+ }
+
+ if (wroteSomething == false) { m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine(); }
+
+ string groupsString = "";
+ for (int i = 0; i < Groups.size()-1; i++) { groupsString += Groups[i] + ", "; }
+ groupsString += Groups[Groups.size()-1];
+
+ m->mothurOut("Selected groups: " + groupsString + " from your shared file."); m->mothurOutEndLine();
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ m->errorOut(e, "GetGroupsCommand", "readShared");
+ exit(1);
+ }
+}