X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=secondarystructurecommand.cpp;h=36e0f609ca67bd3cd37e7c0d33a98e88cee65e6f;hb=8bc3e5b38c2317a1715f53be22fa96455868c281;hp=e23a0ac6a431ad14cdab21fb0bfa4276f4afd8c6;hpb=74844a60d80c6dd06e3fb02ee9b928424f9019b0;p=mothur.git diff --git a/secondarystructurecommand.cpp b/secondarystructurecommand.cpp index e23a0ac..36e0f60 100644 --- a/secondarystructurecommand.cpp +++ b/secondarystructurecommand.cpp @@ -10,6 +10,53 @@ #include "secondarystructurecommand.h" #include "sequence.hpp" +//********************************************************************************************************************** +vector AlignCheckCommand::getValidParameters(){ + try { + string Array[] = {"fasta","map", "outputdir","inputdir"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "AlignCheckCommand", "getValidParameters"); + exit(1); + } +} +//********************************************************************************************************************** +AlignCheckCommand::AlignCheckCommand(){ + try { + //initialize outputTypes + vector tempOutNames; + outputTypes["aligncheck"] = tempOutNames; + } + catch(exception& e) { + m->errorOut(e, "AlignCheckCommand", "AlignCheckCommand"); + exit(1); + } +} +//********************************************************************************************************************** +vector AlignCheckCommand::getRequiredParameters(){ + try { + string Array[] = {"fasta","map"}; + vector myArray (Array, Array+(sizeof(Array)/sizeof(string))); + return myArray; + } + catch(exception& e) { + m->errorOut(e, "AlignCheckCommand", "getRequiredParameters"); + exit(1); + } +} +//********************************************************************************************************************** +vector AlignCheckCommand::getRequiredFiles(){ + try { + vector myArray; + return myArray; + } + catch(exception& e) { + m->errorOut(e, "AlignCheckCommand", "getRequiredFiles"); + exit(1); + } +} //********************************************************************************************************************** AlignCheckCommand::AlignCheckCommand(string option) { @@ -36,6 +83,10 @@ AlignCheckCommand::AlignCheckCommand(string option) { if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; } } + //initialize outputTypes + vector tempOutNames; + outputTypes["aligncheck"] = 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 = ""; } @@ -44,7 +95,7 @@ AlignCheckCommand::AlignCheckCommand(string option) { it = parameters.find("fasta"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["fasta"] = inputDir + it->second; } } @@ -52,7 +103,7 @@ AlignCheckCommand::AlignCheckCommand(string option) { it = parameters.find("map"); //user has given a template file if(it != parameters.end()){ - path = hasPath(it->second); + path = m->hasPath(it->second); //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["map"] = inputDir + it->second; } } @@ -70,7 +121,7 @@ AlignCheckCommand::AlignCheckCommand(string option) { //if the user changes the output directory command factory will send this info to us in the output parameter outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = ""; - outputDir += hasPath(fastafile); //if user entered a file with a path then preserve it + outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it } } @@ -109,19 +160,20 @@ int AlignCheckCommand::execute(){ readMap(); ifstream in; - openInputFile(fastafile, in); + m->openInputFile(fastafile, in); ofstream out; - string outfile = outputDir + getRootName(getSimpleName(fastafile)) + "align.check"; - openOutputFile(outfile, out); + string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "align.check"; + m->openOutputFile(outfile, out); out << "name" << '\t' << "pound" << '\t' << "dash" << '\t' << "plus" << '\t' << "equal" << '\t'; out << "loop" << '\t' << "tilde" << '\t' << "total" << endl; while(!in.eof()){ + if (m->control_pressed) { in.close(); out.close(); remove(outfile.c_str()); return 0; } - Sequence seq(in); gobble(in); + Sequence seq(in); m->gobble(in); if (seq.getName() != "") { statData data = getStats(seq.getAligned()); @@ -135,9 +187,11 @@ int AlignCheckCommand::execute(){ in.close(); out.close(); + if (m->control_pressed) { remove(outfile.c_str()); return 0; } + m->mothurOutEndLine(); m->mothurOut("Output File Name: "); m->mothurOutEndLine(); - m->mothurOut(outfile); m->mothurOutEndLine(); + m->mothurOut(outfile); m->mothurOutEndLine(); outputNames.push_back(outfile); outputTypes["aligncheck"].push_back(outfile); m->mothurOutEndLine(); return 0; @@ -155,13 +209,13 @@ void AlignCheckCommand::readMap(){ structMap.resize(1, 0); ifstream in; - openInputFile(mapfile, in); + m->openInputFile(mapfile, in); while(!in.eof()){ int position; in >> position; structMap.push_back(position); - gobble(in); + m->gobble(in); } in.close();