- int binSize = getNumNames(get(i)); //find number of individual in given bin
- names = get(i);
- while (names.find_first_of(',') != -1) {
- name = names.substr(0,names.find_first_of(','));
- names = names.substr(names.find_first_of(',')+1, names.length());
- groupName = groupmap->getGroup(name);
- order->push_back(i, binSize, groupName); //i represents what bin you are in
+ int binSize = m->getNumNames(get(i)); //find number of individual in given bin
+ string names = get(i);
+ vector<string> binNames;
+ m->splitAtComma(names, binNames);
+ if (m->groupMode != "group") {
+ binSize = 0;
+ for (int j = 0; j < binNames.size(); j++) { binSize += countTable->getNumSeqs(binNames[i]); }
+ }
+ for (int j = 0; j < binNames.size(); j++) {
+ if (m->control_pressed) { return order; }
+ if (m->groupMode == "group") {
+ string groupName = groupmap->getGroup(binNames[i]);
+ if(groupName == "not found") { m->mothurOut("Error: Sequence '" + binNames[i] + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
+
+ order->push_back(i, binSize, groupName); //i represents what bin you are in
+ }else {
+ vector<int> groupAbundances = countTable->getGroupCounts(binNames[i]);
+ vector<string> groupNames = countTable->getNamesOfGroups();
+ for (int k = 0; k < groupAbundances.size(); k++) { //groupAbundances.size() == 0 if there is a file mismatch and m->control_pressed is true.
+ if (m->control_pressed) { return order; }
+ for (int l = 0; l < groupAbundances[k]; l++) { order->push_back(i, binSize, groupNames[k]); }
+ }
+ }