2 * getcurrentcommand.cpp
5 * Created by westcott on 3/16/11.
6 * Copyright 2011 Schloss Lab. All rights reserved.
10 #include "getcurrentcommand.h"
13 //**********************************************************************************************************************
14 vector<string> GetCurrentCommand::getValidParameters(){
16 string Array[] = {"outputdir","inputdir","clear"};
17 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
21 m->errorOut(e, "GetCurrentCommand", "getValidParameters");
25 //**********************************************************************************************************************
26 GetCurrentCommand::GetCurrentCommand(){
28 abort = true; calledHelp = true;
31 m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
35 //**********************************************************************************************************************
36 vector<string> GetCurrentCommand::getRequiredParameters(){
38 vector<string> myArray;
42 m->errorOut(e, "GetCurrentCommand", "getRequiredParameters");
46 //**********************************************************************************************************************
47 vector<string> GetCurrentCommand::getRequiredFiles(){
49 vector<string> myArray;
53 m->errorOut(e, "GetCurrentCommand", "getRequiredFiles");
57 //**********************************************************************************************************************
58 GetCurrentCommand::GetCurrentCommand(string option) {
60 abort = false; calledHelp = false;
62 //allow user to run help
63 if(option == "help") { help(); abort = true; calledHelp = true; }
66 //valid paramters for this command
67 string Array[] = {"outputdir","inputdir","clear"};
68 vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
70 OptionParser parser(option);
71 map<string,string> parameters = parser.getParameters();
73 ValidParameters validParameter;
74 //check to make sure all parameters are valid for command
75 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
76 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
79 clearTypes = validParameter.validFile(parameters, "clear", false);
80 if (clearTypes == "not found") { clearTypes = ""; }
81 else { m->splitAtDash(clearTypes, types); }
86 m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
90 //**********************************************************************************************************************
92 void GetCurrentCommand::help(){
94 m->mothurOut("The get.current command outputs the current files saved by mothur.\n");
95 m->mothurOut("The get.current command has one parameter: clear.\n");
96 m->mothurOut("The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n");
97 m->mothurOut("The get.current command should be in the following format: \n");
98 m->mothurOut("get.current() or get.current(clear=fasta-name-accnos)\n");
101 catch(exception& e) {
102 m->errorOut(e, "GetCurrentCommand", "help");
107 //**********************************************************************************************************************
108 GetCurrentCommand::~GetCurrentCommand(){}
109 //**********************************************************************************************************************
111 int GetCurrentCommand::execute(){
114 if (abort == true) { if (calledHelp) { return 0; } return 2; }
116 //user wants to clear a type
117 if (types.size() != 0) {
118 for (int i = 0; i < types.size(); i++) {
120 if (m->control_pressed) { break; }
122 //look for file types
123 if (types[i] == "fasta") {
125 }else if (types[i] == "qfile") {
127 }else if (types[i] == "phylip") {
128 m->setPhylipFile("");
129 }else if (types[i] == "column") {
130 m->setColumnFile("");
131 }else if (types[i] == "list") {
133 }else if (types[i] == "rabund") {
134 m->setRabundFile("");
135 }else if (types[i] == "sabund") {
136 m->setSabundFile("");
137 }else if (types[i] == "name") {
139 }else if (types[i] == "group") {
141 }else if (types[i] == "order") {
143 }else if (types[i] == "ordergroup") {
144 m->setOrderGroupFile("");
145 }else if (types[i] == "tree") {
147 }else if (types[i] == "shared") {
148 m->setSharedFile("");
149 }else if (types[i] == "relabund") {
150 m->setRelAbundFile("");
151 }else if (types[i] == "design") {
152 m->setDesignFile("");
153 }else if (types[i] == "sff") {
155 }else if (types[i] == "oligos") {
156 m->setOligosFile("");
157 }else if (types[i] == "accnos") {
158 m->setAccnosFile("");
159 }else if (types[i] == "taxonomy") {
160 m->setTaxonomyFile("");
161 }else if (types[i] == "all") {
162 m->clearCurrentFiles();
164 m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
169 m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
170 m->printCurrentFiles();
175 catch(exception& e) {
176 m->errorOut(e, "GetCurrentCommand", "execute");
181 //**********************************************************************************************************************