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();
29 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
33 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
38 /********************************************************************/
40 ValidCalculators::~ValidCalculators() {}
42 /********************************************************************/
44 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
46 //are you looking for a calculator for a single parameter
47 if (parameter == "single") {
49 if ((single.find(calculator)) != (single.end())) {
52 cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
53 for (it = single.begin(); it != single.end(); it++) {
54 cout << it->first << ", ";
58 //are you looking for a calculator for a shared parameter
59 }else if (parameter == "shared") {
61 if ((shared.find(calculator)) != (shared.end())) {
64 cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ";
65 for (it = shared.begin(); it != shared.end(); it++) {
66 cout << it->first << ", ";
70 //are you looking for a calculator for a rarefaction parameter
71 }else if (parameter == "rarefaction") {
73 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
76 cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
77 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
78 cout << it->first << ", ";
82 //are you looking for a calculator for a summary parameter
83 }else if (parameter == "summary") {
85 if ((summary.find(calculator)) != (summary.end())) {
88 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
89 for (it = summary.begin(); it != summary.end(); it++) {
90 cout << it->first << ", ";
94 //are you looking for a calculator for a sharedsummary parameter
95 }else if (parameter == "sharedsummary") {
97 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
100 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
101 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
102 cout << it->first << ", ";
106 }else if (parameter == "sharedrarefaction") {
108 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
111 cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
112 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
113 cout << it->first << ", ";
117 }else if (parameter == "vennsingle") {
119 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
122 cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
123 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
124 cout << it->first << ", ";
128 }else if (parameter == "vennshared") {
130 if ((vennshared.find(calculator)) != (vennshared.end())) {
133 cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
134 for (it = vennshared.begin(); it != vennshared.end(); it++) {
135 cout << it->first << ", ";
139 }else if (parameter == "treegroup") {
141 if ((treegroup.find(calculator)) != (treegroup.end())) {
144 cout << calculator << " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ";
145 for (it = treegroup.begin(); it != treegroup.end(); it++) {
146 cout << it->first << ", ";
150 }else if (parameter == "matrix") {
152 if ((matrix.find(calculator)) != (matrix.end())) {
155 cout << calculator << " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ";
156 for (it = matrix.begin(); it != matrix.end(); it++) {
157 cout << it->first << ", ";
161 }else if (parameter == "boot") {
163 if ((boot.find(calculator)) != (boot.end())) {
166 cout << calculator << " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ";
167 for (it = boot.begin(); it != boot.end(); it++) {
168 cout << it->first << ", ";
172 }else if (parameter == "distance") {
174 if ((distance.find(calculator)) != (distance.end())) {
177 cout << calculator << " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ";
178 for (it = distance.begin(); it != distance.end(); it++) {
179 cout << it->first << ", ";
183 //not a valid parameter
184 }else { return false; }
187 catch(exception& e) {
188 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
192 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
197 /********************************************************************/
198 void ValidCalculators::initialSingle() {
200 single["sobs"] = "sobs";
201 single["chao"] = "chao";
202 single["ace"] = "ace";
203 single["jack"] = "jack";
204 single["shannon"] = "shannon";
205 single["npshannon"] = "npshannon";
206 single["simpson"] = "simpson";
207 single["bergerparker"] = "bergerparker";
208 single["bootstrap"] = "bootstrap";
209 single["geometric"] = "geometric";
210 single["logseries"] = "logseries";
211 single["qstat"] = "qstat";
212 single["bstick"] = "bstick";
213 single["goodscoverage"] = "goodscoverage";
214 single["nseqs"] = "nseqs";
215 single["coverage"] = "coverage";
216 single["efron"] = "efron";
217 single["boneh"] = "boneh";
218 single["solow"] = "solow";
219 single["shen"] = "shen";
220 single["default"] = "default";
222 catch(exception& e) {
223 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
227 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
232 /********************************************************************/
233 void ValidCalculators::initialShared() {
235 shared["sharedsobs"] = "sharedsobs";
236 shared["sharedchao"] = "sharedchao";
237 shared["sharedace"] = "sharedace";
238 shared["jabund"] = "jabund";
239 shared["sorabund"] = "sorabund";
240 shared["jclass"] = "jclass";
241 shared["sorclass"] = "sorclass";
242 shared["jest"] = "jest";
243 shared["sorest"] = "sorest";
244 shared["thetayc"] = "thetayc";
245 shared["thetan"] = "thetan";
246 shared["kstest"] = "kstest";
247 shared["whittaker"] = "whittaker";
248 shared["sharednseqs"] = "sharednseqs";
249 shared["ochiai"] = "ochiai";
250 shared["anderberg"] = "anderberg";
251 shared["kulczynski"] = "kulczynski";
252 shared["kulczynskicody"] = "kulczynskicody";
253 shared["lennon"] = "lennon";
254 shared["morisitahorn"] = "morisitahorn";
255 shared["braycurtis"] = "braycurtis";
256 shared["default"] = "default";
258 catch(exception& e) {
259 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
263 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
268 /********************************************************************/
269 void ValidCalculators::initialRarefaction() {
271 rarefaction["sobs"] = "sobs";
272 rarefaction["chao"] = "chao";
273 rarefaction["ace"] = "ace";
274 rarefaction["jack"] = "jack";
275 rarefaction["shannon"] = "shannon";
276 rarefaction["npshannon"] = "npshannon";
277 rarefaction["simpson"] = "simpson";
278 rarefaction["bootstrap"] = "bootstrap";
279 rarefaction["nseqs"] = "nseqs";
280 rarefaction["coverage"] = "coverage";
281 rarefaction["default"] = "default";
283 catch(exception& e) {
284 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
288 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
293 /********************************************************************/
295 void ValidCalculators::initialSummary() {
297 summary["sobs"] = "sobs";
298 summary["chao"] = "chao";
299 summary["ace"] = "ace";
300 summary["jack"] = "jack";
301 summary["shannon"] = "shannon";
302 summary["npshannon"] = "npshannon";
303 summary["simpson"] = "simpson";
304 summary["bergerparker"] = "bergerparker";
305 summary["geometric"] = "geometric";
306 summary["bootstrap"] = "bootstrap";
307 summary["logseries"] = "logseries";
308 summary["qstat"] = "qstat";
309 summary["bstick"] = "bstick";
310 summary["nseqs"] = "nseqs";
311 summary["goodscoverage"]= "goodscoverage";
312 summary["coverage"] = "coverage";
313 summary["efron"] = "efron";
314 summary["boneh"] = "boneh";
315 summary["solow"] = "solow";
316 summary["shen"] = "shen";
317 summary["default"] = "default";
319 catch(exception& e) {
320 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
324 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
329 /********************************************************************/
330 void ValidCalculators::initialSharedSummary() {
332 sharedsummary["sharedsobs"] = "sharedsobs";
333 sharedsummary["sharedchao"] = "sharedchao";
334 sharedsummary["sharedace"] = "sharedace";
335 sharedsummary["jabund"] = "jabund";
336 sharedsummary["sorabund"] = "sorabund";
337 sharedsummary["jclass"] = "jclass";
338 sharedsummary["sorclass"] = "sorclass";
339 sharedsummary["jest"] = "jest";
340 sharedsummary["sorest"] = "sorest";
341 sharedsummary["thetayc"] = "thetayc";
342 sharedsummary["thetan"] = "thetan";
343 sharedsummary["kstest"] = "kstest";
344 sharedsummary["whittaker"] = "whittaker";
345 sharedsummary["sharednseqs"] = "sharednseqs";
346 sharedsummary["ochiai"] = "ochiai";
347 sharedsummary["anderberg"] = "anderberg";
348 sharedsummary["kulczynski"] = "kulczynski";
349 sharedsummary["kulczynskicody"] = "kulczynskicody";
350 sharedsummary["lennon"] = "lennon";
351 sharedsummary["morisitahorn"] = "morisitahorn";
352 sharedsummary["braycurtis"] = "braycurtis";
353 sharedsummary["default"] = "default";
355 catch(exception& e) {
356 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
360 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
366 /********************************************************************/
368 void ValidCalculators::initialSharedRarefact() {
370 sharedrarefaction["sharedobserved"] = "sharedobserved";
371 sharedrarefaction["sharednseqs"] = "sharednseqs";
372 sharedrarefaction["default"] = "default";
374 catch(exception& e) {
375 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
379 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
385 /********************************************************************/
386 void ValidCalculators::initialVennSingle() {
388 vennsingle["sobs"] = "sobs";
389 vennsingle["chao"] = "chao";
390 vennsingle["ace"] = "ace";
391 vennsingle["jack"] = "jack";
392 vennsingle["default"] = "default";
394 catch(exception& e) {
395 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
399 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
404 /********************************************************************/
405 void ValidCalculators::initialVennShared() {
407 vennshared["sharedsobs"] = "sharedsobs";
408 vennshared["sharedchao"] = "sharedchao";
409 vennshared["sharedace"] = "sharedace";
410 vennshared["default"] = "default";
412 catch(exception& e) {
413 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
417 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
422 /********************************************************************/
423 void ValidCalculators::initialTreeGroups() {
425 treegroup["jabund"] = "jabund";
426 treegroup["sorabund"] = "sorabund";
427 treegroup["jclass"] = "jclass";
428 treegroup["sorclass"] = "sorclass";
429 treegroup["jest"] = "jest";
430 treegroup["sorest"] = "sorest";
431 treegroup["thetayc"] = "thetayc";
432 treegroup["thetan"] = "thetan";
433 treegroup["morisitahorn"] = "morisitahorn";
434 treegroup["braycurtis"] = "braycurtis";
436 catch(exception& e) {
437 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
441 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
445 /********************************************************************/
446 void ValidCalculators::initialMatrix() {
448 matrix["jabund"] = "jabund";
449 matrix["sorabund"] = "sorabund";
450 matrix["jclass"] = "jclass";
451 matrix["sorclass"] = "sorclass";
452 matrix["jest"] = "jest";
453 matrix["sorest"] = "sorest";
454 matrix["thetayc"] = "thetayc";
455 matrix["thetan"] = "thetan";
456 matrix["morisitahorn"] = "morisitahorn";
457 matrix["braycurtis"] = "braycurtis";
459 catch(exception& e) {
460 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
464 cout << "An unknown error has occurred in the ValidCalculator class function initialMatrix. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
469 /********************************************************************/
470 void ValidCalculators::initialBoot() {
472 boot["jabund"] = "jabund";
473 boot["sorabund"] = "sorabund";
474 boot["jclass"] = "jclass";
475 boot["sorclass"] = "orclass";
476 boot["jest"] = "jest";
477 boot["sorest"] = "sorest";
478 boot["thetayc"] = "thetayc";
479 boot["thetan"] = "thetan";
480 boot["morisitahorn"] = "morisitahorn";
481 boot["braycurtis"] = "braycurtis";
483 catch(exception& e) {
484 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
488 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
492 /********************************************************************/
493 void ValidCalculators::initialDistance() {
495 distance["nogaps"] = "nogaps";
496 distance["eachgap"] = "eachgap";
497 distance["onegap"] = "onegap";
499 catch(exception& e) {
500 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
504 cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
509 /********************************************************************/
510 void ValidCalculators::printCalc(string parameter, ostream& out) {
512 out << "The available estimators for calc are ";
513 //are you looking for a calculator for a single parameter
514 if (parameter == "single") {
515 for (it = single.begin(); it != single.end(); it++) {
516 out << it->first << ", ";
518 //are you looking for a calculator for a shared parameter
519 }else if (parameter == "shared") {
520 for (it = shared.begin(); it != shared.end(); it++) {
521 out << it->first << ", ";
523 //are you looking for a calculator for a rarefaction parameter
524 }else if (parameter == "rarefaction") {
525 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
526 out << it->first << ", ";
528 //are you looking for a calculator for a summary parameter
529 }else if (parameter == "summary") {
530 for (it = summary.begin(); it != summary.end(); it++) {
531 out << it->first << ", ";
533 //are you looking for a calculator for a sharedsummary parameter
534 }else if (parameter == "sharedsummary") {
535 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
536 out << it->first << ", ";
538 }else if (parameter == "sharedrarefaction") {
539 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
540 out << it->first << ", ";
542 }else if (parameter == "vennsingle") {
543 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
544 out << it->first << ", ";
546 }else if (parameter == "vennshared") {
547 for (it = vennshared.begin(); it != vennshared.end(); it++) {
548 out << it->first << ", ";
550 }else if (parameter == "treegroup") {
551 for (it = treegroup.begin(); it != treegroup.end(); it++) {
552 out << it->first << ", ";
554 }else if (parameter == "matrix") {
555 for (it = matrix.begin(); it != matrix.end(); it++) {
556 out << it->first << ", ";
558 }else if (parameter == "boot") {
559 for (it = boot.begin(); it != boot.end(); it++) {
560 out << it->first << ", ";
562 }else if (parameter == "distance") {
563 for (it = distance.begin(); it != distance.end(); it++) {
564 out << it->first << ", ";
570 catch(exception& e) {
571 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
575 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
580 /********************************************************************/