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 != "") { mothurOut("There are no valid parameters for the get.group command."); mothurOutEndLine(); abort = true; }
24 if ((globaldata->getSharedFile() == "")) { mothurOut("You must use the read.otu command to read a groupfile or a sharedfile before you can use the get.group command."); mothurOutEndLine(); abort = true; }
28 sharedfile = globaldata->getSharedFile();
29 openInputFile(sharedfile, in);
32 outputFile = getRootName(sharedfile) + "bootGroups";
33 openOutputFile(outputFile, out);
39 errorOut(e, "GetgroupCommand", "GetgroupCommand");
43 //**********************************************************************************************************************
45 void GetgroupCommand::help(){
47 mothurOut("The get.group command can only be executed after a successful read.otu command.\n");
48 //mothurOut("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 consensus command.\n");
49 mothurOut("You may not use any parameters with the get.group command.\n");
50 mothurOut("The get.group command should be in the following format: \n");
51 mothurOut("get.group()\n");
52 mothurOut("Example get.group().\n");
56 errorOut(e, "GetgroupCommand", "help");
61 //**********************************************************************************************************************
63 GetgroupCommand::~GetgroupCommand(){
66 //**********************************************************************************************************************
68 int GetgroupCommand::execute(){
71 if (abort == true) { return 0; }
73 int num, inputData, count;
75 string holdLabel, nextLabel, groupN, label;
77 //read in first row since you know there is at least 1 group.
78 in >> label >> groupN >> num;
82 mothurOut(groupN); mothurOutEndLine();
83 out << groupN << '\t' << groupN << endl;
86 for(int i=0;i<num;i++){
90 if (in.eof() != true) { in >> nextLabel; }
92 //read the rest of the groups info in
93 while ((nextLabel == holdLabel) && (in.eof() != true)) {
98 mothurOut(groupN); mothurOutEndLine();
99 out << groupN << '\t' << groupN << endl;
102 for(int i=0;i<num;i++){
106 if (in.eof() != true) { in >> nextLabel; }
114 catch(exception& e) {
115 errorOut(e, "GetgroupCommand", "execute");