X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=pipelinepdscommand.cpp;h=b7ba7d382476ade9782660f4b9127c9c1b55b513;hb=3fd6dd6e4f19a458ac2966ee5458787e998a1bde;hp=26969d81c7b6d95a0f7c603489be1da984ea7d99;hpb=672cc1adbb2f8dac82757653cd579c093fe886c2;p=mothur.git diff --git a/pipelinepdscommand.cpp b/pipelinepdscommand.cpp index 26969d8..b7ba7d3 100644 --- a/pipelinepdscommand.cpp +++ b/pipelinepdscommand.cpp @@ -183,15 +183,14 @@ void PipelineCommand::help(){ try { m->mothurOut("The pipeline command is designed to guide you through your analysis using mothur.\n"); m->mothurOut("The pipeline command parameters are pipeline, sff, oligos, align, chimera, classify, taxonomy and processors.\n"); - m->mothurOut("The sff parameter allows you to enter your sff file. It is required.\n"); - m->mothurOut("The oligos parameter allows you to enter your oligos file. It is required.\n"); - m->mothurOut("The align parameter allows you to enter a template to use with the aligner. It is required.\n"); - m->mothurOut("The chimera parameter allows you to enter a template to use for chimera detection. It is required.\n"); - m->mothurOut("The classify parameter allows you to enter a template to use for classification. It is required.\n"); - m->mothurOut("The taxonomy parameter allows you to enter a taxonomy file for the classify template to use for classification. It is required.\n"); + m->mothurOut("The sff parameter allows you to enter your sff file. It is required, if not using pipeline parameter.\n"); + m->mothurOut("The oligos parameter allows you to enter your oligos file. It is required, if not using pipeline parameter.\n"); + m->mothurOut("The align parameter allows you to enter a template to use with the aligner. It is required, if not using pipeline parameter.\n"); + m->mothurOut("The chimera parameter allows you to enter a template to use for chimera detection. It is required, if not using pipeline parameter.\n"); + m->mothurOut("The classify parameter allows you to enter a template to use for classification. It is required, if not using pipeline parameter.\n"); + m->mothurOut("The taxonomy parameter allows you to enter a taxonomy file for the classify template to use for classification. It is required, if not using pipeline parameter.\n"); m->mothurOut("The processors parameter allows you to specify the number of processors to use. The default is 1.\n"); m->mothurOut("The pipeline parameter allows you to enter your own pipeline file. This file should look like a mothur batchfile, but where you would be using a mothur generated file, you can use mothurmade instead.\n"); - m->mothurOut("First column contains the command name, and the second column contains the parameter options or 'defaults', meaning use defaults. You may leave out file options.\n"); m->mothurOut("Example: trim.seqs(processors=8, allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, fasta=may1.v13.fasta, oligos=may1.v13.oligos, qfile=may1.v13.qual)\n"); m->mothurOut("then, you could enter unique.seqs(fasta=mothurmade), and mothur would use the .trim.fasta file from the trim.seqs command. \n"); m->mothurOut("then you could enter align.seqs(candidate=mothurmade, template=silva.v13.align, processors=8). , and mothur would use the .trim.unique.fasta file from the unique.seqs command. \n"); @@ -238,6 +237,8 @@ int PipelineCommand::execute(){ try { if (abort == true) { return 0; } + int start = time(NULL); + if (pipeFilename == "") { createPatsPipeline(); @@ -279,6 +280,8 @@ int PipelineCommand::execute(){ if (m->control_pressed) { return 0; } + m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run the pipeline analysis."); m->mothurOutEndLine(); m->mothurOutEndLine(); + m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } @@ -351,10 +354,14 @@ bool PipelineCommand::parseCommand(string nextCommand, string& name, string& opt bool PipelineCommand::checkForValidAndRequiredParameters(string name, string options, map >& mothurMadeFiles){ try { + + if (name == "system") { return false; } + + if (name == "system") { return false; } //get shell of the command so we can check to make sure its valid without running it Command* command = cFactory->getCommand(name); - + //check to make sure all parameters are valid for command vector validParameters = command->getValidParameters(); @@ -366,17 +373,21 @@ bool PipelineCommand::checkForValidAndRequiredParameters(string name, string opt map >::iterator itMade; for (it = parameters.begin(); it != parameters.end(); it++) { + if (validParameter.isValidParameter(it->first, validParameters, it->second) != true) { return true; } // not valid if (it->second == "mothurmade") { itMade = mothurMadeFiles.find(it->first); if (itMade == mothurMadeFiles.end()) { - m->mothurOut("You have the " + it->first + " listed as a mothurmade file for the " + name + " command, but it seems mothur will not make that file in your current pipeline, please correct."); m->mothurOutEndLine(); - return true; + if ((name == "align.seqs") && (it->first == "candidate")) {} //do nothing about candidate + else { + m->mothurOut("You have the " + it->first + " listed as a mothurmade file for the " + name + " command, but it seems mothur will not make that file in your current pipeline, please correct."); m->mothurOutEndLine(); + return true; + } } } } - + //is the command missing any required vector requiredParameters = command->getRequiredParameters(); @@ -395,7 +406,7 @@ bool PipelineCommand::checkForValidAndRequiredParameters(string name, string opt if (!hasOr) { m->mothurOut(name + " requires the " + requiredParameters[i] + " parameter, please correct."); m->mothurOutEndLine(); } } } - + // if all are needed and not all are found if ((!hasOr) && (numFound != requiredParameters.size())) { return true; } //if one is needed and none are found @@ -406,7 +417,7 @@ bool PipelineCommand::checkForValidAndRequiredParameters(string name, string opt for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { mothurMadeFiles[itMade->first] = itMade->second; //adds any new types } - + return false; } catch(exception& e) { @@ -431,8 +442,8 @@ int PipelineCommand::runUsersPipeline(){ CommandOptionParser parser(nextCommand); string commandName = parser.getCommandString(); string options = parser.getOptionString(); - - if (options != "") { + + if ((options != "") && (commandName != "system")) { bool error = fillInMothurMade(options, mothurMadeFiles); if (error) { in.close(); return 0; } } @@ -521,8 +532,9 @@ int PipelineCommand::runUsersPipeline(){ } } //********************************************************************************************************************** -bool PipelineCommand::fillInMothurMade(string& options, map > mothurMadeFiles){ +bool PipelineCommand::fillInMothurMade(string& options, map >& mothurMadeFiles){ try { + OptionParser parser(options); map parameters = parser.getParameters(); map::iterator it; @@ -532,21 +544,28 @@ bool PipelineCommand::fillInMothurMade(string& options, mapsecond == "mothurmade") { - itMade = mothurMadeFiles.find(it->first); + string paraType = it->first; + string tempOption = it->second; + + if (tempOption == "mothurmade") { + + if (it->first == "candidate") { paraType = "fasta"; } + + itMade = mothurMadeFiles.find(paraType); if (itMade == mothurMadeFiles.end()) { - m->mothurOut("Looking for a mothurmade " + it->first + " file, but it seems mothur has not made that file type in your current pipeline, please correct."); m->mothurOutEndLine(); + m->mothurOut("Looking for a mothurmade " + paraType + " file, but it seems mothur has not made that file type in your current pipeline, please correct."); m->mothurOutEndLine(); return true; }else{ vector temp = itMade->second; if (temp.size() > 1) { //ask user which file to use - m->mothurOut("More than one file has been created for the " + it->first + " parameter. "); m->mothurOutEndLine(); + m->mothurOut("More than one file has been created for the " + paraType + " parameter. "); m->mothurOutEndLine(); for (int i = 0; i < temp.size(); i++) { m->mothurOut(toString(i) + " - " + temp[i]); m->mothurOutEndLine(); } + m->mothurOut("Please select the number of the file you would like to use: "); int num = 0; cin >> num; @@ -554,23 +573,43 @@ bool PipelineCommand::fillInMothurMade(string& options, map (temp.size()-1))) { m->mothurOut("Not a valid response, quitting."); m->mothurOutEndLine(); return true; } else { - parameters[it->first] = temp[num]; + tempOption = temp[num]; } //clears buffer so next command doesn't have error string s; getline(cin, s); + vector newTemp; + for (int i = 0; i < temp.size(); i++) { + if (i == num) { newTemp.push_back(temp[i]); } + else { + m->mothurOut("Would you like to remove " + temp[i] + " as an option for " + paraType + ", (y/n): "); m->mothurOutEndLine(); + string response; + cin >> response; + m->mothurOutJustToLog(response); m->mothurOutEndLine(); + + if (response == "n") { newTemp.push_back(temp[i]); } + + //clears buffer so next command doesn't have error + string s; + getline(cin, s); + } + } + + mothurMadeFiles[paraType] = newTemp; + + }else if (temp.size() == 0){ - m->mothurOut("Sorry, we seem to think you created a " + it->first + " file, but it seems mothur doesn't have a filename."); m->mothurOutEndLine(); + m->mothurOut("Sorry, we seem to think you created a " + paraType + " file, but it seems mothur doesn't have a filename."); m->mothurOutEndLine(); return true; }else{ - parameters[it->first] = temp[0]; + tempOption = temp[0]; } } } - options += it->first + "=" + parameters[it->first] + ", "; + options += it->first + "=" + tempOption + ", "; } //rip off extra comma @@ -590,38 +629,38 @@ void PipelineCommand::createPatsPipeline(){ //sff.info command string thisCommand = "sffinfo(sff=" + sffFile + ")"; - //commands.push_back(thisCommand); + commands.push_back(thisCommand); //trim.seqs command string fastaFile = m->getRootName(m->getSimpleName(sffFile)) + "fasta"; string qualFile = m->getRootName(m->getSimpleName(sffFile)) + "qual"; - //thisCommand = "trim.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", allfiles=F, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, oligos=" + oligosFile + ", qfile=" + qualFile + ")"; - //commands.push_back(thisCommand); + thisCommand = "trim.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, oligos=" + oligosFile + ", qfile=" + qualFile + ")"; + commands.push_back(thisCommand); //unique.seqs string groupFile = m->getRootName(m->getSimpleName(fastaFile)) + "groups"; qualFile = m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual"; fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta"; - //thisCommand = "unique.seqs(fasta=" + fastaFile + ")"; - //commands.push_back(thisCommand); + thisCommand = "unique.seqs(fasta=" + fastaFile + ")"; + commands.push_back(thisCommand); //align.seqs string nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "names"; fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "unique" + m->getExtension(fastaFile); - //thisCommand = "align.seqs(processors=" + toString(processors) + ", candidate=" + fastaFile + ", template=" + alignFile + ")"; - //commands.push_back(thisCommand); + thisCommand = "align.seqs(processors=" + toString(processors) + ", candidate=" + fastaFile + ", template=" + alignFile + ")"; + commands.push_back(thisCommand); //screen.seqs fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "align"; - //thisCommand = "screen.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", name=" + nameFile + ", group=" + groupFile + ", optimize=end-minlength)"; - // commands.push_back(thisCommand); + thisCommand = "screen.seqs(processors=" + toString(processors) + ", fasta=" + fastaFile + ", name=" + nameFile + ", group=" + groupFile + ", optimize=end-minlength)"; + commands.push_back(thisCommand); //chimera.slayer fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "good" + m->getExtension(fastaFile); nameFile = m->getRootName(m->getSimpleName(nameFile)) + "good" + m->getExtension(nameFile); groupFile = m->getRootName(m->getSimpleName(groupFile)) + "good" + m->getExtension(groupFile); - //thisCommand = "chimera.slayer(processors=" + toString(processors) + ", fasta=" + fastaFile + ", template=" + chimeraFile + ")"; - // commands.push_back(thisCommand); + thisCommand = "chimera.slayer(processors=" + toString(processors) + ", fasta=" + fastaFile + ", template=" + chimeraFile + ")"; + commands.push_back(thisCommand); //remove.seqs string accnosFile = m->getRootName(m->getSimpleName(fastaFile)) + "slayer.accnos";