]> git.donarmstrong.com Git - mothur.git/blobdiff - normalizesharedcommand.cpp
check in for trip
[mothur.git] / normalizesharedcommand.cpp
index bcec00a0bc6dd47e15ddcf72000dc4a9dbec9469..43c8e2260c4e678bbd2e7718a6313b15d97eed8b 100644 (file)
@@ -632,6 +632,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thisl
                
                //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; }
                
@@ -647,7 +648,13 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thisl
                                        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);
@@ -681,6 +688,7 @@ int NormalizeSharedCommand::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; }
                        
@@ -696,7 +704,13 @@ int NormalizeSharedCommand::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);