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() {
18 initialSharedRarefact();
20 initialSharedSummary();
30 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
34 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
39 /********************************************************************/
41 ValidCalculators::~ValidCalculators() {}
43 /********************************************************************/
45 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
47 //are you looking for a calculator for a single parameter
48 if (parameter == "single") {
50 if ((single.find(calculator)) != (single.end())) {
53 cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
54 for (it = single.begin(); it != single.end(); it++) {
55 cout << it->first << ", ";
59 //are you looking for a calculator for a shared parameter
60 }else if (parameter == "shared") {
62 if ((shared.find(calculator)) != (shared.end())) {
65 cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ";
66 for (it = shared.begin(); it != shared.end(); it++) {
67 cout << it->first << ", ";
71 //are you looking for a calculator for a rarefaction parameter
72 }else if (parameter == "rarefaction") {
74 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
77 cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
78 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
79 cout << it->first << ", ";
83 //are you looking for a calculator for a summary parameter
84 }else if (parameter == "summary") {
86 if ((summary.find(calculator)) != (summary.end())) {
89 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
90 for (it = summary.begin(); it != summary.end(); it++) {
91 cout << it->first << ", ";
95 //are you looking for a calculator for a sharedsummary parameter
96 }else if (parameter == "sharedsummary") {
98 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
101 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
102 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
103 cout << it->first << ", ";
107 }else if (parameter == "sharedrarefaction") {
109 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
112 cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
113 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
114 cout << it->first << ", ";
118 }else if (parameter == "vennsingle") {
120 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
123 cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
124 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
125 cout << it->first << ", ";
129 }else if (parameter == "vennshared") {
131 if ((vennshared.find(calculator)) != (vennshared.end())) {
134 cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
135 for (it = vennshared.begin(); it != vennshared.end(); it++) {
136 cout << it->first << ", ";
140 }else if (parameter == "treegroup") {
142 if ((treegroup.find(calculator)) != (treegroup.end())) {
145 cout << calculator << " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ";
146 for (it = treegroup.begin(); it != treegroup.end(); it++) {
147 cout << it->first << ", ";
151 }else if (parameter == "matrix") {
153 if ((matrix.find(calculator)) != (matrix.end())) {
156 cout << calculator << " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ";
157 for (it = matrix.begin(); it != matrix.end(); it++) {
158 cout << it->first << ", ";
162 }else if (parameter == "heat") {
164 if ((heat.find(calculator)) != (heat.end())) {
167 cout << calculator << " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ";
168 for (it = heat.begin(); it != heat.end(); it++) {
169 cout << it->first << ", ";
173 }else if (parameter == "boot") {
175 if ((boot.find(calculator)) != (boot.end())) {
178 cout << calculator << " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ";
179 for (it = boot.begin(); it != boot.end(); it++) {
180 cout << it->first << ", ";
184 }else if (parameter == "distance") {
186 if ((distance.find(calculator)) != (distance.end())) {
189 cout << calculator << " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ";
190 for (it = distance.begin(); it != distance.end(); it++) {
191 cout << it->first << ", ";
195 //not a valid parameter
196 }else { return false; }
199 catch(exception& e) {
200 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
204 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
209 /********************************************************************/
210 void ValidCalculators::initialSingle() {
212 single["sobs"] = "sobs";
213 single["chao"] = "chao";
214 single["ace"] = "ace";
215 single["jack"] = "jack";
216 single["shannon"] = "shannon";
217 single["npshannon"] = "npshannon";
218 single["simpson"] = "simpson";
219 single["bergerparker"] = "bergerparker";
220 single["bootstrap"] = "bootstrap";
221 single["geometric"] = "geometric";
222 single["logseries"] = "logseries";
223 single["qstat"] = "qstat";
224 single["bstick"] = "bstick";
225 single["goodscoverage"] = "goodscoverage";
226 single["nseqs"] = "nseqs";
227 single["coverage"] = "coverage";
228 single["efron"] = "efron";
229 single["boneh"] = "boneh";
230 single["solow"] = "solow";
231 single["shen"] = "shen";
232 single["default"] = "default";
234 catch(exception& e) {
235 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
239 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
244 /********************************************************************/
245 void ValidCalculators::initialShared() {
247 shared["sharedsobs"] = "sharedsobs";
248 shared["sharedchao"] = "sharedchao";
249 shared["sharedace"] = "sharedace";
250 shared["jabund"] = "jabund";
251 shared["sorabund"] = "sorabund";
252 shared["jclass"] = "jclass";
253 shared["sorclass"] = "sorclass";
254 shared["jest"] = "jest";
255 shared["sorest"] = "sorest";
256 shared["thetayc"] = "thetayc";
257 shared["thetan"] = "thetan";
258 shared["kstest"] = "kstest";
259 shared["whittaker"] = "whittaker";
260 shared["sharednseqs"] = "sharednseqs";
261 shared["ochiai"] = "ochiai";
262 shared["anderberg"] = "anderberg";
263 shared["kulczynski"] = "kulczynski";
264 shared["kulczynskicody"] = "kulczynskicody";
265 shared["lennon"] = "lennon";
266 shared["morisitahorn"] = "morisitahorn";
267 shared["braycurtis"] = "braycurtis";
268 shared["default"] = "default";
270 catch(exception& e) {
271 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
275 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
280 /********************************************************************/
281 void ValidCalculators::initialRarefaction() {
283 rarefaction["sobs"] = "sobs";
284 rarefaction["chao"] = "chao";
285 rarefaction["ace"] = "ace";
286 rarefaction["jack"] = "jack";
287 rarefaction["shannon"] = "shannon";
288 rarefaction["npshannon"] = "npshannon";
289 rarefaction["simpson"] = "simpson";
290 rarefaction["bootstrap"] = "bootstrap";
291 rarefaction["nseqs"] = "nseqs";
292 rarefaction["coverage"] = "coverage";
293 rarefaction["default"] = "default";
295 catch(exception& e) {
296 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
300 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
305 /********************************************************************/
307 void ValidCalculators::initialSummary() {
309 summary["sobs"] = "sobs";
310 summary["chao"] = "chao";
311 summary["ace"] = "ace";
312 summary["jack"] = "jack";
313 summary["shannon"] = "shannon";
314 summary["npshannon"] = "npshannon";
315 summary["simpson"] = "simpson";
316 summary["bergerparker"] = "bergerparker";
317 summary["geometric"] = "geometric";
318 summary["bootstrap"] = "bootstrap";
319 summary["logseries"] = "logseries";
320 summary["qstat"] = "qstat";
321 summary["bstick"] = "bstick";
322 summary["nseqs"] = "nseqs";
323 summary["goodscoverage"]= "goodscoverage";
324 summary["coverage"] = "coverage";
325 summary["efron"] = "efron";
326 summary["boneh"] = "boneh";
327 summary["solow"] = "solow";
328 summary["shen"] = "shen";
329 summary["default"] = "default";
331 catch(exception& e) {
332 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
336 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
341 /********************************************************************/
342 void ValidCalculators::initialSharedSummary() {
344 sharedsummary["sharedsobs"] = "sharedsobs";
345 sharedsummary["sharedchao"] = "sharedchao";
346 sharedsummary["sharedace"] = "sharedace";
347 sharedsummary["jabund"] = "jabund";
348 sharedsummary["sorabund"] = "sorabund";
349 sharedsummary["jclass"] = "jclass";
350 sharedsummary["sorclass"] = "sorclass";
351 sharedsummary["jest"] = "jest";
352 sharedsummary["sorest"] = "sorest";
353 sharedsummary["thetayc"] = "thetayc";
354 sharedsummary["thetan"] = "thetan";
355 sharedsummary["kstest"] = "kstest";
356 sharedsummary["whittaker"] = "whittaker";
357 sharedsummary["sharednseqs"] = "sharednseqs";
358 sharedsummary["ochiai"] = "ochiai";
359 sharedsummary["anderberg"] = "anderberg";
360 sharedsummary["kulczynski"] = "kulczynski";
361 sharedsummary["kulczynskicody"] = "kulczynskicody";
362 sharedsummary["lennon"] = "lennon";
363 sharedsummary["morisitahorn"] = "morisitahorn";
364 sharedsummary["braycurtis"] = "braycurtis";
365 sharedsummary["default"] = "default";
367 catch(exception& e) {
368 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
372 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
378 /********************************************************************/
380 void ValidCalculators::initialSharedRarefact() {
382 sharedrarefaction["sharedobserved"] = "sharedobserved";
383 sharedrarefaction["sharednseqs"] = "sharednseqs";
384 sharedrarefaction["default"] = "default";
386 catch(exception& e) {
387 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
391 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
397 /********************************************************************/
398 void ValidCalculators::initialVennSingle() {
400 vennsingle["sobs"] = "sobs";
401 vennsingle["chao"] = "chao";
402 vennsingle["ace"] = "ace";
403 vennsingle["jack"] = "jack";
404 vennsingle["default"] = "default";
406 catch(exception& e) {
407 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
411 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
416 /********************************************************************/
417 void ValidCalculators::initialVennShared() {
419 vennshared["sharedsobs"] = "sharedsobs";
420 vennshared["sharedchao"] = "sharedchao";
421 vennshared["sharedace"] = "sharedace";
422 vennshared["default"] = "default";
424 catch(exception& e) {
425 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
429 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
434 /********************************************************************/
435 void ValidCalculators::initialTreeGroups() {
437 treegroup["jabund"] = "jabund";
438 treegroup["sorabund"] = "sorabund";
439 treegroup["jclass"] = "jclass";
440 treegroup["sorclass"] = "sorclass";
441 treegroup["jest"] = "jest";
442 treegroup["sorest"] = "sorest";
443 treegroup["thetayc"] = "thetayc";
444 treegroup["thetan"] = "thetan";
445 treegroup["morisitahorn"] = "morisitahorn";
446 treegroup["braycurtis"] = "braycurtis";
448 catch(exception& e) {
449 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
453 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
457 /********************************************************************/
458 void ValidCalculators::initialHeat() {
460 heat["jabund"] = "jabund";
461 heat["sorabund"] = "sorabund";
462 heat["jclass"] = "jclass";
463 heat["sorclass"] = "sorclass";
464 heat["jest"] = "jest";
465 heat["sorest"] = "sorest";
466 heat["thetayc"] = "thetayc";
467 heat["thetan"] = "thetan";
468 heat["morisitahorn"] = "morisitahorn";
469 heat["braycurtis"] = "braycurtis";
471 catch(exception& e) {
472 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
476 cout << "An unknown error has occurred in the ValidCalculator class function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
481 /********************************************************************/
482 void ValidCalculators::initialMatrix() {
484 matrix["jabund"] = "jabund";
485 matrix["sorabund"] = "sorabund";
486 matrix["jclass"] = "jclass";
487 matrix["sorclass"] = "sorclass";
488 matrix["jest"] = "jest";
489 matrix["sorest"] = "sorest";
490 matrix["thetayc"] = "thetayc";
491 matrix["thetan"] = "thetan";
492 matrix["morisitahorn"] = "morisitahorn";
493 matrix["braycurtis"] = "braycurtis";
495 catch(exception& e) {
496 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
500 cout << "An unknown error has occurred in the ValidCalculator class function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
505 /********************************************************************/
506 void ValidCalculators::initialBoot() {
508 boot["jabund"] = "jabund";
509 boot["sorabund"] = "sorabund";
510 boot["jclass"] = "jclass";
511 boot["sorclass"] = "orclass";
512 boot["jest"] = "jest";
513 boot["sorest"] = "sorest";
514 boot["thetayc"] = "thetayc";
515 boot["thetan"] = "thetan";
516 boot["morisitahorn"] = "morisitahorn";
517 boot["braycurtis"] = "braycurtis";
519 catch(exception& e) {
520 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
524 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
528 /********************************************************************/
529 void ValidCalculators::initialDistance() {
531 distance["nogaps"] = "nogaps";
532 distance["eachgap"] = "eachgap";
533 distance["onegap"] = "onegap";
535 catch(exception& e) {
536 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
540 cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
545 /********************************************************************/
546 void ValidCalculators::printCalc(string parameter, ostream& out) {
548 out << "The available estimators for calc are ";
549 //are you looking for a calculator for a single parameter
550 if (parameter == "single") {
551 for (it = single.begin(); it != single.end(); it++) {
552 out << it->first << ", ";
554 //are you looking for a calculator for a shared parameter
555 }else if (parameter == "shared") {
556 for (it = shared.begin(); it != shared.end(); it++) {
557 out << it->first << ", ";
559 //are you looking for a calculator for a rarefaction parameter
560 }else if (parameter == "rarefaction") {
561 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
562 out << it->first << ", ";
564 //are you looking for a calculator for a summary parameter
565 }else if (parameter == "summary") {
566 for (it = summary.begin(); it != summary.end(); it++) {
567 out << it->first << ", ";
569 //are you looking for a calculator for a sharedsummary parameter
570 }else if (parameter == "sharedsummary") {
571 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
572 out << it->first << ", ";
574 }else if (parameter == "sharedrarefaction") {
575 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
576 out << it->first << ", ";
578 }else if (parameter == "vennsingle") {
579 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
580 out << it->first << ", ";
582 }else if (parameter == "vennshared") {
583 for (it = vennshared.begin(); it != vennshared.end(); it++) {
584 out << it->first << ", ";
586 }else if (parameter == "treegroup") {
587 for (it = treegroup.begin(); it != treegroup.end(); it++) {
588 out << it->first << ", ";
590 }else if (parameter == "matrix") {
591 for (it = matrix.begin(); it != matrix.end(); it++) {
592 out << it->first << ", ";
594 }else if (parameter == "boot") {
595 for (it = boot.begin(); it != boot.end(); it++) {
596 out << it->first << ", ";
598 }else if (parameter == "distance") {
599 for (it = distance.begin(); it != distance.end(); it++) {
600 out << it->first << ", ";
606 catch(exception& e) {
607 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
611 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
616 /********************************************************************/