X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=removeotulabelscommand.cpp;h=a882f6bdd3cc1a5588fa4cc18476eca09e6f2153;hp=148758a369f77f85e8c9832d69b3916e13365396;hb=499f4ac6e321f9f03d4c3aa25c3b6880892c8b83;hpb=c85db0a4be3a1f8037a71a23ca73f9762184e28a diff --git a/removeotulabelscommand.cpp b/removeotulabelscommand.cpp index 148758a..a882f6b 100644 --- a/removeotulabelscommand.cpp +++ b/removeotulabelscommand.cpp @@ -234,6 +234,12 @@ int RemoveOtuLabelsCommand::execute(){ //get labels you want to keep labels = m->readAccnos(accnosfile); + //simplfy labels + set newLabels; + for (set::iterator it = labels.begin(); it != labels.end(); it++) { newLabels.insert(m->getSimpleLabel(*it)); } + labels = newLabels; + + if (m->debug) { m->mothurOut("[DEBUG]: numlabels = " + toString(labels.size()) + "\n"); } if (m->control_pressed) { return 0; } @@ -289,7 +295,7 @@ int RemoveOtuLabelsCommand::readClassifyOtu(){ int removedCount = 0; //read headers - string headers = m->getline(in); + string headers = m->getline(in); m->gobble(in); out << headers << endl; while (!in.eof()) { @@ -301,7 +307,9 @@ int RemoveOtuLabelsCommand::readClassifyOtu(){ in >> otu >> size >> tax; m->gobble(in); - if (labels.count(otu) == 0) { + if (m->debug) { m->mothurOut("[DEBUG]: " + otu + toString(size) + tax + "\n"); } + + if (labels.count(m->getSimpleLabel(otu)) == 0) { wroteSomething = true; out << otu << '\t' << size << '\t' << tax << endl; }else { removedCount++; } @@ -341,7 +349,7 @@ int RemoveOtuLabelsCommand::readOtuAssociation(){ int removedCount = 0; //read headers - string headers = m->getline(in); + string headers = m->getline(in); m->gobble(in); out << headers << endl; while (!in.eof()) { @@ -353,7 +361,7 @@ int RemoveOtuLabelsCommand::readOtuAssociation(){ in >> otu1 >> otu2; string line = m->getline(in); m->gobble(in); - if ((labels.count(otu1) == 0) && (labels.count(otu2) == 0)){ + if ((labels.count(m->getSimpleLabel(otu1)) == 0) && (labels.count(m->getSimpleLabel(otu2)) == 0)){ wroteSomething = true; out << otu1 << '\t' << otu2 << '\t' << line << endl; @@ -395,7 +403,7 @@ int RemoveOtuLabelsCommand::readCorrAxes(){ int removedCount = 0; //read headers - string headers = m->getline(in); + string headers = m->getline(in); m->gobble(in); out << headers << endl; while (!in.eof()) { @@ -406,7 +414,7 @@ int RemoveOtuLabelsCommand::readCorrAxes(){ in >> otu; string line = m->getline(in); m->gobble(in); - if (labels.count(otu) == 0) { + if (labels.count(m->getSimpleLabel(otu)) == 0) { wroteSomething = true; out << otu << '\t' << line << endl; @@ -454,9 +462,9 @@ int RemoveOtuLabelsCommand::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->currentBinLabels[i]) == 0) { + if (labels.count(m->getSimpleLabel(m->currentSharedBinLabels[i])) == 0) { 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()); } @@ -476,7 +484,7 @@ int RemoveOtuLabelsCommand::readShared(){ for (int j = 0; j < lookup.size(); j++) { delete lookup[j]; } - m->currentBinLabels = newLabels; + m->currentSharedBinLabels = newLabels; newLookup[0]->printHeaders(out); @@ -525,7 +533,7 @@ int RemoveOtuLabelsCommand::readList(){ } otuLabel += sbinNumber; - if (labels.count(otuLabel) == 0) { + if (labels.count(m->getSimpleLabel(otuLabel)) == 0) { newList.push_back(list->get(i)); }else { removedCount++; } }