- //remove seqs not in sample from treemap
- for (int i = 0; i < tmap->namesOfSeqs.size(); i++) {
- //is that name in the subsample?
- int count = 0;
- for (int j = 0; j < subsampledSeqs.size(); j++) {
- if (tmap->namesOfSeqs[i] == subsampledSeqs[j]) { break; } //found it
- count++;
+ int thisSize = ct->getGroupCount(Groups[i]);
+
+ if (thisSize >= size) {
+
+ vector<string> names = ct->getNamesOfSeqs(Groups[i]);
+ vector<int> random;
+ for (int j = 0; j < names.size(); j++) {
+ int num = ct->getGroupCount(names[j], Groups[i]);
+ for (int k = 0; k < num; k++) { random.push_back(j); }
+ }
+ random_shuffle(random.begin(), random.end());
+
+ vector<int> sampleRandoms; sampleRandoms.resize(names.size(), 0);
+ for (int j = 0; j < size; j++) { sampleRandoms[random[j]]++; }
+ for (int j = 0; j < sampleRandoms.size(); j++) {
+ newCt->setAbund(names[j], Groups[i], sampleRandoms[j]);
+ }
+ sampleRandoms.clear(); sampleRandoms.resize(names.size(), 0);
+ for (int j = size; j < thisSize; j++) { sampleRandoms[random[j]]++; }
+ for (int j = 0; j < sampleRandoms.size(); j++) { doNotIncludeTotals[names[j]] += sampleRandoms[j]; }
+ }else { m->mothurOut("[ERROR]: You have selected a size that is larger than "+Groups[i]+" number of sequences.\n"); m->control_pressed = true; }