]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedrabundfloatvector.cpp
check in for trip
[mothur.git] / sharedrabundfloatvector.cpp
index bda49bf3dcd50b7171eb2d3aaa9f1668692f1fd8..bea2f8c83808b287428bc309f513b8b64d548366 100644 (file)
@@ -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<SharedRAbundFloatVector*>&
                
                //for each bin
                vector<string> 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<SharedRAbundFloatVector*>&
                                        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);