X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getgroupcommand.cpp;h=2847db149ac5e40defdbfdedfd9d99ae3df5d583;hb=3fd6dd6e4f19a458ac2966ee5458787e998a1bde;hp=b645517f938928c44eb5faa5871e4171c40fb800;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp index b645517..2847db1 100644 --- a/getgroupcommand.cpp +++ b/getgroupcommand.cpp @@ -9,6 +9,54 @@ #include "getgroupcommand.h" +//********************************************************************************************************************** +vector GetgroupCommand::getValidParameters(){ + try { + string Array[] = {"outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetgroupCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +GetgroupCommand::GetgroupCommand(){ + try { + abort = true; + //initialize outputTypes + vector tempOutNames; + outputTypes["bootgroup"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "GetgroupCommand", "GetgroupCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetgroupCommand::getRequiredParameters(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetgroupCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector GetgroupCommand::getRequiredFiles(){ + try { + string Array[] = {"shared"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "GetgroupCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** GetgroupCommand::GetgroupCommand(string option) { try { @@ -32,6 +80,10 @@ GetgroupCommand::GetgroupCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["bootgroup"] = tempOutNames; + //if the user changes the output directory command factory will send this info to us in the output parameter string outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; } @@ -40,12 +92,12 @@ GetgroupCommand::GetgroupCommand(string option) { if (abort == false) { //open shared file sharedfile = globaldata->getSharedFile(); - openInputFile(sharedfile, in); + m->openInputFile(sharedfile, in); //open output file - if (outputDir == "") { outputDir += hasPath(sharedfile); } - outputFile = outputDir + getRootName(getSimpleName(sharedfile)) + "bootGroups"; - openOutputFile(outputFile, out); + if (outputDir == "") { outputDir += m->hasPath(sharedfile); } + outputFile = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "bootGroups"; + m->openOutputFile(outputFile, out); } } @@ -102,10 +154,14 @@ int GetgroupCommand::execute(){ in >> inputData; } + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); remove(outputFile.c_str()); return 0; } + if (in.eof() != true) { in >> nextLabel; } //read the rest of the groups info in while ((nextLabel == holdLabel) && (in.eof() != true)) { + if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); remove(outputFile.c_str()); return 0; } + in >> groupN >> num; count++; @@ -124,9 +180,11 @@ int GetgroupCommand::execute(){ in.close(); out.close(); + if (m->control_pressed) { remove(outputFile.c_str()); return 0; } + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); - m->mothurOut(outputFile); m->mothurOutEndLine(); + m->mothurOut(outputFile); m->mothurOutEndLine(); outputNames.push_back(outputFile); outputTypes["bootgroup"].push_back(outputFile); m->mothurOutEndLine(); return 0;