From 65e21482d022d12f7a78a8d436fb51f322603e41 Mon Sep 17 00:00:00 2001 From: westcott Date: Sun, 2 Oct 2011 16:00:00 +0000 Subject: [PATCH] check in for trip --- corraxescommand.cpp | 9 ++++++++- normalizesharedcommand.cpp | 18 ++++++++++++++++-- sharedrabundfloatvector.cpp | 26 +++++++++++++++++++++++--- sharedrabundvector.cpp | 31 +++++++++++++++++++++++++------ subsamplecommand.cpp | 9 ++++++++- summarytaxcommand.h | 3 +++ 6 files changed, 83 insertions(+), 13 deletions(-) diff --git a/corraxescommand.cpp b/corraxescommand.cpp index f10fe4d..b943aa4 100644 --- a/corraxescommand.cpp +++ b/corraxescommand.cpp @@ -760,6 +760,7 @@ int CorrAxesCommand::eliminateZeroOTUS(vector& thisloo //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; } @@ -776,7 +777,13 @@ int CorrAxesCommand::eliminateZeroOTUS(vector& thisloo } //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); diff --git a/normalizesharedcommand.cpp b/normalizesharedcommand.cpp index bcec00a..43c8e22 100644 --- a/normalizesharedcommand.cpp +++ b/normalizesharedcommand.cpp @@ -632,6 +632,7 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector& thisl //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; } @@ -647,7 +648,13 @@ int NormalizeSharedCommand::eliminateZeroOTUS(vector& 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& //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; } @@ -696,7 +704,13 @@ int NormalizeSharedCommand::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); 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); diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 51e277a..f42d24b 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -336,13 +336,19 @@ int SharedRAbundVector::size(){ /***********************************************************************/ void SharedRAbundVector::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'; @@ -351,10 +357,16 @@ void SharedRAbundVector::printHeaders(ostream& output){ }else { for (int i = 0; i < numBins; i++) { //if there is a bin label use it otherwise make one - string mybinLabel = "Otu" + toString(i+1); - if (i < m->currentBinLabels.size()) { mybinLabel = m->currentBinLabels[i]; } + 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 << mybinLabel << '\t'; + output << binLabel << '\t'; } output << endl; @@ -461,6 +473,7 @@ int SharedRAbundVector::eliminateZeroOTUS(vector& thislooku //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; } @@ -477,7 +490,13 @@ int SharedRAbundVector::eliminateZeroOTUS(vector& thislooku } //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); diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp index 28cfc34..49a8210 100644 --- a/subsamplecommand.cpp +++ b/subsamplecommand.cpp @@ -1522,6 +1522,7 @@ int SubSampleCommand::eliminateZeroOTUS(vector& thislookup) //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; } @@ -1537,7 +1538,13 @@ int SubSampleCommand::eliminateZeroOTUS(vector& thislookup) 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); diff --git a/summarytaxcommand.h b/summarytaxcommand.h index acef7ee..b5bdab1 100644 --- a/summarytaxcommand.h +++ b/summarytaxcommand.h @@ -37,4 +37,7 @@ class SummaryTaxCommand : public Command { map nameMap; }; +/**************************************************************************************************/ + + #endif -- 2.39.2