+ m->errorOut(e, "SubSample", "getSample-TreeMap");
+ exit(1);
+ }
+}
+
+//**********************************************************************************************************************
+vector<string> SubSample::getSample(TreeMap* tMap, int size) {
+ try {
+ vector<string> sample;
+
+ vector<string> Groups = tMap->getNamesOfGroups();
+ for (int i = 0; i < Groups.size(); i++) {
+
+ if (m->inUsersGroups(Groups[i], m->getGroups())) {
+ if (m->control_pressed) { break; }
+
+ vector<string> thisGroup; thisGroup.push_back(Groups[i]);
+ vector<string> thisGroupsSeqs = tMap->getNamesSeqs(thisGroup);
+ int thisSize = thisGroupsSeqs.size();
+
+ if (thisSize >= size) {
+
+ random_shuffle(thisGroupsSeqs.begin(), thisGroupsSeqs.end());
+
+ for (int j = 0; j < size; j++) { sample.push_back(thisGroupsSeqs[j]); }
+ }else { m->mothurOut("[ERROR]: You have selected a size that is larger than "+Groups[i]+" number of sequences.\n"); m->control_pressed = true; }
+ }
+ }
+
+ return sample;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SubSample", "getSample-TreeMap");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
+vector<string> SubSample::getSample(TreeMap* tMap, vector<string> Groups) {
+ try {
+ vector<string> sample;
+
+ //vector<string> Groups = tMap->getNamesOfGroups();
+ for (int i = 0; i < Groups.size(); i++) {
+
+ if (m->control_pressed) { break; }
+
+ vector<string> thisGroup; thisGroup.push_back(Groups[i]);
+ vector<string> thisGroupsSeqs = tMap->getNamesSeqs(thisGroup);
+ int thisSize = thisGroupsSeqs.size();
+
+ for (int j = 0; j < thisSize; j++) { sample.push_back(thisGroupsSeqs[j]); }
+ }
+
+ return sample;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SubSample", "getSample-TreeMap");