X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=sharedrabundfloatvector.cpp;h=bea2f8c83808b287428bc309f513b8b64d548366;hb=65e21482d022d12f7a78a8d436fb51f322603e41;hp=bda49bf3dcd50b7171eb2d3aaa9f1668692f1fd8;hpb=763d07b1c215b1bdc9d5d63431f78cfecc60acf5;p=mothur.git diff --git a/sharedrabundfloatvector.cpp b/sharedrabundfloatvector.cpp index bda49bf..bea2f8c 100644 --- a/sharedrabundfloatvector.cpp +++ b/sharedrabundfloatvector.cpp @@ -252,12 +252,19 @@ int SharedRAbundFloatVector::size(){ /***********************************************************************/ void SharedRAbundFloatVector::printHeaders(ostream& output){ try { + string snumBins = toString(numBins); output << "label\tGroup\tnumOtus\t"; if (m->sharedHeaderMode == "tax") { for (int i = 0; i < numBins; i++) { //if there is a bin label use it otherwise make one - string binLabel = "PhyloType" + toString(i+1); + string binLabel = "PhyloType"; + 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; if (i < m->currentBinLabels.size()) { binLabel = m->currentBinLabels[i]; } output << binLabel << '\t'; @@ -266,7 +273,13 @@ void SharedRAbundFloatVector::printHeaders(ostream& output){ }else { for (int i = 0; i < numBins; i++) { //if there is a bin label use it otherwise make one - string binLabel = "Otu" + toString(i+1); + 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; if (i < m->currentBinLabels.size()) { binLabel = m->currentBinLabels[i]; } output << binLabel << '\t'; @@ -484,6 +497,7 @@ int SharedRAbundFloatVector::eliminateZeroOTUS(vector& //for each bin vector newBinLabels; + string snumBins = toString(thislookup[0]->getNumBins()); for (int i = 0; i < thislookup[0]->getNumBins(); i++) { if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } return 0; } @@ -499,7 +513,13 @@ int SharedRAbundFloatVector::eliminateZeroOTUS(vector& newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup()); } //if there is a bin label use it otherwise make one - string binLabel = "Otu" + toString(i+1); + 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; if (i < m->currentBinLabels.size()) { binLabel = m->currentBinLabels[i]; } newBinLabels.push_back(binLabel);