2 * getcurrentcommand.cpp
5 * Created by westcott on 3/16/11.
6 * Copyright 2011 Schloss Lab. All rights reserved.
10 #include "getcurrentcommand.h"
12 //**********************************************************************************************************************
13 vector<string> GetCurrentCommand::setParameters(){
15 CommandParameter pclear("clear", "String", "", "", "", "", "","",false,false); parameters.push_back(pclear);
16 CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
17 CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
19 vector<string> myArray;
20 for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
24 m->errorOut(e, "GetCurrentCommand", "setParameters");
28 //**********************************************************************************************************************
29 string GetCurrentCommand::getHelpString(){
31 string helpString = "";
32 helpString += "The get.current command outputs the current files saved by mothur.\n";
33 helpString += "The get.current command has one parameter: clear.\n";
34 helpString += "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";
35 helpString += "The get.current command should be in the following format: \n";
36 helpString += "get.current() or get.current(clear=fasta-name-accnos)\n";
40 m->errorOut(e, "GetCurrentCommand", "getHelpString");
44 //**********************************************************************************************************************
45 GetCurrentCommand::GetCurrentCommand(){
47 abort = true; calledHelp = true;
51 m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
55 //**********************************************************************************************************************
56 GetCurrentCommand::GetCurrentCommand(string option) {
58 abort = false; calledHelp = false;
60 //allow user to run help
61 if(option == "help") { help(); abort = true; calledHelp = true; }
62 else if(option == "citation") { citation(); abort = true; calledHelp = true;}
65 vector<string> myArray = setParameters();
67 OptionParser parser(option);
68 map<string,string> parameters = parser.getParameters();
70 ValidParameters validParameter;
71 //check to make sure all parameters are valid for command
72 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
73 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
76 clearTypes = validParameter.validFile(parameters, "clear", false);
77 if (clearTypes == "not found") { clearTypes = ""; }
78 else { m->splitAtDash(clearTypes, types); }
83 m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
87 //**********************************************************************************************************************
89 int GetCurrentCommand::execute(){
92 if (abort == true) { if (calledHelp) { return 0; } return 2; }
94 //user wants to clear a type
95 if (types.size() != 0) {
96 for (int i = 0; i < types.size(); i++) {
98 if (m->control_pressed) { break; }
100 //look for file types
101 if (types[i] == "fasta") {
103 }else if (types[i] == "qfile") {
105 }else if (types[i] == "phylip") {
106 m->setPhylipFile("");
107 }else if (types[i] == "column") {
108 m->setColumnFile("");
109 }else if (types[i] == "list") {
111 }else if (types[i] == "rabund") {
112 m->setRabundFile("");
113 }else if (types[i] == "sabund") {
114 m->setSabundFile("");
115 }else if (types[i] == "name") {
117 }else if (types[i] == "group") {
119 }else if (types[i] == "order") {
121 }else if (types[i] == "ordergroup") {
122 m->setOrderGroupFile("");
123 }else if (types[i] == "tree") {
125 }else if (types[i] == "shared") {
126 m->setSharedFile("");
127 }else if (types[i] == "relabund") {
128 m->setRelAbundFile("");
129 }else if (types[i] == "design") {
130 m->setDesignFile("");
131 }else if (types[i] == "sff") {
133 }else if (types[i] == "oligos") {
134 m->setOligosFile("");
135 }else if (types[i] == "accnos") {
136 m->setAccnosFile("");
137 }else if (types[i] == "taxonomy") {
138 m->setTaxonomyFile("");
139 }else if (types[i] == "flow") {
141 }else if (types[i] == "biom") {
143 }else if (types[i] == "count") {
144 m->setCountTableFile("");
145 }else if (types[i] == "summary") {
146 m->setSummaryFile("");
147 }else if (types[i] == "processors") {
148 m->setProcessors("1");
149 }else if (types[i] == "all") {
150 m->clearCurrentFiles();
152 m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
157 if (m->hasCurrentFiles()) {
158 m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
159 m->printCurrentFiles();
165 catch(exception& e) {
166 m->errorOut(e, "GetCurrentCommand", "execute");
171 //**********************************************************************************************************************