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; }
64 vector<string> myArray = setParameters();
66 OptionParser parser(option);
67 map<string,string> parameters = parser.getParameters();
69 ValidParameters validParameter;
70 //check to make sure all parameters are valid for command
71 for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) {
72 if (validParameter.isValidParameter(it->first, myArray, it->second) != true) { abort = true; }
75 clearTypes = validParameter.validFile(parameters, "clear", false);
76 if (clearTypes == "not found") { clearTypes = ""; }
77 else { m->splitAtDash(clearTypes, types); }
82 m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
86 //**********************************************************************************************************************
88 int GetCurrentCommand::execute(){
91 if (abort == true) { if (calledHelp) { return 0; } return 2; }
93 //user wants to clear a type
94 if (types.size() != 0) {
95 for (int i = 0; i < types.size(); i++) {
97 if (m->control_pressed) { break; }
100 if (types[i] == "fasta") {
102 }else if (types[i] == "qfile") {
104 }else if (types[i] == "phylip") {
105 m->setPhylipFile("");
106 }else if (types[i] == "column") {
107 m->setColumnFile("");
108 }else if (types[i] == "list") {
110 }else if (types[i] == "rabund") {
111 m->setRabundFile("");
112 }else if (types[i] == "sabund") {
113 m->setSabundFile("");
114 }else if (types[i] == "name") {
116 }else if (types[i] == "group") {
118 }else if (types[i] == "order") {
120 }else if (types[i] == "ordergroup") {
121 m->setOrderGroupFile("");
122 }else if (types[i] == "tree") {
124 }else if (types[i] == "shared") {
125 m->setSharedFile("");
126 }else if (types[i] == "relabund") {
127 m->setRelAbundFile("");
128 }else if (types[i] == "design") {
129 m->setDesignFile("");
130 }else if (types[i] == "sff") {
132 }else if (types[i] == "oligos") {
133 m->setOligosFile("");
134 }else if (types[i] == "accnos") {
135 m->setAccnosFile("");
136 }else if (types[i] == "taxonomy") {
137 m->setTaxonomyFile("");
138 }else if (types[i] == "flow") {
140 }else if (types[i] == "processors") {
141 m->setProcessors("1");
142 }else if (types[i] == "all") {
143 m->clearCurrentFiles();
145 m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
150 if (m->hasCurrentFiles()) {
151 m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
152 m->printCurrentFiles();
158 catch(exception& e) {
159 m->errorOut(e, "GetCurrentCommand", "execute");
164 //**********************************************************************************************************************