X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getsabundcommand.cpp;h=5425c41a917f4b02d67c5b4dfcb63e1b2fc6159b;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=799d8dced192019f65a633e946262db92c1e615f;hpb=7bf9a81bba76538ecaf351ae208de3da4bf1b6dd;p=mothur.git diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp index 799d8dc..5425c41 100644 --- a/getsabundcommand.cpp +++ b/getsabundcommand.cpp @@ -45,7 +45,26 @@ string GetSAbundCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string GetSAbundCommand::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 == "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, "GetSAbundCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** GetSAbundCommand::GetSAbundCommand(){ try { @@ -166,7 +185,7 @@ int GetSAbundCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } - filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "sabund"; + filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + getOutputFileNameTag("sabund"); m->openOutputFile(filename, out); input = new InputData(inputfile, format); @@ -178,7 +197,7 @@ int GetSAbundCommand::execute(){ set processedLabels; set userLabels = labels; - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { @@ -188,7 +207,7 @@ int GetSAbundCommand::execute(){ sabund->print(out); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -203,7 +222,7 @@ int GetSAbundCommand::execute(){ m->mothurOut(sabund->getLabel()); m->mothurOutEndLine(); sabund->print(out); - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete sabund; delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete sabund; delete input; return 0; } processedLabels.insert(sabund->getLabel()); userLabels.erase(sabund->getLabel()); @@ -241,7 +260,7 @@ int GetSAbundCommand::execute(){ sabund->print(out); delete sabund; - if (m->control_pressed) { outputTypes.clear(); out.close(); remove(filename.c_str()); delete input; return 0; } + if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); delete input; return 0; } }