]> git.donarmstrong.com Git - mothur.git/blobdiff - clearcutcommand.cpp
fixed clearcut version bug, added group count output to get.groups and remove.groups
[mothur.git] / clearcutcommand.cpp
index 0d2da75284049cd377d9cf209de5d0eb44b4034c..7fd8c134a0fdee4c6f93075f1d97e9f5ab98000a 100644 (file)
@@ -8,8 +8,13 @@
  */
 
 #include "clearcutcommand.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
 #include "clearcut.h"
-
+#ifdef __cplusplus
+}
+#endif
 //**********************************************************************************************************************
 vector<string> ClearcutCommand::getValidParameters(){  
        try {
@@ -26,7 +31,7 @@ vector<string> ClearcutCommand::getValidParameters(){
 //**********************************************************************************************************************
 ClearcutCommand::ClearcutCommand(){    
        try {
-               //initialize outputTypes
+               abort = true; calledHelp = true; 
                vector<string> tempOutNames;
                outputTypes["tree"] = tempOutNames;
                outputTypes["matrixout"] = tempOutNames;
@@ -61,10 +66,10 @@ vector<string> ClearcutCommand::getRequiredFiles(){
 /**************************************************************************************/
 ClearcutCommand::ClearcutCommand(string option)  {     
        try {
-               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 {
                        //valid paramters for this command
@@ -225,7 +230,7 @@ void ClearcutCommand::help(){
 int ClearcutCommand::execute() {       
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                //prepare filename
                string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
@@ -305,6 +310,14 @@ int ClearcutCommand::execute() {
                delete[] clearcutParameters; 
                
                if (!stdoutWanted) {    
+                       
+                       //set first tree file as new current treefile
+                       string currentTree = "";
+                       itTypes = outputTypes.find("tree");
+                       if (itTypes != outputTypes.end()) {
+                               if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); }
+                       }
+                       
                        m->mothurOutEndLine();
                        m->mothurOut("Output File Names: "); m->mothurOutEndLine();
                        for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }