]> git.donarmstrong.com Git - mothur.git/blobdiff - getlabelcommand.cpp
fixed clearcut version bug, added group count output to get.groups and remove.groups
[mothur.git] / getlabelcommand.cpp
index be2a989d7a953be7b68a29ceca1a88c4d514bd20..3191d5dda80670b8490203032e35170cf7642044 100644 (file)
@@ -9,25 +9,58 @@
 
 #include "getlabelcommand.h"
 
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getValidParameters(){  
+       try {
+               string Array[] =  {"outputdir","inputdir"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getValidParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getRequiredParameters(){       
+       try {
+               vector<string> myArray;
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getRequiredParameters");
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+vector<string> GetlabelCommand::getRequiredFiles(){    
+       try {
+               string Array[] =  {"list","rabund","sabund", "or"};
+               vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
+               return myArray;
+       }
+       catch(exception& e) {
+               m->errorOut(e, "GetlabelCommand", "getRequiredFiles");
+               exit(1);
+       }
+}
 //**********************************************************************************************************************
 
-GetlabelCommand::GetlabelCommand(string option){
+GetlabelCommand::GetlabelCommand(string option)  {
        try {
                globaldata = GlobalData::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 {
-                       if (option != "") { mothurOut("There are no valid parameters for the get.label command."); mothurOutEndLine(); abort = true; }
-                       
-                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { mothurOut("You must read a list, sabund or rabund before you can use the get.label command."); mothurOutEndLine(); abort = true; }                               
+                       if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { m->mothurOut("You must read a list, sabund or rabund before you can use the get.label command."); m->mothurOutEndLine(); abort = true; }                         
                }
 
        }
        catch(exception& e) {
-               errorOut(e, "GetlabelCommand", "GetlabelCommand");
+               m->errorOut(e, "GetlabelCommand", "GetlabelCommand");
                exit(1);
        }
 }
@@ -35,14 +68,14 @@ GetlabelCommand::GetlabelCommand(string option){
 
 void GetlabelCommand::help(){
        try {
-               mothurOut("The get.label command can only be executed after a successful read.otu command.\n");
-               mothurOut("You may not use any parameters with the get.label command.\n");
-               mothurOut("The get.label command should be in the following format: \n");
-               mothurOut("get.label()\n");
-               mothurOut("Example get.label().\n");
+               m->mothurOut("The get.label command can only be executed after a successful read.otu command.\n");
+               m->mothurOut("You may not use any parameters with the get.label command.\n");
+               m->mothurOut("The get.label command should be in the following format: \n");
+               m->mothurOut("get.label()\n");
+               m->mothurOut("Example get.label().\n");
        }
        catch(exception& e) {
-               errorOut(e, "GetlabelCommand", "help");
+               m->errorOut(e, "GetlabelCommand", "help");
                exit(1);
        }
 }
@@ -57,19 +90,22 @@ GetlabelCommand::~GetlabelCommand(){
 int GetlabelCommand::execute(){
        try {
                
-               if (abort == true) { return 0; }
+               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
                
                filename = globaldata->inputFileName;
                ifstream in;
-               openInputFile(filename, in);
+               m->openInputFile(filename, in);
                string label;
                int numBins = 0;
                int count = -1;
                while(in.good()) {
+                       
+                       if (m->control_pressed) { in.close();  return 0; }
+                       
                        if(count > numBins)
                                count = 0;
                        if(count == 0) {
-                               mothurOut(label); mothurOutEndLine();
+                               m->mothurOut(label); m->mothurOutEndLine();
                                in >> numBins;
                        }
                        in >> label;
@@ -81,7 +117,7 @@ int GetlabelCommand::execute(){
        }
 
        catch(exception& e) {
-               errorOut(e, "GetlabelCommand", "execute");
+               m->errorOut(e, "GetlabelCommand", "execute");
                exit(1);
        }
 }