X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=chimerabellerophoncommand.cpp;h=6d0a116ac4d0d5d1bb2b8cf97f1ea5a1b5126fef;hb=8bc3e5b38c2317a1715f53be22fa96455868c281;hp=5972c62f028100b71b9007785af7c9d4600aaeb4;hpb=f663afa231c9bc1b5e18e0ea3bdd2b2ee784f5b2;p=mothur.git diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp index 5972c62..6d0a116 100644 --- a/chimerabellerophoncommand.cpp +++ b/chimerabellerophoncommand.cpp @@ -10,8 +10,55 @@ #include "chimerabellerophoncommand.h" #include "bellerophon.h" +//********************************************************************************************************************** +vector ChimeraBellerophonCommand::getValidParameters(){ + try { + string AlignArray[] = {"fasta","filter","correction","processors","window","increment","outputdir","inputdir"}; + vector myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ChimeraBellerophonCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector ChimeraBellerophonCommand::getRequiredParameters(){ + try { + string AlignArray[] = {"fasta"}; + vector myArray (AlignArray, AlignArray+(sizeof(AlignArray)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ChimeraBellerophonCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector ChimeraBellerophonCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "ChimeraBellerophonCommand", "getRequiredFiles"); + exit(1); + } +} +//********************************************************************************************************************** +ChimeraBellerophonCommand::ChimeraBellerophonCommand(){ + try { + //initialize outputTypes + vector tempOutNames; + outputTypes["chimera"] = tempOutNames; + outputTypes["accnos"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand"); + exit(1); + } +} //*************************************************************************************************************** - ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option) { try { abort = false; @@ -35,6 +82,11 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["chimera"] = tempOutNames; + outputTypes["accnos"] = tempOutNames; + //if the user changes the input directory command factory will send this info to us in the output parameter string inputDir = validParameter.validFile(parameters, "inputdir", false); if (inputDir == "not found"){ inputDir = ""; } @@ -66,6 +118,17 @@ ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option) { fastaFileNames[i] = tryPath; } } + + //if you can't open it, try default location + if (ableToOpen == 1) { + if (m->getOutputDir() != "") { //default path is set + string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]); + m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); + ableToOpen = m->openInputFile(tryPath, in, "noerror"); + fastaFileNames[i] = tryPath; + } + } + in.close(); if (ableToOpen == 1) { @@ -156,7 +219,7 @@ int ChimeraBellerophonCommand::execute(){ chimera->getChimeras(); - if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); return 0; } #ifdef USE_MPI MPI_File outMPI; @@ -192,12 +255,12 @@ int ChimeraBellerophonCommand::execute(){ #endif - if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } delete chimera; return 0; } + if (m->control_pressed) { remove(accnosFileName.c_str()); remove(outputFileName.c_str()); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); delete chimera; return 0; } m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); - outputNames.push_back(outputFileName); - outputNames.push_back(accnosFileName); + outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName); + outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName); delete chimera; }