5 * Created by Thomas Ryabin on 2/2/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "getgroupcommand.h"
12 //**********************************************************************************************************************
13 GetgroupCommand::GetgroupCommand(string option){
15 globaldata = GlobalData::getInstance();
18 //allow user to run help
19 if(option == "help") { help(); abort = true; }
22 if (option != "") { cout << "There are no valid parameters for the get.group command." << endl; abort = true; }
24 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; }
28 sharedfile = globaldata->getSharedFile();
29 openInputFile(sharedfile, in);
32 outputFile = getRootName(sharedfile) + "bootGroups";
33 openOutputFile(outputFile, out);
39 cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
43 cout << "An unknown error has occurred in the GetgroupCommand class function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
48 //**********************************************************************************************************************
50 void GetgroupCommand::help(){
52 cout << "The get.group command can only be executed after a successful read.otu command." << "\n";
53 //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";
54 cout << "You may not use any parameters with the get.group command." << "\n";
55 cout << "The get.group command should be in the following format: " << "\n";
56 cout << "get.group()" << "\n";
57 cout << "Example get.group()." << "\n";
61 cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
65 cout << "An unknown error has occurred in the GetgroupCommand class function help. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
70 //**********************************************************************************************************************
72 GetgroupCommand::~GetgroupCommand(){
75 //**********************************************************************************************************************
77 int GetgroupCommand::execute(){
80 if (abort == true) { return 0; }
82 int num, inputData, count;
84 string holdLabel, nextLabel, groupN, label;
86 //read in first row since you know there is at least 1 group.
87 in >> label >> groupN >> num;
91 cout << groupN << endl;
92 out << groupN << '\t' << groupN << endl;
95 for(int i=0;i<num;i++){
99 if (in.eof() != true) { in >> nextLabel; }
101 //read the rest of the groups info in
102 while ((nextLabel == holdLabel) && (in.eof() != true)) {
107 cout << groupN << endl;
108 out << groupN << '\t' << groupN << endl;
111 for(int i=0;i<num;i++){
115 if (in.eof() != true) { in >> nextLabel; }
122 catch(exception& e) {
123 cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
127 cout << "An unknown error has occurred in the GetgroupCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";