X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=removegroupscommand.cpp;h=42f088b953d2f3657dd98dcec4f184f87eb8a70b;hp=9db35cb4bcb1fb78daa9545ecf4464b29c09d2e2;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=499f4ac6e321f9f03d4c3aa25c3b6880892c8b83 diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp index 9db35cb..42f088b 100644 --- a/removegroupscommand.cpp +++ b/removegroupscommand.cpp @@ -70,7 +70,7 @@ string RemoveGroupsCommand::getOutputPattern(string type) { else if (type == "count") { pattern = "[filename],pick,[extension]"; } else if (type == "list") { pattern = "[filename],pick,[extension]"; } else if (type == "shared") { pattern = "[filename],[tag],pick,[extension]"; } - else if (type == "design") { pattern = "[filename],pick,[extension]"; } + else if (type == "design") { pattern = "[filename],[tag],pick,[extension]"; } else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } return pattern; @@ -623,12 +623,7 @@ int RemoveGroupsCommand::readList(){ map variables; variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile)); variables["[extension]"] = m->getExtension(listfile); - string outputFileName = getOutputFileName("list", variables); - - - ofstream out; - m->openOutputFile(outputFileName, out); - + ifstream in; m->openInputFile(listfile, in); @@ -641,6 +636,16 @@ int RemoveGroupsCommand::readList(){ //read in list vector ListVector list(in); + + variables["[tag]"] = list.getLabel(); + string outputFileName = getOutputFileName("list", variables); + + ofstream out; + m->openOutputFile(outputFileName, out); + outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName); + + vector binLabels = list.getLabels(); + vector newBinLabels; //make a new list vector ListVector newList; @@ -681,24 +686,26 @@ int RemoveGroupsCommand::readList(){ //if there are names in this bin add to new list if (newNames != "") { newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma - newList.push_back(newNames); + newList.push_back(newNames); + newBinLabels.push_back(binLabels[i]); } } //print new listvector if (newList.getNumBins() != 0) { wroteSomething = true; + newList.setLabels(newBinLabels); + newList.printHeaders(out); newList.print(out); } m->gobble(in); + out.close(); } in.close(); - out.close(); - if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); } - outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName); + if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine(); } m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine(); return 0;