5 * Created by Sarah Westcott on 1/5/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "validparameter.h"
12 /***********************************************************************/
14 ValidParameters::ValidParameters() {
22 initialCollectsingle();
23 initialCollectshared();
24 initialRarefactsingle();
25 initialRarefactshared();
26 initialSummarysingle();
27 initialSummaryshared();
28 initialUnifracweighted();
29 initialUnifracunweighted();
33 cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
37 cout << "An unknown error has occurred in the ValidParameters class function ValidParameters. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
42 /***********************************************************************/
44 ValidParameters::~ValidParameters() {}
46 /***********************************************************************/
47 bool ValidParameters::isValidParameter(string parameter, string command) {
50 if (command == "read.dist") {
52 if ((readdist.find(parameter)) != (readdist.end())) {
55 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
56 for (it = readdist.begin(); it != readdist.end(); it++) {
57 cout << it->first << ", ";
61 }else if (command == "read.otu") {
63 if ((readotu.find(parameter)) != (readotu.end())) {
66 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
67 for (it = readotu.begin(); it != readotu.end(); it++) {
68 cout << it->first << ", ";
72 //are you looking for a calculator for a rarefaction parameter
73 }else if (command == "read.tree") {
75 if ((readtree.find(parameter)) != (readtree.end())) {
78 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
79 for (it = readtree.begin(); it != readtree.end(); it++) {
80 cout << it->first << ", ";
84 //are you looking for a calculator for a summary parameter
85 }else if (command == "cluster") {
87 if ((cluster.find(parameter)) != (cluster.end())) {
90 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
91 for (it = cluster.begin(); it != cluster.end(); it++) {
92 cout << it->first << ", ";
95 return false; } //are you looking for a calculator for a sharedsummary parameter
96 }else if (command == "deconvolute") {
98 if ((deconvolute.find(parameter)) != (deconvolute.end())) {
101 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
102 for (it = deconvolute.begin(); it != deconvolute.end(); it++) {
107 }else if (command == "parsimony") {
109 if ((parsimony.find(parameter)) != (parsimony.end())) {
112 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
113 for (it = parsimony.begin(); it != parsimony.end(); it++) {
114 cout << it->first << ", ";
118 }else if (command == "collect.single") {
120 if ((collectsingle.find(parameter)) != (collectsingle.end())) {
123 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
124 for (it = collectsingle.begin(); it != collectsingle.end(); it++) {
125 cout << it->first << ", ";
129 }else if (command == "collect.shared") {
131 if ((collectshared.find(parameter)) != (collectshared.end())) {
134 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
135 for (it = collectshared.begin(); it != collectshared.end(); it++) {
136 cout << it->first << ", ";
140 }else if (command == "rarefaction.single") {
142 if ((rarefactsingle.find(parameter)) != (rarefactsingle.end())) {
145 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
146 for (it = rarefactsingle.begin(); it != rarefactsingle.end(); it++) {
147 cout << it->first << ", ";
151 }else if (command == "rarefaction.shared") {
153 if ((rarefactshared.find(parameter)) != (rarefactshared.end())) {
156 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
157 for (it = rarefactshared.begin(); it != rarefactshared.end(); it++) {
158 cout << it->first << ", ";
162 }else if (command == "summary.single") {
164 if ((summarysingle.find(parameter)) != (summarysingle.end())) {
167 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
168 for (it = summarysingle.begin(); it != summarysingle.end(); it++) {
169 cout << it->first << ", ";
173 }else if (command == "summary.shared") {
175 if ((summaryshared.find(parameter)) != (summaryshared.end())) {
178 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
179 for (it = summaryshared.begin(); it != summaryshared.end(); it++) {
180 cout << it->first << ", ";
184 }else if (command == "unifrac.weighted") {
186 if ((unifracweighted.find(parameter)) != (unifracweighted.end())) {
189 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
190 for (it = unifracweighted.begin(); it != unifracweighted.end(); it++) {
191 cout << it->first << ", ";
195 }else if (command == "unifrac.unweighted") {
197 if ((unifracunweighted.find(parameter)) != (unifracunweighted.end())) {
200 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
201 for (it = unifracunweighted.begin(); it != unifracunweighted.end(); it++) {
202 cout << it->first << ", ";
206 }else if (command == "libshuff") {
208 if ((libshuff.find(parameter)) != (libshuff.end())) {
211 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
212 for (it = libshuff.begin(); it != libshuff.end(); it++) {
213 cout << it->first << ", ";
217 //not a valid paramter
218 }else if (command == "help") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
219 }else if (command == "quit") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
220 }else if (command == "get.group") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
221 }else if (command == "get.label") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
222 }else if (command == "get.line") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl; }
227 catch(exception& e) {
228 cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
232 cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
237 /***********************************************************************/
238 void ValidParameters::initialReaddist() {
239 readdist["phylip"] = "phylip";
240 readdist["column"] = "column";
241 readdist["name"] = "name";
242 readdist["group"] = "group";
243 readdist["cutoff"] = "cutoff";
244 readdist["precision"] = "precision";
246 /***********************************************************************/
247 void ValidParameters::initialReadotu() {
248 readotu["list"] = "list";
249 readotu["rabund"] = "rabund";
250 readotu["sabund"] = "sabund";
251 readotu["shared"] = "shared";
252 readotu["group"] = "group";
253 readotu["order"] = "order";
254 readotu["label"] = "label";
255 readotu["line"] = "line";
257 /***********************************************************************/
258 void ValidParameters::initialReadtree() {
259 readtree["group"] = "group";
260 readtree["tree"] = "tree";
262 /***********************************************************************/
263 void ValidParameters::initialCluster() {
264 cluster["cutoff"] = "cutoff";
265 cluster["method"] = "method";
266 cluster["precision"] = "precision";
268 /***********************************************************************/
269 void ValidParameters::initialDeconvolute() {
270 deconvolute["fasta"] = "fasta";
272 /***********************************************************************/
273 void ValidParameters::initialParsimony() {
274 parsimony["iters"] = "iters";
275 parsimony["random"] = "random";
276 parsimony["groups"] = "groups";
278 /***********************************************************************/
279 void ValidParameters::initialCollectsingle() {
280 collectsingle["label"] = "label";
281 collectsingle["line"] = "line";
282 collectsingle["freq"] = "freq";
283 collectsingle["calc"] = "calc";
285 /***********************************************************************/
286 void ValidParameters::initialCollectshared() {
287 collectshared["label"] = "label";
288 collectshared["line"] = "line";
289 collectshared["freq"] = "freq";
290 collectshared["calc"] = "calc";
291 collectshared["jumble"] = "jumble";
293 /***********************************************************************/
294 void ValidParameters::initialRarefactsingle() {
295 rarefactsingle["label"] = "label";
296 rarefactsingle["line"] = "line";
297 rarefactsingle["freq"] = "freq";
298 rarefactsingle["calc"] = "calc";
299 rarefactsingle["iters"] = "iters";
301 /***********************************************************************/
302 void ValidParameters::initialRarefactshared() {
303 rarefactshared["label"] = "label";
304 rarefactshared["line"] = "line";
305 rarefactshared["jumble"] = "jumble";
306 rarefactshared["calc"] = "calc";
307 rarefactshared["iters"] = "iters";
309 /***********************************************************************/
310 void ValidParameters::initialSummarysingle() {
311 summarysingle["label"] = "label";
312 summarysingle["line"] = "line";
313 summarysingle["calc"] = "calc";
315 /***********************************************************************/
316 void ValidParameters::initialSummaryshared() {
317 summaryshared["label"] = "label";
318 summaryshared["line"] = "line";
319 summaryshared["calc"] = "calc";
320 summaryshared["jumble"] = "jumble";
323 /***********************************************************************/
324 void ValidParameters::initialUnifracweighted() {
325 unifracweighted["iters"] = "iters";
326 unifracweighted["groups"] = "groups";
328 /***********************************************************************/
329 void ValidParameters::initialUnifracunweighted() {
330 unifracunweighted["iters"] = "iters";
331 unifracunweighted["groups"] = "groups";
333 /***********************************************************************/
334 void ValidParameters::initialLibshuff() {
335 libshuff["cutoff"] = "cutoff";
336 libshuff["iters"] = "iters";
337 libshuff["groups"] = "groups";
338 libshuff["step"] = "step";
339 libshuff["form"] = "form";
341 /***********************************************************************/