X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=getseqscommand.cpp;h=7f0f3ddb51da8496c292367b5dfc728b3915d53f;hp=83fdf73e9af36fd9826f5a8c2efcc11655ac938e;hb=499f4ac6e321f9f03d4c3aa25c3b6880892c8b83;hpb=d39c47623faf0dc1e271f3d50efa6b029b622b88 diff --git a/getseqscommand.cpp b/getseqscommand.cpp index 83fdf73..7f0f3dd 100644 --- a/getseqscommand.cpp +++ b/getseqscommand.cpp @@ -88,7 +88,7 @@ string GetSeqsCommand::getOutputPattern(string type) { else if (type == "name") { pattern = "[filename],pick,[extension]"; } else if (type == "group") { pattern = "[filename],pick,[extension]"; } else if (type == "count") { pattern = "[filename],pick,[extension]"; } - else if (type == "list") { pattern = "[filename],pick,[extension]"; } + else if (type == "list") { pattern = "[filename],[distance],pick,[extension]"; } else if (type == "qfile") { pattern = "[filename],pick,[extension]"; } else if (type == "accnosreport") { pattern = "[filename],pick.accnos.report"; } else if (type == "alignreport") { pattern = "[filename],pick.align.report"; } @@ -589,7 +589,7 @@ int GetSeqsCommand::readCount(){ //check for groups that have been eliminated CountTable ct; if (ct.testGroups(outputFileName)) { - ct.readTable(outputFileName, true); + ct.readTable(outputFileName, true, false); ct.printTable(outputFileName); } @@ -614,9 +614,6 @@ int GetSeqsCommand::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); @@ -629,8 +626,6 @@ int GetSeqsCommand::readList(){ while(!in.eof()){ selectedCount = 0; - - if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //read in list vector ListVector list(in); @@ -638,6 +633,18 @@ int GetSeqsCommand::readList(){ //make a new list vector ListVector newList; newList.setLabel(list.getLabel()); + + variables["[distance]"] = 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; + + if (m->control_pressed) { in.close(); out.close(); return 0; } //for each bin for (int i = 0; i < list.getNumBins(); i++) { @@ -657,23 +664,26 @@ int GetSeqsCommand::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 does not contain any sequence from the .accnos file."); m->mothurOutEndLine(); } - outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName); m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();