exit(1);
}
}
-
+//**********************************************************************************************************************
+string PhylotypeCommand::getOutputFileNameTag(string type, string inputName=""){
+ try {
+ string outputFileName = "";
+ map<string, vector<string> >::iterator it;
+
+ //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 == "list") { outputFileName = "list"; }
+ else if (type == "rabund") { outputFileName = "rabund"; }
+ else if (type == "sabund") { outputFileName = "sabund"; }
+ 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, "PhylotypeCommand", "getOutputFileNameTag");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
PhylotypeCommand::PhylotypeCommand(){
try {
m->mothurOut("No valid current files. taxonomy is a required parameter."); m->mothurOutEndLine();
abort = true;
}
- }else if (taxonomyFileName == "not open") { abort = true; }
+ }else if (taxonomyFileName == "not open") { taxonomyFileName = ""; abort = true; }
else { m->setTaxonomyFile(taxonomyFileName); }
namefile = validParameter.validFile(parameters, "name", true);
- if (namefile == "not open") { abort = true; }
+ if (namefile == "not open") { namefile = ""; abort = true; }
else if (namefile == "not found") { namefile = ""; }
else { readNamesFile(); m->setNameFile(namefile); }
else { allLines = 1; }
}
+ if (namefile == "") {
+ vector<string> files; files.push_back(taxonomyFileName);
+ parser.getNameFile(files);
+ }
+
}
}
catch(exception& e) {
string fileroot = outputDir + m->getRootName(m->getSimpleName(taxonomyFileName));
ofstream outList;
- string outputListFile = fileroot + "tx.list";
+ string outputListFile = fileroot + "tx." + getOutputFileNameTag("list");
m->openOutputFile(outputListFile, outList);
ofstream outSabund;
- string outputSabundFile = fileroot + "tx.sabund";
+ string outputSabundFile = fileroot + "tx." + getOutputFileNameTag("sabund");
m->openOutputFile(outputSabundFile, outSabund);
ofstream outRabund;
- string outputRabundFile = fileroot + "tx.rabund";
+ string outputRabundFile = fileroot + "tx." + getOutputFileNameTag("rabund");
m->openOutputFile(outputRabundFile, outRabund);
outputNames.push_back(outputListFile); outputTypes["list"].push_back(outputListFile);
ListVector list;
list.setLabel(level);
+
//go through nodes and build listvector
for (itCurrent = currentNodes.begin(); itCurrent != currentNodes.end(); itCurrent++) {
//make the names compatable with listvector
string name = "";
for (int i = 0; i < names.size(); i++) {
- if (namefile != "") {
- map<string, string>::iterator itNames = namemap.find(names[i]); //make sure this name is in namefile
-
- if (itNames != namemap.end()) { name += namemap[names[i]] + ","; } //you found it in namefile
- else { m->mothurOut(names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); exit(1); }
-
- }else{ name += names[i] + ","; }
+
+ if (names[i] != "unknown") {
+ if (namefile != "") {
+ map<string, string>::iterator itNames = namemap.find(names[i]); //make sure this name is in namefile
+
+ if (itNames != namemap.end()) { name += namemap[names[i]] + ","; } //you found it in namefile
+ else { m->mothurOut(names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); exit(1); }
+
+ }else{ name += names[i] + ","; }
+ }
}
name = name.substr(0, name.length()-1); //rip off extra ','
-
//add bin to list vector
- list.push_back(name);
+ if (name != "") { list.push_back(name); } //caused by unknown
}
//print listvector