X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getlabelcommand.cpp;h=3191d5dda80670b8490203032e35170cf7642044;hb=c3396974063d6efc5e5850ddf4ed8ab65cc94bb9;hp=e0c17204e7c732ed180fd134a1a7c0d05a105c40;hpb=0470f6d037aacb3563c3f7010708120a4a67d4e6;p=mothur.git diff --git a/getlabelcommand.cpp b/getlabelcommand.cpp index e0c1720..3191d5d 100644 --- a/getlabelcommand.cpp +++ b/getlabelcommand.cpp @@ -9,51 +9,75 @@ #include "getlabelcommand.h" +//********************************************************************************************************************** +vector GetlabelCommand::getValidParameters(){ + try { + string Array[] = {"outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetlabelCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetlabelCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetlabelCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetlabelCommand::getRequiredFiles(){ + try { + string Array[] = {"list","rabund","sabund", "or"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetlabelCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** -GetlabelCommand::GetlabelCommand(string option){ +GetlabelCommand::GetlabelCommand(string option) { try { globaldata = GlobalData::getInstance(); - abort = false; + abort = false; calledHelp = false; //allow user to run help - if(option == "help") { help(); abort = true; } + if(option == "help") { help(); abort = true; calledHelp = true; } else { - if (option != "") { cout << "There are no valid parameters for the get.label command." << endl; abort = true; } - - if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the get.label command." << endl; abort = true; } + if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund or rabund before you can use the get.label command."); m->mothurOutEndLine(); abort = true; } } } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "GetlabelCommand", "GetlabelCommand"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the GetlabelCommand class function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - } //********************************************************************************************************************** void GetlabelCommand::help(){ try { - cout << "The get.label command can only be executed after a successful read.otu command." << "\n"; - cout << "You may not use any parameters with the get.label command." << "\n"; - cout << "The get.label command should be in the following format: " << "\n"; - cout << "get.label()" << "\n"; - cout << "Example get.label()." << "\n"; + m->mothurOut("The get.label command can only be executed after a successful read.otu command.\n"); + m->mothurOut("You may not use any parameters with the get.label command.\n"); + m->mothurOut("The get.label command should be in the following format: \n"); + m->mothurOut("get.label()\n"); + m->mothurOut("Example get.label().\n"); } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "GetlabelCommand", "help"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the GetlabelCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } } //********************************************************************************************************************** @@ -66,34 +90,35 @@ GetlabelCommand::~GetlabelCommand(){ int GetlabelCommand::execute(){ try { - if (abort == true) { return 0; } + if (abort == true) { if (calledHelp) { return 0; } return 2; } filename = globaldata->inputFileName; ifstream in; - openInputFile(filename, in); + m->openInputFile(filename, in); string label; int numBins = 0; int count = -1; while(in.good()) { + + if (m->control_pressed) { in.close(); return 0; } + if(count > numBins) count = 0; if(count == 0) { - cout << label << "\n"; + m->mothurOut(label); m->mothurOutEndLine(); in >> numBins; } in >> label; count++; } + + in.close(); return 0; } catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + m->errorOut(e, "GetlabelCommand", "execute"); exit(1); } - catch(...) { - cout << "An unknown error has occurred in the GetlabelCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } }