X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getotuscommand.cpp;h=8d20e63b65b9a99b6476608fe4a108ce233718f0;hb=49d2b7459c5027557564b21e9487dadafbbbdc96;hp=4e8d3198c9b6c560d57ff579b26eb9985e452b35;hpb=0caf3fbabaa3ece404f8ce77f4c883dc5b1bf1dc;p=mothur.git diff --git a/getotuscommand.cpp b/getotuscommand.cpp index 4e8d319..8d20e63 100644 --- a/getotuscommand.cpp +++ b/getotuscommand.cpp @@ -53,7 +53,27 @@ string GetOtusCommand::getHelpString(){ exit(1); } } - +//********************************************************************************************************************** +string GetOtusCommand::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 == "group") { outputFileName = "pick" + m->getExtension(inputName); } + else if (type == "list") { outputFileName = "pick" + m->getExtension(inputName); } + 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, "GetOtusCommand", "getOutputFileNameTag"); + exit(1); + } +} //********************************************************************************************************************** GetOtusCommand::GetOtusCommand(){ try { @@ -182,7 +202,7 @@ int GetOtusCommand::execute(){ groupMap->readMap(); //get groups you want to get - if (accnosfile != "") { readAccnos(); } + if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); } //make sure groups are valid //takes care of user setting groupNames that are invalid or setting groups=all @@ -231,14 +251,14 @@ int GetOtusCommand::readListGroup(){ try { string thisOutputDir = outputDir; if (outputDir == "") { thisOutputDir += m->hasPath(listfile); } - string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick." + label + m->getExtension(listfile); + string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + label + "." + getOutputFileNameTag("list", listfile); ofstream out; m->openOutputFile(outputFileName, out); string GroupOutputDir = outputDir; if (outputDir == "") { GroupOutputDir += m->hasPath(groupfile); } - string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick." + label + m->getExtension(groupfile); + string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + label + "." + getOutputFileNameTag("group", groupfile); ofstream outGroup; m->openOutputFile(outputGroupFileName, outGroup); @@ -400,29 +420,5 @@ int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream } } //********************************************************************************************************************** -void GetOtusCommand::readAccnos(){ - try { - Groups.clear(); - - ifstream in; - m->openInputFile(accnosfile, in); - string name; - - while(!in.eof()){ - in >> name; - - Groups.push_back(name); - - m->gobble(in); - } - in.close(); - - } - catch(exception& e) { - m->errorOut(e, "GetOtusCommand", "readAccnos"); - exit(1); - } -} -//**********************************************************************************************************************