+ string binLabel = "Otu";
+ string sbinNumber = toString(i+1);
+ if (sbinNumber.length() < snumBins.length()) {
+ int diff = snumBins.length() - sbinNumber.length();
+ for (int h = 0; h < diff; h++) { binLabel += "0"; }
+ }
+ binLabel += sbinNumber;
+
+ out << binLabel << '\t' << size << '\t' << conTax << endl;
+
+ string noConfidenceConTax = conTax;
+ m->removeConfidences(noConfidenceConTax);
+
+ //add this bins taxonomy to summary
+ if (basis == "sequence") {
+ for(int j = 0; j < names.size(); j++) {
+ int numReps = 1;
+ if (countfile != "") { numReps = ct->getNumSeqs(names[j]); }
+ for(int k = 0; k < numReps; k++) { taxaSum->addSeqToTree(names[j], noConfidenceConTax); }
+ }
+ }else { //otu
+ map<string, bool> containsGroup;
+ if (countfile != "") {
+ if (ct->hasGroupInfo()) {
+ vector<string> mGroups = ct->getNamesOfGroups();
+ for (int k = 0; k < names.size(); k++) {
+ vector<int> counts = ct->getGroupCounts(names[k]);
+ for (int h = 0; h < counts.size(); h++) {
+ if (counts[h] != 0) { containsGroup[mGroups[h]] = true; }
+ }
+ }
+ }
+ }else {
+ if (groupfile != "") {
+ vector<string> mGroups = groupMap->getNamesOfGroups();
+ for (int j = 0; j < mGroups.size(); j++) { containsGroup[mGroups[j]] = false; }
+
+ for (int k = 0; k < names.size(); k++) {
+ //find out the sequences group
+ string group = groupMap->getGroup(names[k]);
+
+ if (group == "not found") { m->mothurOut("[WARNING]: " + names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine(); }
+ else {
+ containsGroup[group] = true;
+ }
+ }
+ }
+ }
+ taxaSum->addSeqToTree(noConfidenceConTax, containsGroup);
+ }
+
+
+ if (persample) {
+ //divide names by group
+ map<string, vector<string> > parsedNames;
+ map<string, vector<string> >::iterator itParsed;
+
+ //parse names by group
+ for (int j = 0; j < names.size(); j++) {
+ if (groupfile != "") {
+ string group = groupMap->getGroup(names[j]);
+ itParsed = parsedNames.find(group);
+
+ if (itParsed != parsedNames.end()) { itParsed->second.push_back(names[j]); }
+ else { vector<string> tempNames; tempNames.push_back(names[j]); parsedNames[group] = tempNames; }
+ }else { //count file was used
+ vector<string> thisSeqsGroups = ct->getGroups(names[j]);
+ for (int k = 0; k < thisSeqsGroups.size(); k++) {
+ string group = thisSeqsGroups[k];
+ itParsed = parsedNames.find(group);
+
+ if (itParsed != parsedNames.end()) { itParsed->second.push_back(names[j]); }
+ else { vector<string> tempNames; tempNames.push_back(names[j]); parsedNames[group] = tempNames; }
+ }
+ }
+ }
+
+ for (itParsed = parsedNames.begin(); itParsed != parsedNames.end(); itParsed++) {
+ vector<string> theseNames = findConsensusTaxonomy(itParsed->second, size, conTax);
+
+ if (m->control_pressed) { break; }
+
+ //output to new names file
+ string binLabel = "Otu";
+ string sbinNumber = toString(i+1);
+ if (sbinNumber.length() < snumBins.length()) {
+ int diff = snumBins.length() - sbinNumber.length();
+ for (int h = 0; h < diff; h++) { binLabel += "0"; }
+ }
+ binLabel += sbinNumber;
+
+ (*outs[groupIndex[itParsed->first]]) << binLabel << '\t' << size << '\t' << conTax << endl;
+
+ string noConfidenceConTax = conTax;
+ m->removeConfidences(noConfidenceConTax);
+
+ //add this bins taxonomy to summary
+ if (basis == "sequence") {
+ for(int j = 0; j < theseNames.size(); j++) {
+ int numReps = 1;
+ if (countfile != "") { numReps = ct->getGroupCount(theseNames[j], itParsed->first); } //get num seqs for this seq from this group
+ for(int k = 0; k < numReps; k++) { (taxaSums[groupIndex[itParsed->first]])->addSeqToTree(theseNames[j], noConfidenceConTax); }
+ }
+ }else { //otu
+ map<string, bool> containsGroup;
+ containsGroup[itParsed->first] = true;
+ (taxaSums[groupIndex[itParsed->first]])->addSeqToTree(noConfidenceConTax, containsGroup);
+ }
+ }
+ }