]> git.donarmstrong.com Git - mothur.git/blobdiff - getlabelcommand.cpp
added groups option to read.otu, added qtrim option to trim.seqs, fixed bug in get...
[mothur.git] / getlabelcommand.cpp
index 1e272673a502df4e39de245c32700eb8bdb25a93..be2a989d7a953be7b68a29ceca1a88c4d514bd20 100644 (file)
@@ -9,21 +9,42 @@
 
 #include "getlabelcommand.h"
 
+//**********************************************************************************************************************
 
-
-GetlabelCommand::GetlabelCommand(){
+GetlabelCommand::GetlabelCommand(string option){
        try {
                globaldata = GlobalData::getInstance();
+               abort = false;
+               
+               //allow user to run help
+               if(option == "help") { help(); abort = 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; }                               
+               }
+
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlabelCommand", "GetlabelCommand");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlabelCommand class function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+}
+//**********************************************************************************************************************
+
+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");
+       }
+       catch(exception& e) {
+               errorOut(e, "GetlabelCommand", "help");
                exit(1);
-       }       
-                       
+       }
 }
 
 //**********************************************************************************************************************
@@ -35,34 +56,33 @@ GetlabelCommand::~GetlabelCommand(){
 
 int GetlabelCommand::execute(){
        try {
+               
+               if (abort == true) { return 0; }
+               
                filename = globaldata->inputFileName;
                ifstream in;
                openInputFile(filename, in);
                string label;
                int numBins = 0;
                int count = -1;
-               while(in.good())
-               {
+               while(in.good()) {
                        if(count > numBins)
                                count = 0;
-                       if(count == 0)
-                       {
-                               cout << label << "\n";
+                       if(count == 0) {
+                               mothurOut(label); mothurOutEndLine();
                                in >> numBins;
                        }
                        in >> label;
                        count++;
                }       
+               
+               in.close();
                return 0;       
        }
 
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "GetlabelCommand", "execute");
                exit(1);
        }
-       catch(...) {
-               cout << "An unknown error has occurred in the GetlabelCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }       
 }