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 errorOut(e, "ValidCalculator", "ValidCalculator");
35 /********************************************************************/
37 ValidCalculators::~ValidCalculators() {}
39 /********************************************************************/
41 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
43 //are you looking for a calculator for a single parameter
44 if (parameter == "single") {
46 if ((single.find(calculator)) != (single.end())) {
49 mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
50 for (it = single.begin(); it != single.end(); it++) {
51 mothurOut(it->first + ", ");
55 //are you looking for a calculator for a shared parameter
56 }else if (parameter == "shared") {
58 if ((shared.find(calculator)) != (shared.end())) {
61 mothurOut(calculator + " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ");
62 for (it = shared.begin(); it != shared.end(); it++) {
63 mothurOut(it->first + ", ");
67 //are you looking for a calculator for a rarefaction parameter
68 }else if (parameter == "rarefaction") {
70 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
73 mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
74 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
75 mothurOut(it->first + ", ");
79 //are you looking for a calculator for a summary parameter
80 }else if (parameter == "summary") {
82 if ((summary.find(calculator)) != (summary.end())) {
85 mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
86 for (it = summary.begin(); it != summary.end(); it++) {
87 mothurOut(it->first + ", ");
91 //are you looking for a calculator for a sharedsummary parameter
92 }else if (parameter == "sharedsummary") {
94 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
97 mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
98 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
99 mothurOut(it->first + ", ");
103 }else if (parameter == "sharedrarefaction") {
105 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
108 mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
109 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
110 mothurOut(it->first + ", ");
114 }else if (parameter == "vennsingle") {
116 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
119 mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
120 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
121 mothurOut(it->first + ", ");
125 }else if (parameter == "vennshared") {
127 if ((vennshared.find(calculator)) != (vennshared.end())) {
130 mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
131 for (it = vennshared.begin(); it != vennshared.end(); it++) {
132 mothurOut(it->first + ", ");
136 }else if (parameter == "treegroup") {
138 if ((treegroup.find(calculator)) != (treegroup.end())) {
141 mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
142 for (it = treegroup.begin(); it != treegroup.end(); it++) {
143 mothurOut(it->first + ", ");
147 }else if (parameter == "matrix") {
149 if ((matrix.find(calculator)) != (matrix.end())) {
152 mothurOut(calculator + " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
153 for (it = matrix.begin(); it != matrix.end(); it++) {
154 mothurOut(it->first + ", ");
158 }else if (parameter == "heat") {
160 if ((heat.find(calculator)) != (heat.end())) {
163 mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
164 for (it = heat.begin(); it != heat.end(); it++) {
165 mothurOut(it->first + ", ");
169 }else if (parameter == "boot") {
171 if ((boot.find(calculator)) != (boot.end())) {
174 mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
175 for (it = boot.begin(); it != boot.end(); it++) {
176 mothurOut(it->first + ", ");
180 }else if (parameter == "distance") {
182 if ((distance.find(calculator)) != (distance.end())) {
185 mothurOut(calculator + " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
186 for (it = distance.begin(); it != distance.end(); it++) {
187 mothurOut(it->first + ", ");
191 //not a valid parameter
192 }else { return false; }
195 catch(exception& e) {
196 errorOut(e, "ValidCalculator", "isValidCalculator");
201 /********************************************************************/
202 void ValidCalculators::initialSingle() {
204 single["sobs"] = "sobs";
205 single["chao"] = "chao";
206 single["ace"] = "ace";
207 single["jack"] = "jack";
208 single["shannon"] = "shannon";
209 single["npshannon"] = "npshannon";
210 single["simpson"] = "simpson";
211 single["bergerparker"] = "bergerparker";
212 single["bootstrap"] = "bootstrap";
213 single["geometric"] = "geometric";
214 single["logseries"] = "logseries";
215 single["qstat"] = "qstat";
216 single["bstick"] = "bstick";
217 single["goodscoverage"] = "goodscoverage";
218 single["nseqs"] = "nseqs";
219 single["coverage"] = "coverage";
220 single["efron"] = "efron";
221 single["boneh"] = "boneh";
222 single["solow"] = "solow";
223 single["shen"] = "shen";
224 single["default"] = "default";
226 catch(exception& e) {
227 errorOut(e, "ValidCalculator", "initialSingle");
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 errorOut(e, "ValidCalculator", "initialShared");
264 /********************************************************************/
265 void ValidCalculators::initialRarefaction() {
267 rarefaction["sobs"] = "sobs";
268 rarefaction["chao"] = "chao";
269 rarefaction["ace"] = "ace";
270 rarefaction["jack"] = "jack";
271 rarefaction["shannon"] = "shannon";
272 rarefaction["npshannon"] = "npshannon";
273 rarefaction["simpson"] = "simpson";
274 rarefaction["bootstrap"] = "bootstrap";
275 rarefaction["nseqs"] = "nseqs";
276 rarefaction["coverage"] = "coverage";
277 rarefaction["default"] = "default";
279 catch(exception& e) {
280 errorOut(e, "ValidCalculator", "initialRarefaction");
285 /********************************************************************/
287 void ValidCalculators::initialSummary() {
289 summary["sobs"] = "sobs";
290 summary["chao"] = "chao";
291 summary["ace"] = "ace";
292 summary["jack"] = "jack";
293 summary["shannon"] = "shannon";
294 summary["npshannon"] = "npshannon";
295 summary["simpson"] = "simpson";
296 summary["bergerparker"] = "bergerparker";
297 summary["geometric"] = "geometric";
298 summary["bootstrap"] = "bootstrap";
299 summary["logseries"] = "logseries";
300 summary["qstat"] = "qstat";
301 summary["bstick"] = "bstick";
302 summary["nseqs"] = "nseqs";
303 summary["goodscoverage"]= "goodscoverage";
304 summary["coverage"] = "coverage";
305 summary["efron"] = "efron";
306 summary["boneh"] = "boneh";
307 summary["solow"] = "solow";
308 summary["shen"] = "shen";
309 summary["default"] = "default";
311 catch(exception& e) {
312 errorOut(e, "ValidCalculator", "initialSummary");
317 /********************************************************************/
318 void ValidCalculators::initialSharedSummary() {
320 sharedsummary["sharedsobs"] = "sharedsobs";
321 sharedsummary["sharedchao"] = "sharedchao";
322 sharedsummary["sharedace"] = "sharedace";
323 sharedsummary["jabund"] = "jabund";
324 sharedsummary["sorabund"] = "sorabund";
325 sharedsummary["jclass"] = "jclass";
326 sharedsummary["sorclass"] = "sorclass";
327 sharedsummary["jest"] = "jest";
328 sharedsummary["sorest"] = "sorest";
329 sharedsummary["thetayc"] = "thetayc";
330 sharedsummary["thetan"] = "thetan";
331 sharedsummary["kstest"] = "kstest";
332 sharedsummary["whittaker"] = "whittaker";
333 sharedsummary["sharednseqs"] = "sharednseqs";
334 sharedsummary["ochiai"] = "ochiai";
335 sharedsummary["anderberg"] = "anderberg";
336 sharedsummary["kulczynski"] = "kulczynski";
337 sharedsummary["kulczynskicody"] = "kulczynskicody";
338 sharedsummary["lennon"] = "lennon";
339 sharedsummary["morisitahorn"] = "morisitahorn";
340 sharedsummary["braycurtis"] = "braycurtis";
341 sharedsummary["default"] = "default";
343 catch(exception& e) {
344 errorOut(e, "ValidCalculator", "initialSharedSummary");
350 /********************************************************************/
352 void ValidCalculators::initialSharedRarefact() {
354 sharedrarefaction["sharedobserved"] = "sharedobserved";
355 sharedrarefaction["sharednseqs"] = "sharednseqs";
356 sharedrarefaction["default"] = "default";
358 catch(exception& e) {
359 errorOut(e, "ValidCalculator", "initialSharedRarefact");
365 /********************************************************************/
366 void ValidCalculators::initialVennSingle() {
368 vennsingle["sobs"] = "sobs";
369 vennsingle["chao"] = "chao";
370 vennsingle["ace"] = "ace";
371 vennsingle["jack"] = "jack";
372 vennsingle["default"] = "default";
374 catch(exception& e) {
375 errorOut(e, "ValidCalculator", "initialVennSingle");
380 /********************************************************************/
381 void ValidCalculators::initialVennShared() {
383 vennshared["sharedsobs"] = "sharedsobs";
384 vennshared["sharedchao"] = "sharedchao";
385 vennshared["sharedace"] = "sharedace";
386 vennshared["default"] = "default";
388 catch(exception& e) {
389 errorOut(e, "ValidCalculator", "initialVennShared");
394 /********************************************************************/
395 void ValidCalculators::initialTreeGroups() {
397 treegroup["jabund"] = "jabund";
398 treegroup["sorabund"] = "sorabund";
399 treegroup["jclass"] = "jclass";
400 treegroup["sorclass"] = "sorclass";
401 treegroup["jest"] = "jest";
402 treegroup["sorest"] = "sorest";
403 treegroup["thetayc"] = "thetayc";
404 treegroup["thetan"] = "thetan";
405 treegroup["morisitahorn"] = "morisitahorn";
406 treegroup["braycurtis"] = "braycurtis";
408 catch(exception& e) {
409 errorOut(e, "ValidCalculator", "initialTreeGroups");
413 /********************************************************************/
414 void ValidCalculators::initialHeat() {
416 heat["jabund"] = "jabund";
417 heat["sorabund"] = "sorabund";
418 heat["jclass"] = "jclass";
419 heat["sorclass"] = "sorclass";
420 heat["jest"] = "jest";
421 heat["sorest"] = "sorest";
422 heat["thetayc"] = "thetayc";
423 heat["thetan"] = "thetan";
424 heat["morisitahorn"] = "morisitahorn";
425 heat["braycurtis"] = "braycurtis";
427 catch(exception& e) {
428 errorOut(e, "ValidCalculator", "initialHeat");
433 /********************************************************************/
434 void ValidCalculators::initialMatrix() {
436 matrix["jabund"] = "jabund";
437 matrix["sorabund"] = "sorabund";
438 matrix["jclass"] = "jclass";
439 matrix["sorclass"] = "sorclass";
440 matrix["jest"] = "jest";
441 matrix["sorest"] = "sorest";
442 matrix["thetayc"] = "thetayc";
443 matrix["thetan"] = "thetan";
444 matrix["morisitahorn"] = "morisitahorn";
445 matrix["braycurtis"] = "braycurtis";
447 catch(exception& e) {
448 errorOut(e, "ValidCalculator", "initialMatrix");
453 /********************************************************************/
454 void ValidCalculators::initialBoot() {
456 boot["jabund"] = "jabund";
457 boot["sorabund"] = "sorabund";
458 boot["jclass"] = "jclass";
459 boot["sorclass"] = "orclass";
460 boot["jest"] = "jest";
461 boot["sorest"] = "sorest";
462 boot["thetayc"] = "thetayc";
463 boot["thetan"] = "thetan";
464 boot["morisitahorn"] = "morisitahorn";
465 boot["braycurtis"] = "braycurtis";
467 catch(exception& e) {
468 errorOut(e, "ValidCalculator", "initialBoot");
472 /********************************************************************/
473 void ValidCalculators::initialDistance() {
475 distance["nogaps"] = "nogaps";
476 distance["eachgap"] = "eachgap";
477 distance["onegap"] = "onegap";
479 catch(exception& e) {
480 errorOut(e, "ValidCalculator", "initialDistance");
485 /********************************************************************/
486 void ValidCalculators::printCalc(string parameter, ostream& out) {
488 out << "The available estimators for calc are ";
489 //are you looking for a calculator for a single parameter
490 if (parameter == "single") {
491 for (it = single.begin(); it != single.end(); it++) {
492 out << it->first << ", ";
494 //are you looking for a calculator for a shared parameter
495 }else if (parameter == "shared") {
496 for (it = shared.begin(); it != shared.end(); it++) {
497 out << it->first << ", ";
499 //are you looking for a calculator for a rarefaction parameter
500 }else if (parameter == "rarefaction") {
501 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
502 out << it->first << ", ";
504 //are you looking for a calculator for a summary parameter
505 }else if (parameter == "summary") {
506 for (it = summary.begin(); it != summary.end(); it++) {
507 out << it->first << ", ";
509 //are you looking for a calculator for a sharedsummary parameter
510 }else if (parameter == "sharedsummary") {
511 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
512 out << it->first << ", ";
514 }else if (parameter == "sharedrarefaction") {
515 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
516 out << it->first << ", ";
518 }else if (parameter == "vennsingle") {
519 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
520 out << it->first << ", ";
522 }else if (parameter == "vennshared") {
523 for (it = vennshared.begin(); it != vennshared.end(); it++) {
524 out << it->first << ", ";
526 }else if (parameter == "treegroup") {
527 for (it = treegroup.begin(); it != treegroup.end(); it++) {
528 out << it->first << ", ";
530 }else if (parameter == "matrix") {
531 for (it = matrix.begin(); it != matrix.end(); it++) {
532 out << it->first << ", ";
534 }else if (parameter == "heat") {
535 for (it = heat.begin(); it != heat.end(); it++) {
536 out << it->first << ", ";
538 }else if (parameter == "boot") {
539 for (it = boot.begin(); it != boot.end(); it++) {
540 out << it->first << ", ";
542 }else if (parameter == "distance") {
543 for (it = distance.begin(); it != distance.end(); it++) {
544 out << it->first << ", ";
550 catch(exception& e) {
551 errorOut(e, "ValidCalculator", "printCalc");
555 /********************************************************************/