X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=phylotypecommand.cpp;h=eddddfa0534f547cfa1802b75211f1c6c9950f65;hb=9b53f130ac9af5e95444ce2e817fce25ed19ff03;hp=2d2db08a40ea5e1aa8712902dcd419ddb1ad757a;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/phylotypecommand.cpp b/phylotypecommand.cpp index 2d2db08..eddddfa 100644 --- a/phylotypecommand.cpp +++ b/phylotypecommand.cpp @@ -53,7 +53,28 @@ string PhylotypeCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string PhylotypeCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::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 { @@ -198,13 +219,13 @@ int PhylotypeCommand::execute(){ 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); @@ -251,11 +272,14 @@ int PhylotypeCommand::execute(){ map::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 { m->mothurOut("[ERROR]: " + names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; } }else{ name += names[i] + ","; } } } + + if (m->control_pressed) { break; } + name = name.substr(0, name.length()-1); //rip off extra ',' //add bin to list vector if (name != "") { list.push_back(name); } //caused by unknown