5 * Created by Thomas Ryabin on 1/30/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "getlabelcommand.h"
12 //**********************************************************************************************************************
13 vector<string> GetlabelCommand::getValidParameters(){
15 string Array[] = {"outputdir","inputdir"};
16 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
20 m->errorOut(e, "GetlabelCommand", "getValidParameters");
24 //**********************************************************************************************************************
25 vector<string> GetlabelCommand::getRequiredParameters(){
27 vector<string> myArray;
31 m->errorOut(e, "GetlabelCommand", "getRequiredParameters");
35 //**********************************************************************************************************************
36 vector<string> GetlabelCommand::getRequiredFiles(){
38 string Array[] = {"list","rabund","sabund", "or"};
39 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
43 m->errorOut(e, "GetlabelCommand", "getRequiredFiles");
47 //**********************************************************************************************************************
49 GetlabelCommand::GetlabelCommand(string option) {
51 globaldata = GlobalData::getInstance();
54 //allow user to run help
55 if(option == "help") { help(); abort = true; }
58 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; }
63 m->errorOut(e, "GetlabelCommand", "GetlabelCommand");
67 //**********************************************************************************************************************
69 void GetlabelCommand::help(){
71 m->mothurOut("The get.label command can only be executed after a successful read.otu command.\n");
72 m->mothurOut("You may not use any parameters with the get.label command.\n");
73 m->mothurOut("The get.label command should be in the following format: \n");
74 m->mothurOut("get.label()\n");
75 m->mothurOut("Example get.label().\n");
78 m->errorOut(e, "GetlabelCommand", "help");
83 //**********************************************************************************************************************
85 GetlabelCommand::~GetlabelCommand(){
88 //**********************************************************************************************************************
90 int GetlabelCommand::execute(){
93 if (abort == true) { return 0; }
95 filename = globaldata->inputFileName;
97 m->openInputFile(filename, in);
103 if (m->control_pressed) { in.close(); return 0; }
108 m->mothurOut(label); m->mothurOutEndLine();
119 catch(exception& e) {
120 m->errorOut(e, "GetlabelCommand", "execute");