]> git.donarmstrong.com Git - mothur.git/blobdiff - commandfactory.cpp
added check to cluster.classic to make sure file type is phylip. added mapping funct...
[mothur.git] / commandfactory.cpp
index 0c9504d09a109a39168af9b9d582ef20732e6647..1241a04e998537fe33446a1c9ba3d933e690e557 100644 (file)
 #include "cooccurrencecommand.h"
 #include "pcrseqscommand.h"
 #include "createdatabasecommand.h"
+#include "makebiomcommand.h"
+#include "getcoremicrobiomecommand.h"
+#include "listotulabelscommand.h"
+#include "makecontigscommand.h"
 
 /*******************************************************/
 
@@ -281,6 +285,10 @@ CommandFactory::CommandFactory(){
     commands["cooccurrence"]        = "cooccurrence";
     commands["pcr.seqs"]            = "pcr.seqs";
     commands["create.database"]     = "create.database";
+    commands["make.biom"]           = "make.biom";
+    commands["get.coremicrobiome"]  = "get.coremicrobiome";
+    commands["list.otulabels"]      = "list.otulabels";
+    commands["make.contigs"]        = "make.contigs";
        commands["quit"]                                = "MPIEnabled"; 
 
 }
@@ -304,7 +312,49 @@ CommandFactory::~CommandFactory(){
        delete shellcommand;
        delete pipecommand;
 }
+/***********************************************************/
 
+/***********************************************************/
+int CommandFactory::checkForRedirects(string optionString) {
+    try {
+        
+        int pos = optionString.find("outputdir");
+        if (pos != string::npos) { //user has set outputdir in command option string
+            string outputOption = "";
+            bool foundEquals = false;
+            for(int i=pos;i<optionString.length();i++){
+                if(optionString[i] == ',')       { break;               }              
+                else if(optionString[i] == '=')  { foundEquals = true; }
+                if (foundEquals)       {   outputOption += optionString[i]; }
+            }
+            if(m->dirCheck(outputOption)){ 
+                setOutputDirectory(outputOption); 
+                m->mothurOut("Setting output directory to: " + outputOption); m->mothurOutEndLine();
+            }
+        }
+        
+        pos = optionString.find("inputdir");
+        if (pos != string::npos) { //user has set inputdir in command option string
+            string intputOption = "";
+            bool foundEquals = false;
+            for(int i=pos;i<optionString.length();i++){
+                if(optionString[i] == ',')       { break;               }              
+                else if(optionString[i] == '=')  { foundEquals = true; }
+                if (foundEquals)       {   intputOption += optionString[i]; }
+            }
+            if(m->dirCheck(intputOption)){ 
+                setInputDirectory(intputOption); 
+                m->mothurOut("Setting input directory to: " + intputOption); m->mothurOutEndLine();
+            }
+        }
+        
+        return 0;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "CommandFactory", "getCommand");
+               exit(1);
+       }
+}
 /***********************************************************/
 
 /***********************************************************/
@@ -313,7 +363,9 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
        try {
         
                delete command;   //delete the old command
-               
+        
+        checkForRedirects(optionString);
+                       
                //user has opted to redirect output from dir where input files are located to some other place
                if (outputDir != "") { 
                        if (optionString != "") { optionString += ", outputdir=" + outputDir; }
@@ -446,6 +498,10 @@ Command* CommandFactory::getCommand(string commandName, string optionString){
         else if(commandName == "cooccurrence")          {      command = new CooccurrenceCommand(optionString);            }
         else if(commandName == "pcr.seqs")              {      command = new PcrSeqsCommand(optionString);                 }
         else if(commandName == "create.database")       {      command = new CreateDatabaseCommand(optionString);          }
+        else if(commandName == "make.biom")             {      command = new MakeBiomCommand(optionString);                }
+        else if(commandName == "get.coremicrobiome")    {      command = new GetCoreMicroBiomeCommand(optionString);       }
+        else if(commandName == "list.otulabels")        {      command = new ListOtuLabelsCommand(optionString);           }
+        else if(commandName == "make.contigs")          {      command = new MakeContigsCommand(optionString);             }
                else                                                                                    {       command = new NoCommand(optionString);                                          }
 
                return command;
@@ -463,6 +519,8 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str
        try {
                delete pipecommand;   //delete the old command
                
+        checkForRedirects(optionString);
+        
                //user has opted to redirect output from dir where input files are located to some other place
                if (outputDir != "") { 
                        if (optionString != "") { optionString += ", outputdir=" + outputDir; }
@@ -594,6 +652,10 @@ Command* CommandFactory::getCommand(string commandName, string optionString, str
         else if(commandName == "cooccurrence")          {      pipecommand = new CooccurrenceCommand(optionString);            }
         else if(commandName == "pcr.seqs")              {      pipecommand = new PcrSeqsCommand(optionString);                 }
         else if(commandName == "create.database")       {      pipecommand = new CreateDatabaseCommand(optionString);          }
+        else if(commandName == "make.biom")             {      pipecommand = new MakeBiomCommand(optionString);                }
+        else if(commandName == "get.coremicrobiome")    {      pipecommand = new GetCoreMicroBiomeCommand(optionString);       }
+        else if(commandName == "list.otulabels")        {      pipecommand = new ListOtuLabelsCommand(optionString);           }
+        else if(commandName == "make.contigs")          {      pipecommand = new MakeContigsCommand(optionString);             }
                else                                                                                    {       pipecommand = new NoCommand(optionString);                                              }
 
                return pipecommand;
@@ -730,6 +792,10 @@ Command* CommandFactory::getCommand(string commandName){
         else if(commandName == "cooccurrence")          {      shellcommand = new CooccurrenceCommand();           }
         else if(commandName == "pcr.seqs")              {      shellcommand = new PcrSeqsCommand();                }
         else if(commandName == "create.database")       {      shellcommand = new CreateDatabaseCommand();         }
+        else if(commandName == "make.biom")             {      shellcommand = new MakeBiomCommand();               }
+        else if(commandName == "get.coremicrobiome")    {      shellcommand = new GetCoreMicroBiomeCommand();      }
+        else if(commandName == "list.otulabels")        {      shellcommand = new ListOtuLabelsCommand();          }
+        else if(commandName == "make.contigs")          {      shellcommand = new MakeContigsCommand();            }
                else                                                                                    {       shellcommand = new NoCommand();                                         }
 
                return shellcommand;