X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=removeotuscommand.cpp;h=a840bba6d8d91c94cc34350e944a02aa01613ee8;hb=250e3b11b1c9c1e1ad458ab6c7e71ac2e67e11d9;hp=16fd8dce8bab96b030a57effd81d218e122628a5;hpb=1a5c2356c1b955c6ec024b2baf9f46377ee7c72e;p=mothur.git diff --git a/removeotuscommand.cpp b/removeotuscommand.cpp index 16fd8dc..a840bba 100644 --- a/removeotuscommand.cpp +++ b/removeotuscommand.cpp @@ -243,6 +243,13 @@ int RemoveOtusCommand::execute(){ //********************************************************************************************************************** int RemoveOtusCommand::readListGroup(){ try { + InputData* input = new InputData(listfile, "list"); + ListVector* list = input->getListVector(); + string lastLabel = list->getLabel(); + + //using first label seen if none is provided + if (label == "") { label = lastLabel; } + string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(listfile); } map variables; @@ -263,13 +270,6 @@ int RemoveOtusCommand::readListGroup(){ ofstream outGroup; m->openOutputFile(outputGroupFileName, outGroup); - InputData* input = new InputData(listfile, "list"); - ListVector* list = input->getListVector(); - string lastLabel = list->getLabel(); - - //using first label seen if none is provided - if (label == "") { label = lastLabel; } - //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label. set labels; labels.insert(label); set processedLabels; @@ -365,6 +365,8 @@ int RemoveOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstr int numOtus = 0; //for each bin + vector binLabels = list->getLabels(); + vector newBinLabels; for (int i = 0; i < list->getNumBins(); i++) { if (m->control_pressed) { return 0; } @@ -400,7 +402,8 @@ int RemoveOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstr if (!removeBin) { //if there are no sequences from the groups we want to remove in this bin add to new list, output to groupfile - newList.push_back(binnames); + newList.push_back(binnames); + newBinLabels.push_back(binLabels[i]); outGroup << groupFileOutput; }else { numOtus++; @@ -414,7 +417,9 @@ int RemoveOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstr //print new listvector if (newList.getNumBins() != 0) { wroteSomething = true; - newList.print(out); + newList.setLabels(newBinLabels); + newList.printHeaders(out); + newList.print(out); } m->mothurOut(newList.getLabel() + " - removed " + toString(numOtus) + " of the " + toString(list->getNumBins()) + " OTUs."); m->mothurOutEndLine();