]> git.donarmstrong.com Git - mothur.git/blobdiff - clearcutcommand.cpp
modified the engine to extract the path of mothur executable if argv does not contain...
[mothur.git] / clearcutcommand.cpp
index f8d389c60d81654f944e6b892ef7ad19a6d91859..7bea292ee6b1dfd7afe9a2ce1300e6b71f2b1324 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include "clearcutcommand.h"
-#include "globaldata.hpp"
 
 /**************************************************************************************/
 ClearcutCommand::ClearcutCommand(string option)  {     
@@ -21,7 +20,7 @@ ClearcutCommand::ClearcutCommand(string option)  {
                else {
                        //valid paramters for this command
                        string Array[] =  {"fasta","phylip","version","verbose","quiet","seed","norandom","shuffle","neighbor","expblen",
-                                                               "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","stdin","outputdir","inputdir"};
+                                                               "expdist","ntrees","matrixout","stdout","kimura","jukes","protein","DNA","outputdir","inputdir"};
                        vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
                        
                        OptionParser parser(option);
@@ -73,7 +72,7 @@ ClearcutCommand::ClearcutCommand(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 = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = hasPath(inputFile); }
                        
                        string temp;
                        temp = validParameter.validFile(parameters, "version", false);          if (temp == "not found"){       temp = "F";                     }
@@ -96,9 +95,6 @@ ClearcutCommand::ClearcutCommand(string option)  {
                        temp = validParameter.validFile(parameters, "neighbor", false);         if (temp == "not found"){       temp = "F";                     }
                        neighbor = isTrue(temp); 
                        
-                       temp = validParameter.validFile(parameters, "stdin", false);            if (temp == "not found"){       temp = "F";                     }
-                       stdin = isTrue(temp); 
-                       
                        temp = validParameter.validFile(parameters, "DNA", false);                      if (temp == "not found"){       temp = "F";                     }
                        DNA = isTrue(temp);
                        
@@ -112,7 +108,7 @@ ClearcutCommand::ClearcutCommand(string option)  {
                        kimura = isTrue(temp);
                        
                        temp = validParameter.validFile(parameters, "stdout", false);           if (temp == "not found"){       temp = "F";                     }
-                       stdout = isTrue(temp); 
+                       stdoutWanted = isTrue(temp); 
                        
                        matrixout = validParameter.validFile(parameters, "matrixout", false);   if (matrixout == "not found"){  matrixout = "";         }
                        
@@ -140,7 +136,7 @@ void ClearcutCommand::help(){
                m->mothurOut("The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n");
                m->mothurOut("For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n");
                m->mothurOut("The clearcut executable must be in a folder called clearcut in the same folder as your mothur executable, similar to mothur's requirements for using blast. \n");
-               m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA, stdin. \n");
+               m->mothurOut("The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA. \n");
                m->mothurOut("The phylip parameter allows you to enter your phylip formatted distance matrix. \n");
                m->mothurOut("The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n");
                
@@ -152,7 +148,6 @@ void ClearcutCommand::help(){
                m->mothurOut("The shuffle parameter allows you to randomly shuffle the distance matrix, default=F. \n");
                m->mothurOut("The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=F. \n");
                
-               m->mothurOut("The stdin parameter reads input from STDIN, default=F. \n");
                m->mothurOut("The DNA parameter allows you to indicate your fasta file contains DNA sequences, default=F. \n");
                m->mothurOut("The protein parameter allows you to indicate your fasta file contains protein sequences, default=F. \n");
                
@@ -165,6 +160,7 @@ void ClearcutCommand::help(){
                m->mothurOut("The clearcut command should be in the following format: \n");
                m->mothurOut("clearcut(phylip=yourDistanceFile) \n");
                m->mothurOut("Example: clearcut(phylip=abrecovery.phylip.dist) \n");    
+               
        }
        catch(exception& e) {
                m->errorOut(e, "ClearcutCommand", "help");
@@ -185,9 +181,9 @@ int ClearcutCommand::execute() {
                GlobalData* globaldata = GlobalData::getInstance();
                string path = globaldata->argv;
                path = path.substr(0, (path.find_last_of('m')));
-
-               string clearcutCommand = path + "clearcut/clearcut ";
                
+               string clearcutCommand = path + "clearcut ";
+                               
                //you gave us a distance matrix
                if (phylipfile != "") { clearcutCommand += "--distance ";       }
                
@@ -202,27 +198,37 @@ int ClearcutCommand::execute() {
                if (shuffle)                    {  clearcutCommand += "--shuffle ";             }
                if (neighbor)                   {  clearcutCommand += "--neighbor ";    }
                
-               if (stdin)                              {  clearcutCommand += "--stdin ";               }
-               else                                    {  clearcutCommand += "--in=" + inputFile + " "; }
-               if (stdout)                             {  clearcutCommand += "--stdout ";              }
-               else                                    {  clearcutCommand += "--out=" + outputName + " "; }
+               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                       clearcutCommand += "--in=" + inputFile + " "; 
+               #else
+                       clearcutCommand += "--in=\"" + inputFile + "\" "; 
+               #endif
+               
+               if (stdoutWanted)               {  clearcutCommand += "--stdout ";              }
+               else{  
+                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+                               clearcutCommand += "--out=" + outputName + " "; }
+                       #else
+                               clearcutCommand += "--out=\"" + outputName + "\" "; }
+                       #endif
                
                if (DNA)                                {  clearcutCommand += "--DNA ";                 }
                if (protein)                    {  clearcutCommand += "--protein ";             }
                if (jukes)                              {  clearcutCommand += "--jukes ";               }
                if (kimura)                             {  clearcutCommand += "--kimura ";              }
-               if (matrixout != "")    {  clearcutCommand += "--matrixout=" + matrixout + " "; }
+               if (matrixout != "")    {  clearcutCommand += "--matrixout=" + matrixout + " ";  }
                if (ntrees != "1")              {  clearcutCommand += "--ntrees=" + ntrees + " "; }
                if (expblen)                    {  clearcutCommand += "--expblen ";             }
                if (expdist)                    {  clearcutCommand += "--expdist ";             }
-               
+       
                //run clearcut
                system(clearcutCommand.c_str());
                
-               if (!stdout) {  
+               if (!stdoutWanted) {    
                        m->mothurOutEndLine();
                        m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       m->mothurOut(outputName); m->mothurOutEndLine();        
+                       m->mothurOut(outputName); m->mothurOutEndLine();
+                       if (matrixout != "")    {  m->mothurOut(matrixout); m->mothurOutEndLine();  }
                        m->mothurOutEndLine();
                }