GCC_ENABLE_SSE3_EXTENSIONS = NO;
GCC_ENABLE_SSE41_EXTENSIONS = NO;
GCC_ENABLE_SSE42_EXTENSIONS = NO;
- GCC_OPTIMIZATION_LEVEL = s;
+ GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
"MOTHUR_FILES=\"\\\"../../release\\\"\"",
"VERSION=\"\\\"1.31.0\\\"\"",
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = "";
- GCC_OPTIMIZATION_LEVEL = s;
+ GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
- "VERSION=\"\\\"1.32.0\\\"\"",
- "RELEASE_DATE=\"\\\"10/01/2013\\\"\"",
+ "VERSION=\"\\\"1.32.1\\\"\"",
+ "RELEASE_DATE=\"\\\"10/16/2013\\\"\"",
);
GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
else { optionString += "inputdir=" + inputDir; }
}
- if(commandName == "cluster") { command = new ClusterCommand(optionString); }
+ if(commandName == "cluster") { command = new ClusterCommand(optionString); }
else if(commandName == "unique.seqs") { command = new DeconvoluteCommand(optionString); }
else if(commandName == "parsimony") { command = new ParsimonyCommand(optionString); }
else if(commandName == "help") { command = new HelpCommand(optionString); }
bool isValidCommand(string, string);\r
void printCommands(ostream&);\r
void printCommandsCategories(ostream&);\r
- void setOutputDirectory(string o) { outputDir = o; m->setOutputDir(o); }\r
- void setInputDirectory(string i) { inputDir = i; }\r
+ void setOutputDirectory(string o) { if(m->dirCheck(o) || (o == "")) { outputDir = o; m->setOutputDir(o); } }\r
+ void setInputDirectory(string i) { if(m->dirCheck(i) || (i == "")) { inputDir = i; } }\r
void setLogfileName(string n, bool a) { logFileName = n; append = a; }\r
string getLogfileName() { return logFileName; }\r
bool getAppend() { return append; }\r
newList.setLabel(list->getLabel());
int selectedCount = 0;
bool wroteSomething = false;
- string snumBins = toString(list->getNumBins());
vector<string> binLabels = list->getLabels();
vector<string> newLabels;
m->splitAtComma(binnames, bnames);
string newNames = "";
- for (int i = 0; i < bnames.size(); i++) {
- string name = bnames[i];
+ for (int j = 0; j < bnames.size(); j++) {
+ string name = bnames[j];
//if that name is in the .accnos file, add it
if (names.count(name) != 0) { newNames += name + ","; selectedCount++; if (m->debug) { sanity["list"].insert(name); } }
}
CYGWIN_BUILD ?= no
USECOMPRESSION ?= no
MOTHUR_FILES="\"Enter_your_default_path_here\""
-RELEASE_DATE = "\"10/01/2013\""
-VERSION = "\"1.32.0\""
+RELEASE_DATE = "\"10/16/2013\""
+VERSION = "\"1.32.1\""
FORTAN_COMPILER = gfortran
FORTRAN_FLAGS =
//test to make sure directory exists
dirName = getFullPathName(dirName);
- string outTemp = dirName + tag + "temp";
+ string outTemp = dirName + tag + "temp"+ toString(time(NULL));
ofstream out;
out.open(outTemp.c_str(), ios::trunc);
if(!out) {
vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
vector<string> Treenames;
- //map<string, string> names;
vector<string> sharedBinLabelsInFile;
vector<string> currentSharedBinLabels;
vector<string> listBinLabelsInFile;
- //vector<string> currentListBinLabels;
string saveNextLabel, argv, sharedHeaderMode, groupMode;
bool printedSharedHeaders, printedListHeaders, commandInputsConvertError, changedSeqNames, modifyNames;
try {
string pattern = "";
- if (type == "list") { pattern = "[filename],[group],list"; }
+ if (type == "list") { pattern = "[filename],[group],[distance],list"; }
else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
return pattern;
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- //set fileroot
- map<string, string> variables;
- variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
-
- //fill filehandles with neccessary ofstreams
- int i;
- ofstream* temp;
- vector<string> gGroups;
- if (groupfile != "") { gGroups = groupMap->getNamesOfGroups(); }
- else { gGroups = ct.getNamesOfGroups(); }
-
- for (i=0; i<gGroups.size(); i++) {
- temp = new ofstream;
- filehandles[gGroups[i]] = temp;
-
- variables["[group]"] = gGroups[i];
- string filename = getOutputFileName("list",variables);
- outputNames.push_back(filename); outputTypes["list"].push_back(filename);
- m->openOutputFile(filename, *temp);
- }
-
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
set<string> processedLabels;
set<string> userLabels = labels;
if (m->control_pressed) {
delete list; if (groupfile != "") { delete groupMap; }
- for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- return 0;
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;
}
while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if (m->control_pressed) {
delete list; if (groupfile != "") { delete groupMap; }
- for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
return 0;
}
if (m->control_pressed) {
if (groupfile != "") { delete groupMap; }
- for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
return 0;
}
if (m->control_pressed) {
if (groupfile != "") { delete groupMap; }
- for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
return 0;
}
delete list;
}
- for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
- (*(filehandles[it3->first])).close();
- delete it3->second;
- }
-
if (groupfile != "") { delete groupMap; }
if (m->control_pressed) {
/**********************************************************************************************************************/
int ParseListCommand::parse(ListVector* thisList) {
try {
+ map<string, ofstream*> filehandles;
+ map<string, ofstream*>::iterator it3;
+
+ //set fileroot
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+ variables["[distance]"] = thisList->getLabel();
+
+ //fill filehandles with neccessary ofstreams
+ ofstream* temp;
+ vector<string> gGroups;
+ if (groupfile != "") { gGroups = groupMap->getNamesOfGroups(); }
+ else { gGroups = ct.getNamesOfGroups(); }
+
+ for (int i=0; i<gGroups.size(); i++) {
+ temp = new ofstream;
+ filehandles[gGroups[i]] = temp;
+
+ variables["[group]"] = gGroups[i];
+ string filename = getOutputFileName("list",variables);
+ m->openOutputFile(filename, *temp);
+ outputNames.push_back(filename); outputTypes["list"].push_back(filename);
+ }
+
map<string, string> groupVector;
+ map<string, string> groupLabels;
map<string, string>::iterator itGroup;
map<string, int> groupNumBins;
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
groupNumBins[it3->first] = 0;
groupVector[it3->first] = "";
+ groupLabels[it3->first] = "label\tnumOtus\t";
}
-
+ vector<string> binLabels = thisList->getLabels();
for (int i = 0; i < thisList->getNumBins(); i++) {
- if (m->control_pressed) { return 0; }
+ if (m->control_pressed) { break; }
map<string, string> groupBins;
string bin = list->get(i);
//print parsed bin info to files
for (itGroup = groupBins.begin(); itGroup != groupBins.end(); itGroup++) {
- groupVector[itGroup->first] += itGroup->second + '\t';
+ groupVector[itGroup->first] += itGroup->second + '\t';
+ groupLabels[itGroup->first] += binLabels[i] + '\t';
}
}
+ if (m->control_pressed) {
+ for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
+ (*(filehandles[it3->first])).close();
+ delete it3->second;
+ }
+ return 0;
+ }
+
//end list vector
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
+ (*(filehandles[it3->first])) << groupLabels[it3->first] << endl;
(*(filehandles[it3->first])) << thisList->getLabel() << '\t' << groupNumBins[it3->first] << '\t' << groupVector[it3->first] << endl; // label numBins listvector for that group
+ (*(filehandles[it3->first])).close();
+ delete it3->second;
}
return 0;
set<string> labels;
bool abort, allLines;
vector<string> outputNames;
-
- map<string, ofstream*> filehandles;
- map<string, ofstream*>::iterator it3;
};
}
//print listvector
- list.print(outList);
+ if (!m->printedListHeaders) { list.printHeaders(outList); }
+ list.print(outList);
+
if (countfile == "") {
//print rabund
list.getRAbundVector().print(outRabund);
CommandParameter pmintm("mintm", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmintm);
CommandParameter pmaxtm("maxtm", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxtm);
CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false); parameters.push_back(pprocessors);
- CommandParameter potunumber("otunumber", "Number", "", "-1", "", "", "","",false,true,true); parameters.push_back(potunumber);
+ CommandParameter potunumber("otulabel", "String", "", "", "", "", "","",false,true,true); parameters.push_back(potunumber);
CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
CommandParameter pcutoff("cutoff", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pcutoff);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
try {
string helpString = "";
helpString += "The primer.design allows you to identify sequence fragments that are specific to particular OTUs.\n";
- helpString += "The primer.design command parameters are: list, fasta, name, count, otunumber, cutoff, length, pdiffs, mintm, maxtm, processors and label.\n";
+ helpString += "The primer.design command parameters are: list, fasta, name, count, otulabel, cutoff, length, pdiffs, mintm, maxtm, processors and label.\n";
helpString += "The list parameter allows you to provide a list file and is required.\n";
helpString += "The fasta parameter allows you to provide a fasta file and is required.\n";
helpString += "The name parameter allows you to provide a name file associated with your fasta file.\n";
helpString += "The count parameter allows you to provide a count file associated with your fasta file.\n";
helpString += "The label parameter is used to indicate the label you want to use from your list file.\n";
- helpString += "The otunumber parameter is used to indicate the otu you want to use from your list file. It is required.\n";
+ helpString += "The otulabel parameter is used to indicate the otu you want to use from your list file. It is required.\n";
helpString += "The pdiffs parameter is used to specify the number of differences allowed in the primer. The default is 0.\n";
helpString += "The length parameter is used to indicate the length of the primer. The default is 18.\n";
helpString += "The mintm parameter is used to indicate minimum melting temperature.\n";
temp = validParameter.validFile(parameters, "maxtm", false); if (temp == "not found") { temp = "-1"; }
m->mothurConvert(temp, maxTM);
- temp = validParameter.validFile(parameters, "otunumber", false); if (temp == "not found") { temp = "-1"; }
- m->mothurConvert(temp, otunumber);
- if (otunumber < 1) { m->mothurOut("[ERROR]: You must provide an OTU number, aborting.\n"); abort = true; }
+ otulabel = validParameter.validFile(parameters, "otulabel", false); if (otulabel == "not found") { temp = ""; }
+ if (otulabel == "") { m->mothurOut("[ERROR]: You must provide an OTU label, aborting.\n"); abort = true; }
temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
m->setProcessors(temp);
//reads list file and selects the label the users specified or the first label
getListVector();
- if (otunumber > list->getNumBins()) { m->mothurOut("[ERROR]: You selected an OTU number larger than the number of OTUs you have in your list file, quitting.\n"); return 0; }
+ vector<string> binLabels = list->getLabels();
+ int binIndex = findIndex(otulabel, binLabels);
+ if (binIndex == -1) { m->mothurOut("[ERROR]: You selected an OTU label that is not in your in your list file, quitting.\n"); return 0; }
map<string, int> nameMap;
unsigned long int numSeqs; //used to sanity check the files. numSeqs = total seqs for namefile and uniques for count.
m->mothurOut("Done.\n\n");
- set<string> primers = getPrimer(conSeqs[otunumber-1]);
+ set<string> primers = getPrimer(conSeqs[binIndex]);
if (m->control_pressed) { delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
ofstream outSum;
m->openOutputFile(consSummaryFile, outSum);
- outSum << "PrimerOtu: " << otunumber << " Members: " << list->get(otunumber-1) << endl << "Primers\tminTm\tmaxTm" << endl;
+ outSum << "PrimerOtu: " << otulabel << " Members: " << list->get(binIndex) << endl << "Primers\tminTm\tmaxTm" << endl;
//find min and max melting points
vector<double> minTms;
outSum.close();
//check each otu's conseq for each primer in otunumber
- set<int> otuToRemove = createProcesses(consSummaryFile, minTms, maxTms, primers, conSeqs);
+ set<int> otuToRemove = createProcesses(consSummaryFile, minTms, maxTms, primers, conSeqs, binIndex);
if (m->control_pressed) { delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
mvariables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
mvariables["[extension]"] = m->getExtension(listfile);
string newListFile = getOutputFileName("list", mvariables);
- outputNames.push_back(newListFile); outputTypes["list"].push_back(newListFile);
- ofstream outList;
- m->openOutputFile(newListFile, outList);
+ ofstream outListTemp;
+ m->openOutputFile(newListFile+".temp", outListTemp);
- outList << list->getLabel() << '\t' << (list->getNumBins()-otuToRemove.size()) << '\t';
+ outListTemp << list->getLabel() << '\t' << (list->getNumBins()-otuToRemove.size()) << '\t';
+ string headers = "label\tnumOtus\t";
for (int j = 0; j < list->getNumBins(); j++) {
if (m->control_pressed) { break; }
//good otus
if (otuToRemove.count(j) == 0) {
string bin = list->get(j);
- if (bin != "") { outList << bin << '\t'; }
+ if (bin != "") { outListTemp << bin << '\t'; headers += binLabels[j] + '\t'; }
}
}
- outList << endl;
+ outListTemp << endl;
+ outListTemp.close();
+
+ ofstream outList;
+ m->openOutputFile(newListFile, outList);
+ outList << headers << endl;
outList.close();
+ m->appendFiles(newListFile+".temp", newListFile);
+ m->mothurRemove(newListFile+".temp");
+ outputNames.push_back(newListFile); outputTypes["list"].push_back(newListFile);
if (m->control_pressed) { delete list; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
}
}
/**************************************************************************************************/
-set<int> PrimerDesignCommand::createProcesses(string newSummaryFile, vector<double>& minTms, vector<double>& maxTms, set<string>& primers, vector<Sequence>& conSeqs) {
+set<int> PrimerDesignCommand::createProcesses(string newSummaryFile, vector<double>& minTms, vector<double>& maxTms, set<string>& primers, vector<Sequence>& conSeqs, int binIndex) {
try {
vector<int> processIDS;
//clear old file because we append in driver
m->mothurRemove(newSummaryFile + toString(getpid()) + ".temp");
- otusToRemove = driver(newSummaryFile + toString(getpid()) + ".temp", minTms, maxTms, primers, conSeqs, lines[process].start, lines[process].end, numBinsProcessed);
+ otusToRemove = driver(newSummaryFile + toString(getpid()) + ".temp", minTms, maxTms, primers, conSeqs, lines[process].start, lines[process].end, numBinsProcessed, binIndex);
string tempFile = toString(getpid()) + ".otus2Remove.temp";
ofstream outTemp;
}
//do my part
- otusToRemove = driver(newSummaryFile, minTms, maxTms, primers, conSeqs, lines[0].start, lines[0].end, numBinsProcessed);
+ otusToRemove = driver(newSummaryFile, minTms, maxTms, primers, conSeqs, lines[0].start, lines[0].end, numBinsProcessed, binIndex);
//force parent to wait until all the processes are done
for (int i=0;i<processIDS.size();i++) {
string extension = toString(i) + ".temp";
m->mothurRemove(newSummaryFile+extension);
- primerDesignData* tempPrimer = new primerDesignData((newSummaryFile+extension), m, lines[i].start, lines[i].end, minTms, maxTms, primers, conSeqs, pdiffs, otunumber, length, i);
+ primerDesignData* tempPrimer = new primerDesignData((newSummaryFile+extension), m, lines[i].start, lines[i].end, minTms, maxTms, primers, conSeqs, pdiffs, binIndex, length, i);
pDataArray.push_back(tempPrimer);
processIDS.push_back(i);
//using the main process as a worker saves time and memory
- otusToRemove = driver(newSummaryFile, minTms, maxTms, primers, conSeqs, lines[0].start, lines[0].end, numBinsProcessed);
+ otusToRemove = driver(newSummaryFile, minTms, maxTms, primers, conSeqs, lines[0].start, lines[0].end, numBinsProcessed, binIndex);
//Wait until all threads have terminated.
WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
}
}
//**********************************************************************************************************************
-set<int> PrimerDesignCommand::driver(string summaryFileName, vector<double>& minTms, vector<double>& maxTms, set<string>& primers, vector<Sequence>& conSeqs, int start, int end, int& numBinsProcessed){
+set<int> PrimerDesignCommand::driver(string summaryFileName, vector<double>& minTms, vector<double>& maxTms, set<string>& primers, vector<Sequence>& conSeqs, int start, int end, int& numBinsProcessed, int binIndex){
try {
set<int> otuToRemove;
if (m->control_pressed) { break; }
- if (i != (otunumber-1)) {
+ if (i != (binIndex)) {
int primerIndex = 0;
for (set<string>::iterator it = primers.begin(); it != primers.end(); it++) {
vector<int> primerStarts;
}
}
//**********************************************************************************************************************
+int PrimerDesignCommand::findIndex(string binLabel, vector<string> binLabels){
+ try {
+ int index = -1;
+ for (int i = 0; i < binLabels.size(); i++){
+ if (m->control_pressed) { return index; }
+ if (m->isLabelEquivalent(binLabel, binLabels[i])) { index = i; break; }
+ }
+ return index;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "PrimerDesignCommand", "findIndex");
+ exit(1);
+ }
+}
+//**********************************************************************************************************************
};
bool abort, allLines, large;
- int cutoff, pdiffs, length, otunumber, processors, alignedLength;
- string outputDir, listfile, namefile, countfile, fastafile, label;
+ int cutoff, pdiffs, length, processors, alignedLength;
+ string outputDir, listfile, otulabel, namefile, countfile, fastafile, label;
double minTM, maxTM;
ListVector* list;
vector<string> outputNames;
bool findPrimer(string, string, vector<int>&, vector<int>&, vector<int>&);
int findMeltingPoint(string primer, double&, double&);
- set<int> createProcesses(string, vector<double>&, vector<double>&, set<string>&, vector<Sequence>&);
- set<int> driver(string, vector<double>&, vector<double>&, set<string>&, vector<Sequence>&, int, int, int&);
+ set<int> createProcesses(string, vector<double>&, vector<double>&, set<string>&, vector<Sequence>&, int);
+ set<int> driver(string, vector<double>&, vector<double>&, set<string>&, vector<Sequence>&, int, int, int&, int);
vector< vector< vector<unsigned int> > > driverGetCounts(map<string, int>&, unsigned long int&, vector<unsigned int>&, unsigned long long&, unsigned long long&);
vector<Sequence> createProcessesConSeqs(map<string, int>&, unsigned long int&);
+ int findIndex(string binLabel, vector<string> binLabels);
};
MothurOut* m;
int start;
int end;
- int pdiffs, threadID, otunumber, length;
+ int pdiffs, threadID, length, binIndex;
set<string> primers;
vector<double> minTms, maxTms;
set<int> otusToRemove;
maxTms = max;
primers = pri;
consSeqs = seqs;
- otunumber = otun;
+ binIndex = otun;
length = l;
threadID = tid;
numBinsProcessed = 0;
if (pDataArray->m->control_pressed) { break; }
- if (i != (pDataArray->otunumber-1)) {
+ if (i != (pDataArray->binIndex)) {
int primerIndex = 0;
for (set<string>::iterator it = pDataArray->primers.begin(); it != pDataArray->primers.end(); it++) {
vector<int> primerStarts;
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;
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;
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]-[filename],[distance],pick,[extension]"; }
+ else if (type == "list") { pattern = "[filename],[distance],pick,[extension]"; }
else if (type == "shared") { pattern = "[filename],[distance],pick,[extension]"; }
else if (type == "alignreport") { pattern = "[filename],pick.align.report"; }
else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
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);
bool wroteSomething = false;
while(!in.eof()){
+
//read in list vector
ListVector list(in);
//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);
+
+ if (m->control_pressed) { in.close(); out.close(); return 0; }
+
+ vector<string> binLabels = list.getLabels();
+ vector<string> newBinLabels;
//for each bin
for (int i = 0; i < list.getNumBins(); i++) {
//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 list file contains only sequences from " + taxons + "."); m->mothurOutEndLine(); }
- outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
return 0;
bool wroteSomething = false;
string snumBins = toString(list->getNumBins());
+ vector<string> binLabels = list->getLabels();
+ vector<string> newBinLabels;
for (int i = 0; i < list->getNumBins(); i++) {
if (m->control_pressed) { delete list; return 0;}
if (names.count(m->getSimpleLabel(otuLabel)) == 0) {
newList.push_back(list->get(i));
+ newBinLabels.push_back(binLabels[i]);
}else { removedCount++; }
}
//print new listvector
if (newList.getNumBins() != 0) {
wroteSomething = true;
+ newList.setLabels(newBinLabels);
+ newList.printHeaders(out);
newList.print(out);
}
out.close();
newList.setLabel(list->getLabel());
int removedCount = 0;
bool wroteSomething = false;
- string snumBins = toString(list->getNumBins());
+ vector<string> binLabels = list->getLabels();
+ vector<string> newLabels;
for (int i = 0; i < list->getNumBins(); i++) {
if (m->control_pressed) { delete list; return 0;}
- //create a label for this otu
- string otuLabel = "Otu";
- string sbinNumber = toString(i+1);
- if (sbinNumber.length() < snumBins.length()) {
- int diff = snumBins.length() - sbinNumber.length();
- for (int h = 0; h < diff; h++) { otuLabel += "0"; }
- }
- otuLabel += sbinNumber;
-
- if (labels.count(m->getSimpleLabel(otuLabel)) == 0) {
+ if (labels.count(m->getSimpleLabel(binLabels[i])) == 0) {
newList.push_back(list->get(i));
+ newLabels.push_back(binLabels[i]);
}else { removedCount++; }
}
//print new listvector
if (newList.getNumBins() != 0) {
wroteSomething = true;
+ newList.setLabels(newLabels);
+ newList.printHeaders(out);
newList.print(out);
}
out.close();
//**********************************************************************************************************************
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<string, string> variables;
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<string> labels; labels.insert(label);
set<string> processedLabels;
int numOtus = 0;
//for each bin
+ vector<string> binLabels = list->getLabels();
+ vector<string> newBinLabels;
for (int i = 0; i < list->getNumBins(); i++) {
if (m->control_pressed) { return 0; }
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++;
//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();
else if (type == "sabund") { 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],[tag],pick,[extension]"; }
else if (type == "shared") { pattern = "[filename],[tag],pick,[extension]"; }
else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
//**********************************************************************************************************************
int RemoveRareCommand::processList(){
try {
- string thisOutputDir = outputDir;
- if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
- map<string, string> variables;
- variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
- variables["[extension]"] = m->getExtension(listfile);
- string outputFileName = getOutputFileName("list", variables);
- variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
- variables["[extension]"] = m->getExtension(groupfile);
- string outputGroupFileName = getOutputFileName("group", variables);
- variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
- variables["[extension]"] = m->getExtension(countfile);
- string outputCountFileName = getOutputFileName("count", variables);
-
- ofstream out, outGroup;
- m->openOutputFile(outputFileName, out);
-
- bool wroteSomething = false;
-
+
//you must provide a label because the names in the listfile need to be consistent
string thisLabel = "";
if (allLines) { m->mothurOut("For the listfile you must select one label, using first label in your listfile."); m->mothurOutEndLine(); }
list = input.getListVector(lastLabel);
}
}
+
+ string thisOutputDir = outputDir;
+ if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
+ map<string, string> variables;
+ variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+ variables["[extension]"] = m->getExtension(listfile);
+ variables["[tag]"] = list->getLabel();
+ string outputFileName = getOutputFileName("list", variables);
+ variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(groupfile));
+ variables["[extension]"] = m->getExtension(groupfile);
+ string outputGroupFileName = getOutputFileName("group", variables);
+ variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(countfile));
+ variables["[extension]"] = m->getExtension(countfile);
+ string outputCountFileName = getOutputFileName("count", variables);
+
+ ofstream out, outGroup;
+ m->openOutputFile(outputFileName, out);
+
+ bool wroteSomething = false;
+
//if groupfile is given then use it
GroupMap* groupMap;
}
- if (list != NULL) {
+ if (list != NULL) {
+
+ vector<string> binLabels = list->getLabels();
+ vector<string> newLabels;
+
//make a new list vector
ListVector newList;
newList.setLabel(list->getLabel());
if (binsize > nseqs) { //keep bin
newList.push_back(saveBinNames);
+ newLabels.push_back(binLabels[i]);
if (groupfile != "") { for(int k = 0; k < newGroupFile.size(); k++) { outGroup << newGroupFile[k] << endl; } }
else if (countfile != "") { for(int k = 0; k < newGroupFile.size(); k++) { ct.remove(newGroupFile[k]); } }
}else { if (countfile != "") { for(int k = 0; k < names.size(); k++) { ct.remove(names[k]); } } }
//print new listvector
if (newList.getNumBins() != 0) {
wroteSomething = true;
- newList.print(out);
+ newList.setLabels(newLabels);
+ newList.printHeaders(out);
+ newList.print(out);
}
}
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 == "alignreport") { pattern = "[filename],pick.align.report"; }
else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
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);
//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<string> binLabels = list.getLabels();
+ vector<string> newBinLabels;
+
+ if (m->control_pressed) { in.close(); out.close(); return 0; }
+
//for each bin
for (int i = 0; i < list.getNumBins(); i++) {
if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
//parse out names that are in accnos file
- string binnames = list.get(i);
+ string bin = list.get(i);
+ vector<string> bnames;
+ m->splitAtComma(bin, bnames);
string newNames = "";
- while (binnames.find_first_of(',') != -1) {
- string name = binnames.substr(0,binnames.find_first_of(','));
- binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-
- //if that name is in the .accnos file, add it
+ for (int j = 0; j < bnames.size(); j++) {
+ string name = bnames[j];
+ //if that name is in the .accnos file, add it
if (names.count(name) == 0) { newNames += name + ","; }
else { removedCount++; }
- }
-
- //get last name
- if (names.count(binnames) == 0) { newNames += binnames + ","; }
- else { removedCount++; }
+ }
//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 .accnos file."); m->mothurOutEndLine(); }
- outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine();
//make a new list vector
ListVector newList;
newList.setLabel(list.getLabel());
+ vector<string> binLabels = list.getLabels();
+ vector<string> newLabels;
//for each bin
for (int i = 0; i < list.getNumBins(); i++) {
//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);
+ newLabels.push_back(binLabels[i]);
}
}
//print new listvector
if (newList.getNumBins() != 0) {
wroteSomething = true;
+ newList.setLabels(newLabels);
+ if (!m->printedListHeaders) { newList.printHeaders(out); }
newList.print(out);
}
#include "seqnoise.h"
#include "sequence.hpp"
+#include "listvector.hpp"
+#include "inputdata.h"
#define MIN_DELTA 1.0e-6
#define MIN_ITER 20
ifstream listFile;
m->openInputFile(listFileName, listFile);
- double threshold;
- int numOTUs;
- string line = "";
- bool adjustCutoff = true;
-
- if(listFile.peek() == 'u'){ m->getline(listFile); }
- while(listFile){
- listFile >> threshold;
-
- if(threshold < cutOff){
- line = m->getline(listFile); m->gobble(listFile);
- }
- else{
- adjustCutoff = false;
- listFile >> numOTUs;
- otuFreq.resize(numOTUs, 0);
-
- for(int i=0;i<numOTUs;i++){
-
- if (m->control_pressed) { return 0; }
-
- string otu;
- listFile >> otu;
-
- int count = 0;
-
- string number = "";
-
- for(int j=0;j<otu.size();j++){
- if(otu[j] != ','){
- number += otu[j];
- }
- else{
- int index = atoi(number.c_str());
- otuData[index] = i;
- count++;
- number = "";
- }
- }
-
- int index = atoi(number.c_str());
- otuData[index] = i;
- count++;
-
- otuFreq[i] = count;
- }
-
- otuBySeqLookUp.resize(numOTUs);
-
- int numSeqs = otuData.size();
-
- for(int i=0;i<numSeqs;i++){
- if (m->control_pressed) { return 0; }
- otuBySeqLookUp[otuData[i]].push_back(i);
- }
- for(int i=0;i<numOTUs;i++){
- if (m->control_pressed) { return 0; }
- for(int j=otuBySeqLookUp[i].size();j<numSeqs;j++){
- otuBySeqLookUp[i].push_back(0);
- }
- }
-
- break;
- }
+ bool adjustCutoff = true;
+ string lastLabel = "";
+
+ while(!listFile.eof()){
+
+ ListVector list(listFile); m->gobble(listFile); //10/18/13 - change to reading with listvector to accomodate changes to the listfiel format. ie. adding header labels.
+
+ string thisLabel = list.getLabel();
+ lastLabel = thisLabel;
+
+ if (thisLabel == "unique") {} //skip to next label in listfile
+ else {
+ double threshold;
+ m->mothurConvert(thisLabel, threshold);
+
+ if(threshold < cutOff){} //skip to next label in listfile
+ else{
+ adjustCutoff = false;
+ int numOTUs = list.getNumBins();
+ otuFreq.resize(numOTUs, 0);
+
+ for(int i=0;i<numOTUs;i++){
+
+ if (m->control_pressed) { return 0; }
+
+ string otu = list.get(i);
+ int count = 0;
+ string number = "";
+
+ for(int j=0;j<otu.size();j++){
+ if(otu[j] != ','){
+ number += otu[j];
+ }
+ else{
+ int index = atoi(number.c_str());
+ otuData[index] = i;
+ count++;
+ number = "";
+ }
+ }
+
+ int index = atoi(number.c_str());
+ otuData[index] = i;
+ count++;
+
+ otuFreq[i] = count;
+ }
+
+ otuBySeqLookUp.resize(numOTUs);
+
+ int numSeqs = otuData.size();
+
+ for(int i=0;i<numSeqs;i++){
+ if (m->control_pressed) { return 0; }
+ otuBySeqLookUp[otuData[i]].push_back(i);
+ }
+ for(int i=0;i<numOTUs;i++){
+ if (m->control_pressed) { return 0; }
+ for(int j=otuBySeqLookUp[i].size();j<numSeqs;j++){
+ otuBySeqLookUp[i].push_back(0);
+ }
+ }
+
+ break;
+ }
+ }
}
listFile.close();
//the listfile does not contain a threshold greater than the cutoff so use highest value
if (adjustCutoff) {
- istringstream iss (line,istringstream::in);
-
- iss >> numOTUs;
- otuFreq.resize(numOTUs, 0);
+
+ InputData input(listFileName, "list");
+ ListVector* list = input.getListVector(lastLabel);
+
+ int numOTUs = list->getNumBins();
+ otuFreq.resize(numOTUs, 0);
for(int i=0;i<numOTUs;i++){
if (m->control_pressed) { return 0; }
- string otu;
- iss >> otu;
+ string otu = list->get(i);
int count = 0;
-
string number = "";
for(int j=0;j<otu.size();j++){
}
}
+ delete list;
}
return 0;
variables["[tag]"] = tag;
variables["[tag2]"] = "rare";
string rare = getOutputFileName("list",variables);
- m->openOutputFile(rare, rout);
+ m->openOutputFile(rare+".temp", rout);
outputNames.push_back(rare); outputTypes["list"].push_back(rare);
variables["[tag2]"] = "abund";
string abund = getOutputFileName("list",variables);
- m->openOutputFile(abund, aout);
+ m->openOutputFile(abund+".temp", aout);
outputNames.push_back(abund); outputTypes["list"].push_back(abund);
if (rareNames.size() != 0) { rout << thisList->getLabel() << '\t' << numRareBins << '\t'; }
if (abundNames.size() != 0) { aout << thisList->getLabel() << '\t' << numAbundBins << '\t'; }
-
+
+ vector<string> binLabels = thisList->getLabels();
+ string rareHeader = "label\tnumOtus\t"; string abundHeader = "label\tnumOtus\t";
for (int i = 0; i < thisList->getNumBins(); i++) {
if (m->control_pressed) { break; }
for (int j = 0; j < names.size(); j++) { size += ct.getNumSeqs(names[j]); }
}
- if (size <= cutoff) { rout << bin << '\t'; }
- else { aout << bin << '\t'; }
+ if (size <= cutoff) { rout << bin << '\t'; rareHeader += binLabels[i] + '\t'; }
+ else { aout << bin << '\t'; abundHeader += binLabels[i] + '\t'; }
}
if (rareNames.size() != 0) { rout << endl; }
rout.close();
aout.close();
+
+ //add headers
+ ofstream r;
+ m->openOutputFile(rare, r);
+ r << rareHeader << endl;
+ r.close();
+ m->appendFiles(rare+".temp", rare);
+ m->mothurRemove(rare+".temp");
+
+ ofstream a;
+ m->openOutputFile(abund, a);
+ a << abundHeader << endl;
+ a.close();
+ m->appendFiles(abund+".temp", abund);
+ m->mothurRemove(abund+".temp");
}else{ //parse names by abundance and group
string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
}
map<string, string> groupVector;
+ map<string, string> groupLabels;
map<string, string>::iterator itGroup;
map<string, int> groupNumBins;
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
groupNumBins[it3->first] = 0;
groupVector[it3->first] = "";
+ groupLabels[it3->first] = "label\tnumOtus\t";
}
-
+ vector<string> binLabels = thisList->getLabels();
for (int i = 0; i < thisList->getNumBins(); i++) {
if (m->control_pressed) { break; }
for (itGroup = groupBins.begin(); itGroup != groupBins.end(); itGroup++) {
- groupVector[itGroup->first] += itGroup->second + '\t';
+ groupVector[itGroup->first] += itGroup->second + '\t';
+ groupLabels[itGroup->first] += binLabels[i] + '\t';
}
}
//end list vector
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
+ (*(filehandles[it3->first])) << groupLabels[it3->first] << endl;
(*(filehandles[it3->first])) << thisList->getLabel() << '\t' << groupNumBins[it3->first] << '\t' << groupVector[it3->first] << endl; // label numBins listvector for that group
(*(filehandles[it3->first])).close();
delete it3->second;
else if (type == "name") { pattern = "[filename],subsample,[extension]"; }
else if (type == "group") { pattern = "[filename],subsample,[extension]"; }
else if (type == "count") { pattern = "[filename],subsample,[extension]"; }
- else if (type == "list") { pattern = "[filename],subsample,[extension]"; }
+ else if (type == "list") { pattern = "[filename],[distance],subsample,[extension]"; }
else if (type == "taxonomy") { pattern = "[filename],subsample,[extension]"; }
else if (type == "shared") { pattern = "[filename],[distance],subsample,[extension]"; }
else if (type == "rabund") { pattern = "[filename],subsample,[extension]"; }
if (namefile != "") { m->readNames(namefile, nameMap); }
- string thisOutputDir = outputDir;
- if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
- 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);
- outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-
InputData* input = new InputData(listfile, "list");
ListVector* list = input->getListVector();
string lastLabel = list->getLabel();
//file mismatch quit
if (list->getNumSeqs() != groupMap.getNumSeqs()) {
m->mothurOut("[ERROR]: your list file contains " + toString(list->getNumSeqs()) + " sequences, and your groupfile contains " + toString(groupMap.getNumSeqs()) + ", please correct.");
- m->mothurOutEndLine(); delete list; delete input; out.close(); outGroup.close(); return 0;
+ m->mothurOutEndLine(); delete list; delete input; outGroup.close(); return 0;
}
}else if (countfile != "") {
if (ct.hasGroupInfo()) {
//as long as you are not at the end of the file or done wih the lines you want
while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { delete list; delete input; out.close(); return 0; }
+ if (m->control_pressed) { delete list; delete input; return 0; }
if(allLines == 1 || labels.count(list->getLabel()) == 1){
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
- processList(list, out, subset);
+ processList(list, subset);
processedLabels.insert(list->getLabel());
userLabels.erase(list->getLabel());
list = input->getListVector(lastLabel);
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
- processList(list, out, subset);
+ processList(list, subset);
processedLabels.insert(list->getLabel());
userLabels.erase(list->getLabel());
}
- if (m->control_pressed) { if (list != NULL) { delete list; } delete input; out.close(); return 0; }
+ if (m->control_pressed) { if (list != NULL) { delete list; } delete input; return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
m->mothurOut(list->getLabel()); m->mothurOutEndLine();
- processList(list, out, subset);
+ processList(list, subset);
delete list; list = NULL;
}
- out.close();
if (list != NULL) { delete list; }
delete input;
}
}
//**********************************************************************************************************************
-int SubSampleCommand::processList(ListVector*& list, ofstream& out, set<string>& subset) {
+int SubSampleCommand::processList(ListVector*& list, set<string>& subset) {
try {
-
+ string thisOutputDir = outputDir;
+ if (outputDir == "") { thisOutputDir += m->hasPath(listfile); }
+ map<string, string> variables;
+ variables["[filename]"] = thisOutputDir + m->getRootName(m->getSimpleName(listfile));
+ variables["[extension]"] = m->getExtension(listfile);
+ variables["[distance]"] = list->getLabel();
+ string outputFileName = getOutputFileName("list", variables);
+ ofstream out;
+ m->openOutputFile(outputFileName, out);
+ outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
+
int numBins = list->getNumBins();
ListVector* temp = new ListVector();
temp->setLabel(list->getLabel());
+ vector<string> binLabels = list->getLabels();
+ vector<string> newLabels;
for (int i = 0; i < numBins; i++) {
if (m->control_pressed) { break; }
if (newNames != "") {
newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
temp->push_back(newNames);
+ newLabels.push_back(binLabels[i]);
}
}
+ temp->setLabels(newLabels);
delete list;
list = temp;
- if (m->control_pressed) { return 0; }
+ if (m->control_pressed) { out.close(); return 0; }
+ list->printHeaders(out);
list->print(out);
+ out.close();
return 0;
int processShared(vector<SharedRAbundVector*>&);
int processRabund(RAbundVector*&, ofstream&);
int processSabund(SAbundVector*&, ofstream&);
- int processList(ListVector*&, ofstream&, set<string>&);
+ int processList(ListVector*&, set<string>&);
int getNames();
int readNames();
int getTax(set<string>&);