]> git.donarmstrong.com Git - mothur.git/blobdiff - pipelinepdscommand.cpp
worked on trim.seqs - added in the groupfiles for allfiles=t, cleaned up the outputNa...
[mothur.git] / pipelinepdscommand.cpp
index d928122787c965beafb78b12eb42b901367a4eb9..84282dcc39105c7f4d560b88fcacdcb4ed4342d6 100644 (file)
@@ -49,10 +49,10 @@ vector<string> PipelineCommand::getRequiredFiles(){
 PipelineCommand::PipelineCommand(string option) {
        try {
                cFactory = CommandFactory::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 {
                        
@@ -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");
@@ -236,7 +235,7 @@ PipelineCommand::~PipelineCommand(){}
 
 int PipelineCommand::execute(){
        try {
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                int start = time(NULL);
                
@@ -355,12 +354,14 @@ bool PipelineCommand::parseCommand(string nextCommand, string& name, string& opt
 
 bool PipelineCommand::checkForValidAndRequiredParameters(string name, string options, map<string, vector<string> >& 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<string> validParameters = command->getValidParameters();
                
@@ -372,6 +373,7 @@ bool PipelineCommand::checkForValidAndRequiredParameters(string name, string opt
                map<string, vector<string> >::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);
@@ -385,7 +387,7 @@ bool PipelineCommand::checkForValidAndRequiredParameters(string name, string opt
                                }
                        }
                }
-               
+                       
                //is the command missing any required
                vector<string> requiredParameters = command->getRequiredParameters();
                
@@ -404,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
@@ -415,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) {
@@ -440,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; }
                                }
@@ -523,6 +525,8 @@ int PipelineCommand::runUsersPipeline(){
                }
                
                in.close();
+               
+               return 0;
        }
        catch(exception& e) {
                m->errorOut(e, "PipelineCommand", "runUsersPipeline");
@@ -532,6 +536,7 @@ int PipelineCommand::runUsersPipeline(){
 //**********************************************************************************************************************
 bool PipelineCommand::fillInMothurMade(string& options, map<string, vector<string> >& mothurMadeFiles){
        try {
+               
                OptionParser parser(options);
                map<string, string> parameters = parser.getParameters(); 
                map<string, string>::iterator it;