//**********************************************************************************************************************
vector<string> SplitAbundCommand::setParameters(){
try {
- CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
- CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none",false,false); parameters.push_back(pname);
- CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none",false,false); parameters.push_back(pcount);
- CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none",false,false); parameters.push_back(pgroup);
- CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
- CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
- CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "",false,true); parameters.push_back(pcutoff);
- CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
- CommandParameter paccnos("accnos", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(paccnos);
- CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
- CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
+ CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none","fasta",false,true,true); parameters.push_back(pfasta);
+ CommandParameter pname("name", "InputTypes", "", "", "NameCount", "FNGLT", "none","name",false,false,true); parameters.push_back(pname);
+ CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","count",false,false); parameters.push_back(pcount);
+ CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","group",false,false); parameters.push_back(pgroup);
+ CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none","list",false,false,true); parameters.push_back(plist);
+ CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel);
+ CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "","",false,true); parameters.push_back(pcutoff);
+ CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups);
+ CommandParameter paccnos("accnos", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(paccnos);
+ CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
+ CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
exit(1);
}
}
+
//**********************************************************************************************************************
-string SplitAbundCommand::getOutputFileNameTag(string type, string inputName=""){
- try {
- string outputFileName = "";
- map<string, vector<string> >::iterator it;
+string SplitAbundCommand::getOutputPattern(string type) {
+ try {
+ string pattern = "";
- //is this a type this command creates
- it = outputTypes.find(type);
- if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); }
- else {
- if (type == "fasta") { outputFileName = "fasta"; }
- else if (type == "list") { outputFileName = "list"; }
- else if (type == "name") { outputFileName = "names"; }
- else if (type == "count") { outputFileName = "count_table"; }
- else if (type == "group") { outputFileName = "groups"; }
- else if (type == "accnos") { outputFileName = "accnos"; }
- else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; }
- }
- return outputFileName;
- }
- catch(exception& e) {
- m->errorOut(e, "SplitAbundCommand", "getOutputFileNameTag");
- exit(1);
- }
+ if (type == "fasta") { pattern = "[filename],[tag],[tag2],fasta-[filename],[tag],[group],[tag2],fasta"; }
+ else if (type == "list") { pattern = "[filename],[tag],[tag2],list-[filename],[group],[tag],[tag2],list"; }
+ else if (type == "name") { pattern = "[filename],[tag],names-[filename],[group],[tag],names"; }
+ else if (type == "count") { pattern = "[filename],[tag],[tag2],count_table-[filename],[tag],count_table"; }
+ else if (type == "group") { pattern = "[filename],[tag],[tag2],groups-[filename],[tag],[group],[tag2],groups"; }
+ else if (type == "accnos") { pattern = "[filename],[tag],[tag2],accnos-[filename],[tag],[group],[tag2],accnos"; }
+ else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; }
+
+ return pattern;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SplitAbundCommand", "getOutputPattern");
+ exit(1);
+ }
}
//**********************************************************************************************************************
SplitAbundCommand::SplitAbundCommand(){
else if (countfile == "not found") { countfile = ""; }
else {
m->setCountTableFile(countfile);
- ct.readTable(countfile);
+ ct.readTable(countfile, true);
}
if ((namefile != "") && (countfile != "")) {
}//end for
- string tag = thisList->getLabel() + ".";
+ string tag = thisList->getLabel();
writeList(thisList, tag, numRareBins);
ofstream aout;
ofstream rout;
- string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare." + getOutputFileNameTag("list");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(listfile));
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ string rare = getOutputFileName("list",variables);
m->openOutputFile(rare, rout);
outputNames.push_back(rare); outputTypes["list"].push_back(rare);
- string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund." + getOutputFileNameTag("list");
+ variables["[tag2]"] = "abund";
+ string abund = getOutputFileName("list",variables);
m->openOutputFile(abund, aout);
outputNames.push_back(abund); outputTypes["list"].push_back(abund);
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- string rareGroupFileName = fileroot + Groups[i] +"."+ tag + "rare." + getOutputFileNameTag("list");
- string abundGroupFileName = fileroot + Groups[i] +"."+ tag + "abund." + getOutputFileNameTag("list");
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ variables["[group]"] = Groups[i];
+ string rareGroupFileName = getOutputFileName("list",variables);
+ variables["[tag2]"] = "abund";
+ string abundGroupFileName = getOutputFileName("list",variables);
m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
outputNames.push_back(rareGroupFileName); outputTypes["list"].push_back(rareGroupFileName);
map<string, ofstream*> filehandles;
if (Groups.size() == 0) {
- string rare = outputDir + m->getRootName(m->getSimpleName(countfile)) + tag + "rare." + getOutputFileNameTag("count");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(countfile));
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ string rare = getOutputFileName("count",variables);
outputNames.push_back(rare); outputTypes["count"].push_back(rare);
-
- string abund = outputDir + m->getRootName(m->getSimpleName(countfile)) + tag + "abund." + getOutputFileNameTag("count");
+ variables["[tag2]"] = "abund";
+ string abund = getOutputFileName("count",variables);
outputNames.push_back(abund); outputTypes["count"].push_back(abund);
CountTable rareTable;
for (it3 = countTableMap.begin(); it3 != countTableMap.end(); it3++) {
string fileroot = outputDir + m->getRootName(m->getSimpleName(countfile));
- string filename = fileroot + it3->first + "." + getOutputFileNameTag("count");
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = it3->first;
+ string filename = getOutputFileName("count",variables);
outputNames.push_back(filename); outputTypes["count"].push_back(filename);
(it3->second)->printTable(filename);
delete it3->second;
ofstream aout;
ofstream rout;
- string rare = outputDir + m->getRootName(m->getSimpleName(namefile)) + "rare." + getOutputFileNameTag("name");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(namefile));
+ variables["[tag]"] = "rare";
+ string rare = getOutputFileName("name", variables);
m->openOutputFile(rare, rout);
outputNames.push_back(rare); outputTypes["name"].push_back(rare);
- string abund = outputDir + m->getRootName(m->getSimpleName(namefile)) + "abund." + getOutputFileNameTag("name");
+ variables["[tag]"] = "abund";
+ string abund = getOutputFileName("name", variables);
m->openOutputFile(abund, aout);
outputNames.push_back(abund); outputTypes["name"].push_back(abund);
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- string rareGroupFileName = fileroot + Groups[i] + ".rare." + getOutputFileNameTag("name");
- string abundGroupFileName = fileroot + Groups[i] + ".abund." + getOutputFileNameTag("name");
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = "rare";
+ variables["[group]"] = Groups[i];
+ string rareGroupFileName = getOutputFileName("name",variables);
+ variables["[tag]"] = "abund";
+ string abundGroupFileName = getOutputFileName("name",variables);
m->openOutputFile(rareGroupFileName, *(filehandles[Groups[i]+".rare"]));
m->openOutputFile(abundGroupFileName, *(filehandles[Groups[i]+".abund"]));
}
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
(*(filehandles[it3->first])).close();
- outputNames.push_back(fileroot + it3->first + "." + getOutputFileNameTag("name")); outputTypes["name"].push_back(fileroot + it3->first + "." + getOutputFileNameTag("name"));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = it3->first;
+ outputNames.push_back(getOutputFileName("name",variables)); outputTypes["name"].push_back(getOutputFileName("name",variables));
delete it3->second;
}
}
ofstream aout;
ofstream rout;
-
- string rare = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag + "rare." + getOutputFileNameTag("accnos");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(inputFile));
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ string rare = getOutputFileName("accnos",variables);
m->openOutputFile(rare, rout);
outputNames.push_back(rare); outputTypes["accnos"].push_back(rare);
}
rout.close();
- string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag + "abund." + getOutputFileNameTag("accnos");
+ variables["[tag2]"] = "abund";
+ string abund = getOutputFileName("accnos",variables);
m->openOutputFile(abund, aout);
outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("accnos"), *(filehandles[Groups[i]+".rare"]));
- m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("accnos"), *(filehandles[Groups[i]+".abund"]));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ variables["[group]"] = Groups[i];
+ m->openOutputFile(getOutputFileName("accnos",variables), *(filehandles[Groups[i]+".rare"]));
+ variables["[tag2]"] = "abund";
+ m->openOutputFile(getOutputFileName("accnos",variables), *(filehandles[Groups[i]+".abund"]));
}
//write rare
//close files
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
(*(filehandles[it3->first])).close();
- outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos")); outputTypes["accnos"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("accnos"));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = it3->first;
+ outputNames.push_back(getOutputFileName("accnos",variables)); outputTypes["accnos"].push_back(getOutputFileName("accnos",variables));
delete it3->second;
}
}
ofstream aout;
ofstream rout;
- string rare = outputDir + m->getRootName(m->getSimpleName(groupfile)) + tag + "rare." + getOutputFileNameTag("group");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(groupfile));
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ string rare = getOutputFileName("group",variables);
m->openOutputFile(rare, rout);
outputNames.push_back(rare); outputTypes["group"].push_back(rare);
- string abund = outputDir + m->getRootName(m->getSimpleName(groupfile)) + tag + "abund." + getOutputFileNameTag("group");
+ variables["[tag2]"] = "abund";
+ string abund = getOutputFileName("group",variables);
;
m->openOutputFile(abund, aout);
outputNames.push_back(abund); outputTypes["group"].push_back(abund);
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("group"), *(filehandles[Groups[i]+".rare"]));
- m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("group"), *(filehandles[Groups[i]+".abund"]));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ variables["[group]"] = Groups[i];
+ m->openOutputFile(getOutputFileName("group",variables), *(filehandles[Groups[i]+".rare"]));
+ variables["[tag2]"] = "abund";
+ m->openOutputFile(getOutputFileName("group",variables), *(filehandles[Groups[i]+".abund"]));
}
for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
(*(filehandles[it3->first])).close();
- outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group")); outputTypes["group"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("group"));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = it3->first;
+ outputNames.push_back(getOutputFileName("group",variables)); outputTypes["group"].push_back(getOutputFileName("group",variables));
delete it3->second;
}
}
ofstream aout;
ofstream rout;
- string rare = outputDir + m->getRootName(m->getSimpleName(fastafile)) + tag + "rare." + getOutputFileNameTag("fasta");
+ map<string, string> variables;
+ variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(fastafile));
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ string rare = getOutputFileName("fasta",variables);
m->openOutputFile(rare, rout);
outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
- string abund = outputDir + m->getRootName(m->getSimpleName(fastafile)) + tag + "abund." + getOutputFileNameTag("fasta");
+ variables["[tag2]"] = "abund";
+ string abund = getOutputFileName("fasta",variables);
m->openOutputFile(abund, aout);
outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
temp2 = new ofstream;
filehandles[Groups[i]+".abund"] = temp2;
- m->openOutputFile(fileroot + tag + Groups[i] + ".rare." + getOutputFileNameTag("fasta"), *(filehandles[Groups[i]+".rare"]));
- m->openOutputFile(fileroot + tag + Groups[i] + ".abund." + getOutputFileNameTag("fasta"), *(filehandles[Groups[i]+".abund"]));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = "rare";
+ variables["[group]"] = Groups[i];
+ m->openOutputFile(getOutputFileName("fasta",variables), *(filehandles[Groups[i]+".rare"]));
+ variables["[tag2]"] = "abund";
+ m->openOutputFile(getOutputFileName("fasta",variables), *(filehandles[Groups[i]+".abund"]));
}
//open input file
for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
(*(filehandles[it3->first])).close();
- outputNames.push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta")); outputTypes["fasta"].push_back(fileroot + tag + it3->first + "." + getOutputFileNameTag("fasta"));
+ map<string, string> variables;
+ variables["[filename]"] = fileroot;
+ variables["[tag]"] = tag;
+ variables["[tag2]"] = it3->first;
+ outputNames.push_back(getOutputFileName("fasta",variables)); outputTypes["fasta"].push_back(getOutputFileName("fasta",variables));
delete it3->second;
}
}