]> git.donarmstrong.com Git - mothur.git/blobdiff - getgroupcommand.cpp
broke up globaldata and moved error checking and help into commands
[mothur.git] / getgroupcommand.cpp
index 4d439592127e53ff8b61fc465ef5e27db238e49e..ea6ef1760a763f6962f1f259a512b519fc659956 100644 (file)
@@ -9,18 +9,31 @@
 
 #include "getgroupcommand.h"
 
-
-GetgroupCommand::GetgroupCommand(){
+//**********************************************************************************************************************
+GetgroupCommand::GetgroupCommand(string option){
        try {
                globaldata = GlobalData::getInstance();
+               abort = false;
                
-               //open shared file
-               sharedfile = globaldata->getSharedFile();
-               openInputFile(sharedfile, in);
+               //allow user to run help
+               if(option == "help") { help(); abort = true; }
                
-               //open output file
-               outputFile = getRootName(globaldata->inputFileName) + "bootGroups";
-               openOutputFile(outputFile, out);
+               else {
+                       if (option != "") { cout << "There are no valid parameters for the get.group command." << endl; abort = true; }
+                       
+                       if ((globaldata->getSharedFile() == "")) { cout << "You must use the read.otu command to read a groupfile or a sharedfile before you can use the get.group command." << endl; abort = true; }
+                               
+                       if (abort == false) {
+                               //open shared file
+                               sharedfile = globaldata->getSharedFile();
+                               openInputFile(sharedfile, in);
+               
+                               //open output file
+                               outputFile = getRootName(sharedfile) + "bootGroups";
+                               openOutputFile(outputFile, out);
+
+                       }
+               }
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -32,6 +45,27 @@ GetgroupCommand::GetgroupCommand(){
        }       
                        
 }
+//**********************************************************************************************************************
+
+void GetgroupCommand::help(){
+       try {
+               cout << "The get.group command can only be executed after a successful read.otu command." << "\n";
+               //cout << "The get.group command outputs a .bootGroups file to you can use in addition to the tree file generated by the bootstrap.shared command to run the concensus command." << "\n";
+               cout << "You may not use any parameters with the get.group command." << "\n";
+               cout << "The get.group command should be in the following format: " << "\n";
+               cout << "get.group()" << "\n";
+               cout << "Example get.group()." << "\n";
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the GetgroupCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
 
 //**********************************************************************************************************************
 
@@ -42,6 +76,9 @@ GetgroupCommand::~GetgroupCommand(){
 
 int GetgroupCommand::execute(){
        try {
+       
+               if (abort == true) { return 0; }
+       
                int num, inputData, count;
                count = 0;  
                string holdLabel, nextLabel, groupN, label;