5 * Created by Sarah Westcott on 1/5/09.
6 * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10 #include "validcalculator.h"
12 /********************************************************************/
13 ValidCalculators::ValidCalculators() {
15 m = MothurOut::getInstance();
20 initialSharedRarefact();
22 initialSharedSummary();
32 m->errorOut(e, "ValidCalculator", "ValidCalculator");
37 /********************************************************************/
39 ValidCalculators::~ValidCalculators() {}
41 /********************************************************************/
43 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
45 //are you looking for a calculator for a single parameter
46 if (parameter == "single") {
48 if ((single.find(calculator)) != (single.end())) {
51 m->mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
52 for (it = single.begin(); it != single.end(); it++) {
53 m->mothurOut(it->first + ", ");
55 m->mothurOutEndLine();
57 //are you looking for a calculator for a shared parameter
58 }else if (parameter == "shared") {
60 if ((shared.find(calculator)) != (shared.end())) {
63 m->mothurOut(calculator + " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ");
64 for (it = shared.begin(); it != shared.end(); it++) {
65 m->mothurOut(it->first + ", ");
67 m->mothurOutEndLine();
69 //are you looking for a calculator for a rarefaction parameter
70 }else if (parameter == "rarefaction") {
72 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
75 m->mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
76 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
77 m->mothurOut(it->first + ", ");
79 m->mothurOutEndLine();
81 //are you looking for a calculator for a summary parameter
82 }else if (parameter == "summary") {
84 if ((summary.find(calculator)) != (summary.end())) {
87 m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
88 for (it = summary.begin(); it != summary.end(); it++) {
89 m->mothurOut(it->first + ", ");
91 m->mothurOutEndLine();
93 //are you looking for a calculator for a sharedsummary parameter
94 }else if (parameter == "sharedsummary") {
96 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
99 m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
100 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
101 m->mothurOut(it->first + ", ");
103 m->mothurOutEndLine();
105 }else if (parameter == "sharedrarefaction") {
107 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
110 m->mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
111 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
112 m->mothurOut(it->first + ", ");
114 m->mothurOutEndLine();
116 }else if (parameter == "vennsingle") {
118 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
121 m->mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
122 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
123 m->mothurOut(it->first + ", ");
125 m->mothurOutEndLine();
127 }else if (parameter == "vennshared") {
129 if ((vennshared.find(calculator)) != (vennshared.end())) {
132 m->mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
133 for (it = vennshared.begin(); it != vennshared.end(); it++) {
134 m->mothurOut(it->first + ", ");
136 m->mothurOutEndLine();
138 }else if (parameter == "treegroup") {
140 if ((treegroup.find(calculator)) != (treegroup.end())) {
143 m->mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
144 for (it = treegroup.begin(); it != treegroup.end(); it++) {
145 m->mothurOut(it->first + ", ");
147 m->mothurOutEndLine();
149 }else if (parameter == "matrix") {
151 if ((matrix.find(calculator)) != (matrix.end())) {
154 m->mothurOut(calculator + " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
155 for (it = matrix.begin(); it != matrix.end(); it++) {
156 m->mothurOut(it->first + ", ");
158 m->mothurOutEndLine();
160 }else if (parameter == "heat") {
162 if ((heat.find(calculator)) != (heat.end())) {
165 m->mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
166 for (it = heat.begin(); it != heat.end(); it++) {
167 m->mothurOut(it->first + ", ");
169 m->mothurOutEndLine();
171 }else if (parameter == "boot") {
173 if ((boot.find(calculator)) != (boot.end())) {
176 m->mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
177 for (it = boot.begin(); it != boot.end(); it++) {
178 m->mothurOut(it->first + ", ");
180 m->mothurOutEndLine();
182 }else if (parameter == "distance") {
184 if ((distance.find(calculator)) != (distance.end())) {
187 m->mothurOut(calculator + " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
188 for (it = distance.begin(); it != distance.end(); it++) {
189 m->mothurOut(it->first + ", ");
191 m->mothurOutEndLine();
193 //not a valid parameter
194 }else { return false; }
197 catch(exception& e) {
198 m->errorOut(e, "ValidCalculator", "isValidCalculator");
203 /********************************************************************/
204 void ValidCalculators::initialSingle() {
206 single["sobs"] = "sobs";
207 single["chao"] = "chao";
208 single["ace"] = "ace";
209 single["jack"] = "jack";
210 single["shannon"] = "shannon";
211 single["npshannon"] = "npshannon";
212 single["simpson"] = "simpson";
213 single["bergerparker"] = "bergerparker";
214 single["bootstrap"] = "bootstrap";
215 single["geometric"] = "geometric";
216 single["logseries"] = "logseries";
217 single["qstat"] = "qstat";
218 single["bstick"] = "bstick";
219 single["goodscoverage"] = "goodscoverage";
220 single["nseqs"] = "nseqs";
221 single["coverage"] = "coverage";
222 single["efron"] = "efron";
223 single["boneh"] = "boneh";
224 single["solow"] = "solow";
225 single["shen"] = "shen";
226 single["default"] = "default";
228 catch(exception& e) {
229 m->errorOut(e, "ValidCalculator", "initialSingle");
234 /********************************************************************/
235 void ValidCalculators::initialShared() {
237 shared["sharedsobs"] = "sharedsobs";
238 shared["sharedchao"] = "sharedchao";
239 shared["sharedace"] = "sharedace";
240 shared["jabund"] = "jabund";
241 shared["sorabund"] = "sorabund";
242 shared["jclass"] = "jclass";
243 shared["sorclass"] = "sorclass";
244 shared["jest"] = "jest";
245 shared["sorest"] = "sorest";
246 shared["thetayc"] = "thetayc";
247 shared["thetan"] = "thetan";
248 shared["kstest"] = "kstest";
249 shared["whittaker"] = "whittaker";
250 shared["sharednseqs"] = "sharednseqs";
251 shared["ochiai"] = "ochiai";
252 shared["anderberg"] = "anderberg";
253 shared["kulczynski"] = "kulczynski";
254 shared["kulczynskicody"] = "kulczynskicody";
255 shared["lennon"] = "lennon";
256 shared["morisitahorn"] = "morisitahorn";
257 shared["braycurtis"] = "braycurtis";
258 shared["default"] = "default";
260 catch(exception& e) {
261 m->errorOut(e, "ValidCalculator", "initialShared");
266 /********************************************************************/
267 void ValidCalculators::initialRarefaction() {
269 rarefaction["sobs"] = "sobs";
270 rarefaction["chao"] = "chao";
271 rarefaction["ace"] = "ace";
272 rarefaction["jack"] = "jack";
273 rarefaction["shannon"] = "shannon";
274 rarefaction["npshannon"] = "npshannon";
275 rarefaction["simpson"] = "simpson";
276 rarefaction["bootstrap"] = "bootstrap";
277 rarefaction["nseqs"] = "nseqs";
278 rarefaction["coverage"] = "coverage";
279 rarefaction["default"] = "default";
281 catch(exception& e) {
282 m->errorOut(e, "ValidCalculator", "initialRarefaction");
287 /********************************************************************/
289 void ValidCalculators::initialSummary() {
291 summary["sobs"] = "sobs";
292 summary["chao"] = "chao";
293 summary["ace"] = "ace";
294 summary["jack"] = "jack";
295 summary["shannon"] = "shannon";
296 summary["npshannon"] = "npshannon";
297 summary["simpson"] = "simpson";
298 summary["bergerparker"] = "bergerparker";
299 summary["geometric"] = "geometric";
300 summary["bootstrap"] = "bootstrap";
301 summary["logseries"] = "logseries";
302 summary["qstat"] = "qstat";
303 summary["bstick"] = "bstick";
304 summary["nseqs"] = "nseqs";
305 summary["goodscoverage"]= "goodscoverage";
306 summary["coverage"] = "coverage";
307 summary["efron"] = "efron";
308 summary["boneh"] = "boneh";
309 summary["solow"] = "solow";
310 summary["shen"] = "shen";
311 summary["default"] = "default";
313 catch(exception& e) {
314 m->errorOut(e, "ValidCalculator", "initialSummary");
319 /********************************************************************/
320 void ValidCalculators::initialSharedSummary() {
322 sharedsummary["sharedsobs"] = "sharedsobs";
323 sharedsummary["sharedchao"] = "sharedchao";
324 sharedsummary["sharedace"] = "sharedace";
325 sharedsummary["jabund"] = "jabund";
326 sharedsummary["sorabund"] = "sorabund";
327 sharedsummary["jclass"] = "jclass";
328 sharedsummary["sorclass"] = "sorclass";
329 sharedsummary["jest"] = "jest";
330 sharedsummary["sorest"] = "sorest";
331 sharedsummary["thetayc"] = "thetayc";
332 sharedsummary["thetan"] = "thetan";
333 sharedsummary["kstest"] = "kstest";
334 sharedsummary["whittaker"] = "whittaker";
335 sharedsummary["sharednseqs"] = "sharednseqs";
336 sharedsummary["ochiai"] = "ochiai";
337 sharedsummary["anderberg"] = "anderberg";
338 sharedsummary["kulczynski"] = "kulczynski";
339 sharedsummary["kulczynskicody"] = "kulczynskicody";
340 sharedsummary["lennon"] = "lennon";
341 sharedsummary["morisitahorn"] = "morisitahorn";
342 sharedsummary["braycurtis"] = "braycurtis";
343 sharedsummary["default"] = "default";
345 catch(exception& e) {
346 m->errorOut(e, "ValidCalculator", "initialSharedSummary");
352 /********************************************************************/
354 void ValidCalculators::initialSharedRarefact() {
356 sharedrarefaction["sharedobserved"] = "sharedobserved";
357 sharedrarefaction["sharednseqs"] = "sharednseqs";
358 sharedrarefaction["default"] = "default";
360 catch(exception& e) {
361 m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
367 /********************************************************************/
368 void ValidCalculators::initialVennSingle() {
370 vennsingle["sobs"] = "sobs";
371 vennsingle["chao"] = "chao";
372 vennsingle["ace"] = "ace";
373 vennsingle["jack"] = "jack";
374 vennsingle["default"] = "default";
376 catch(exception& e) {
377 m->errorOut(e, "ValidCalculator", "initialVennSingle");
382 /********************************************************************/
383 void ValidCalculators::initialVennShared() {
385 vennshared["sharedsobs"] = "sharedsobs";
386 vennshared["sharedchao"] = "sharedchao";
387 vennshared["sharedace"] = "sharedace";
388 vennshared["default"] = "default";
390 catch(exception& e) {
391 m->errorOut(e, "ValidCalculator", "initialVennShared");
396 /********************************************************************/
397 void ValidCalculators::initialTreeGroups() {
399 treegroup["jabund"] = "jabund";
400 treegroup["sorabund"] = "sorabund";
401 treegroup["jclass"] = "jclass";
402 treegroup["sorclass"] = "sorclass";
403 treegroup["jest"] = "jest";
404 treegroup["sorest"] = "sorest";
405 treegroup["thetayc"] = "thetayc";
406 treegroup["thetan"] = "thetan";
407 treegroup["morisitahorn"] = "morisitahorn";
408 treegroup["braycurtis"] = "braycurtis";
410 catch(exception& e) {
411 m->errorOut(e, "ValidCalculator", "initialTreeGroups");
415 /********************************************************************/
416 void ValidCalculators::initialHeat() {
418 heat["jabund"] = "jabund";
419 heat["sorabund"] = "sorabund";
420 heat["jclass"] = "jclass";
421 heat["sorclass"] = "sorclass";
422 heat["jest"] = "jest";
423 heat["sorest"] = "sorest";
424 heat["thetayc"] = "thetayc";
425 heat["thetan"] = "thetan";
426 heat["morisitahorn"] = "morisitahorn";
427 heat["braycurtis"] = "braycurtis";
429 catch(exception& e) {
430 m->errorOut(e, "ValidCalculator", "initialHeat");
435 /********************************************************************/
436 void ValidCalculators::initialMatrix() {
438 matrix["jabund"] = "jabund";
439 matrix["sorabund"] = "sorabund";
440 matrix["jclass"] = "jclass";
441 matrix["sorclass"] = "sorclass";
442 matrix["jest"] = "jest";
443 matrix["sorest"] = "sorest";
444 matrix["thetayc"] = "thetayc";
445 matrix["thetan"] = "thetan";
446 matrix["morisitahorn"] = "morisitahorn";
447 matrix["braycurtis"] = "braycurtis";
449 catch(exception& e) {
450 m->errorOut(e, "ValidCalculator", "initialMatrix");
455 /********************************************************************/
456 void ValidCalculators::initialBoot() {
458 boot["jabund"] = "jabund";
459 boot["sorabund"] = "sorabund";
460 boot["jclass"] = "jclass";
461 boot["sorclass"] = "orclass";
462 boot["jest"] = "jest";
463 boot["sorest"] = "sorest";
464 boot["thetayc"] = "thetayc";
465 boot["thetan"] = "thetan";
466 boot["morisitahorn"] = "morisitahorn";
467 boot["braycurtis"] = "braycurtis";
469 catch(exception& e) {
470 m->errorOut(e, "ValidCalculator", "initialBoot");
474 /********************************************************************/
475 void ValidCalculators::initialDistance() {
477 distance["nogaps"] = "nogaps";
478 distance["eachgap"] = "eachgap";
479 distance["onegap"] = "onegap";
481 catch(exception& e) {
482 m->errorOut(e, "ValidCalculator", "initialDistance");
487 /********************************************************************/
488 void ValidCalculators::printCalc(string parameter, ostream& out) {
490 out << "The available estimators for calc are ";
491 //are you looking for a calculator for a single parameter
492 if (parameter == "single") {
493 for (it = single.begin(); it != single.end(); it++) {
494 out << it->first << ", ";
496 //are you looking for a calculator for a shared parameter
497 }else if (parameter == "shared") {
498 for (it = shared.begin(); it != shared.end(); it++) {
499 out << it->first << ", ";
501 //are you looking for a calculator for a rarefaction parameter
502 }else if (parameter == "rarefaction") {
503 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
504 out << it->first << ", ";
506 //are you looking for a calculator for a summary parameter
507 }else if (parameter == "summary") {
508 for (it = summary.begin(); it != summary.end(); it++) {
509 out << it->first << ", ";
511 //are you looking for a calculator for a sharedsummary parameter
512 }else if (parameter == "sharedsummary") {
513 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
514 out << it->first << ", ";
516 }else if (parameter == "sharedrarefaction") {
517 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
518 out << it->first << ", ";
520 }else if (parameter == "vennsingle") {
521 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
522 out << it->first << ", ";
524 }else if (parameter == "vennshared") {
525 for (it = vennshared.begin(); it != vennshared.end(); it++) {
526 out << it->first << ", ";
528 }else if (parameter == "treegroup") {
529 for (it = treegroup.begin(); it != treegroup.end(); it++) {
530 out << it->first << ", ";
532 }else if (parameter == "matrix") {
533 for (it = matrix.begin(); it != matrix.end(); it++) {
534 out << it->first << ", ";
536 }else if (parameter == "heat") {
537 for (it = heat.begin(); it != heat.end(); it++) {
538 out << it->first << ", ";
540 }else if (parameter == "boot") {
541 for (it = boot.begin(); it != boot.end(); it++) {
542 out << it->first << ", ";
544 }else if (parameter == "distance") {
545 for (it = distance.begin(); it != distance.end(); it++) {
546 out << it->first << ", ";
552 catch(exception& e) {
553 m->errorOut(e, "ValidCalculator", "printCalc");
557 /********************************************************************/