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 }else if (command == "heatmap") {
219 if ((heatmap.find(parameter)) != (heatmap.end())) {
222 cout << parameter << " is not a valid parameter for the " + command + " command. Valid parameters are ";
223 for (it = heatmap.begin(); it != heatmap.end(); it++) {
224 cout << it->first << ", ";
229 //not a valid paramter
230 }else if (command == "help") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
231 }else if (command == "quit") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
232 }else if (command == "get.group") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
233 }else if (command == "get.label") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl;
234 }else if (command == "get.line") { cout << parameter << " is not a valid parameter for the " + command + " command. There are no vaild parameters." << endl; }
239 catch(exception& e) {
240 cout << "Standard Error: " << e.what() << " has occurred in the ValidParameters class Function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
244 cout << "An unknown error has occurred in the ValidParameters class function isValidParameter. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
249 /***********************************************************************/
250 void ValidParameters::initialReaddist() {
251 readdist["phylip"] = "phylip";
252 readdist["column"] = "column";
253 readdist["name"] = "name";
254 readdist["group"] = "group";
255 readdist["cutoff"] = "cutoff";
256 readdist["precision"] = "precision";
258 /***********************************************************************/
259 void ValidParameters::initialReadotu() {
260 readotu["list"] = "list";
261 readotu["rabund"] = "rabund";
262 readotu["sabund"] = "sabund";
263 readotu["shared"] = "shared";
264 readotu["group"] = "group";
265 readotu["order"] = "order";
266 readotu["label"] = "label";
267 readotu["line"] = "line";
269 /***********************************************************************/
270 void ValidParameters::initialReadtree() {
271 readtree["group"] = "group";
272 readtree["tree"] = "tree";
274 /***********************************************************************/
275 void ValidParameters::initialCluster() {
276 cluster["cutoff"] = "cutoff";
277 cluster["method"] = "method";
278 cluster["precision"] = "precision";
280 /***********************************************************************/
281 void ValidParameters::initialDeconvolute() {
282 deconvolute["fasta"] = "fasta";
284 /***********************************************************************/
285 void ValidParameters::initialParsimony() {
286 parsimony["iters"] = "iters";
287 parsimony["random"] = "random";
288 parsimony["groups"] = "groups";
290 /***********************************************************************/
291 void ValidParameters::initialCollectsingle() {
292 collectsingle["label"] = "label";
293 collectsingle["line"] = "line";
294 collectsingle["freq"] = "freq";
295 collectsingle["calc"] = "calc";
297 /***********************************************************************/
298 void ValidParameters::initialCollectshared() {
299 collectshared["label"] = "label";
300 collectshared["line"] = "line";
301 collectshared["freq"] = "freq";
302 collectshared["calc"] = "calc";
303 collectshared["jumble"] = "jumble";
305 /***********************************************************************/
306 void ValidParameters::initialRarefactsingle() {
307 rarefactsingle["label"] = "label";
308 rarefactsingle["line"] = "line";
309 rarefactsingle["freq"] = "freq";
310 rarefactsingle["calc"] = "calc";
311 rarefactsingle["iters"] = "iters";
313 /***********************************************************************/
314 void ValidParameters::initialRarefactshared() {
315 rarefactshared["label"] = "label";
316 rarefactshared["line"] = "line";
317 rarefactshared["jumble"] = "jumble";
318 rarefactshared["calc"] = "calc";
319 rarefactshared["iters"] = "iters";
321 /***********************************************************************/
322 void ValidParameters::initialSummarysingle() {
323 summarysingle["label"] = "label";
324 summarysingle["line"] = "line";
325 summarysingle["calc"] = "calc";
327 /***********************************************************************/
328 void ValidParameters::initialSummaryshared() {
329 summaryshared["label"] = "label";
330 summaryshared["line"] = "line";
331 summaryshared["calc"] = "calc";
332 summaryshared["jumble"] = "jumble";
335 /***********************************************************************/
336 void ValidParameters::initialUnifracweighted() {
337 unifracweighted["iters"] = "iters";
338 unifracweighted["groups"] = "groups";
340 /***********************************************************************/
341 void ValidParameters::initialUnifracunweighted() {
342 unifracunweighted["iters"] = "iters";
343 unifracunweighted["groups"] = "groups";
345 /***********************************************************************/
346 void ValidParameters::initialLibshuff() {
347 libshuff["cutoff"] = "cutoff";
348 libshuff["iters"] = "iters";
349 libshuff["groups"] = "groups";
350 libshuff["step"] = "step";
351 libshuff["form"] = "form";
353 /***********************************************************************/
354 void ValidParameters::initialHeatmap() {
355 heatmap["label"] = "label";
356 heatmap["line"] = "line";
359 /***********************************************************************/