-vector<string> SubSample::getSample(TreeMap* tMap, int size, map<string, vector<string> >& sample) {
- try {
- vector<string> temp2;
- sample["doNotIncludeMe"] = temp2;
-
- vector<string> namesInSample;
-
- 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();
- vector<string> temp;
- sample[Groups[i]] = temp;
-
- if (thisSize >= size) {
-
- random_shuffle(thisGroupsSeqs.begin(), thisGroupsSeqs.end());
-
- for (int j = 0; j < size; j++) { sample[Groups[i]].push_back(thisGroupsSeqs[j]); namesInSample.push_back(thisGroupsSeqs[j]); }
- for (int j = size; j < thisSize; j++) { sample["doNotIncludeMe"].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 namesInSample;
- }
- catch(exception& e) {
- 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");
- exit(1);
- }
-}
-//**********************************************************************************************************************