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;
m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
}
CountTable ct;
- ct.readTable(countfile, true);
+ ct.readTable(countfile, true, false);
if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; }
vector<string> gNamesOfGroups = ct.getNamesOfGroups();
m->setGroups(groupsToKeep);
m->clearAllGroups();
m->saveNextLabel = "";
- m->printedHeaders = false;
- m->currentBinLabels.clear();
- m->binLabelsInFile.clear();
+ m->printedSharedHeaders = false;
+ m->currentSharedBinLabels.clear();
+ m->sharedBinLabelsInFile.clear();
InputData input(sharedfile, "sharedfile");
lookup = input.getSharedRAbundVectors();
map<string, string> 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);
//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<string> binLabels = list.getLabels();
+ vector<string> newBinLabels;
//make a new list vector
ListVector newList;
//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;