X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getotulabelscommand.cpp;h=a1413d244171ea6fa6d68c58969cce4afa86d1b6;hb=6b32d112bb60e9f7eb6d4407a4eed4c49b67bced;hp=00297e2d8049be362a991589446544b6c1cf99fc;hpb=a935b75dd890da5ae7f09e5e6179f90ab2955348;p=mothur.git diff --git a/getotulabelscommand.cpp b/getotulabelscommand.cpp index 00297e2..a1413d2 100644 --- a/getotulabelscommand.cpp +++ b/getotulabelscommand.cpp @@ -465,9 +465,9 @@ int GetOtuLabelsCommand::readShared(){ if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) { delete newLookup[j]; } for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } return 0; } //is this otu on the list - if (labels.count(m->getSimpleLabel(m->currentBinLabels[i])) != 0) { + if (labels.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) != 0) { numSelected++; wroteSomething = true; - newLabels.push_back(m->currentBinLabels[i]); + newLabels.push_back(m->currentSharedBinLabels[i]); for (int j = 0; j < newLookup.size(); j++) { //add this OTU to the new lookup newLookup[j]->push_back(lookup[j]->getAbundance(i), lookup[j]->getGroup()); } @@ -487,7 +487,7 @@ int GetOtuLabelsCommand::readShared(){ for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } - m->currentBinLabels = newLabels; + m->currentSharedBinLabels = newLabels; newLookup[0]->printHeaders(out); @@ -521,24 +521,17 @@ int GetOtuLabelsCommand::readList(){ newList.setLabel(list->getLabel()); int selectedCount = 0; bool wroteSomething = false; - string snumBins = toString(list->getNumBins()); + vector binLabels = list->getLabels(); + vector newLabels; for (int i = 0; i < list->getNumBins(); i++) { if (m->control_pressed) { delete list; return 0;} - //create a label for this otu - string otuLabel = "Otu"; - string sbinNumber = toString(i+1); - if (sbinNumber.length() < snumBins.length()) { - int diff = snumBins.length() - sbinNumber.length(); - for (int h = 0; h < diff; h++) { otuLabel += "0"; } - } - otuLabel += sbinNumber; - - if (labels.count(m->getSimpleLabel(otuLabel)) != 0) { + if (labels.count(m->getSimpleLabel(binLabels[i])) != 0) { selectedCount++; newList.push_back(list->get(i)); + newLabels.push_back(binLabels[i]); } } @@ -556,6 +549,8 @@ int GetOtuLabelsCommand::readList(){ //print new listvector if (newList.getNumBins() != 0) { wroteSomething = true; + newList.setLabels(newLabels); + newList.printHeaders(out); newList.print(out); } out.close();