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["shannoneven"] = "shannoneven";
213 single["smithwilson"] = "smithwilson";
214 single["heip"] = "heip";
215 single["simpson"] = "simpson";
216 single["simpsoneven"] = "simpsoneven";
217 single["invsimpson"] = "invsimpson";
218 single["bergerparker"] = "bergerparker";
219 single["bootstrap"] = "bootstrap";
220 single["geometric"] = "geometric";
221 single["logseries"] = "logseries";
222 single["qstat"] = "qstat";
223 single["bstick"] = "bstick";
224 single["goodscoverage"] = "goodscoverage";
225 single["nseqs"] = "nseqs";
226 single["coverage"] = "coverage";
227 single["efron"] = "efron";
228 single["boneh"] = "boneh";
229 single["solow"] = "solow";
230 single["shen"] = "shen";
231 single["default"] = "default";
233 catch(exception& e) {
234 m->errorOut(e, "ValidCalculator", "initialSingle");
239 /********************************************************************/
240 void ValidCalculators::initialShared() {
242 shared["sharedsobs"] = "sharedsobs";
243 shared["sharedchao"] = "sharedchao";
244 shared["sharedace"] = "sharedace";
245 shared["jabund"] = "jabund";
246 shared["sorabund"] = "sorabund";
247 shared["jclass"] = "jclass";
248 shared["sorclass"] = "sorclass";
249 shared["jest"] = "jest";
250 shared["sorest"] = "sorest";
251 shared["thetayc"] = "thetayc";
252 shared["thetan"] = "thetan";
253 shared["kstest"] = "kstest";
254 shared["whittaker"] = "whittaker";
255 shared["sharednseqs"] = "sharednseqs";
256 shared["ochiai"] = "ochiai";
257 shared["anderberg"] = "anderberg";
258 shared["kulczynski"] = "kulczynski";
259 shared["kulczynskicody"] = "kulczynskicody";
260 shared["lennon"] = "lennon";
261 shared["morisitahorn"] = "morisitahorn";
262 shared["braycurtis"] = "braycurtis";
263 shared["default"] = "default";
265 catch(exception& e) {
266 m->errorOut(e, "ValidCalculator", "initialShared");
271 /********************************************************************/
272 void ValidCalculators::initialRarefaction() {
274 rarefaction["sobs"] = "sobs";
275 rarefaction["chao"] = "chao";
276 rarefaction["ace"] = "ace";
277 rarefaction["jack"] = "jack";
278 rarefaction["shannon"] = "shannon";
279 rarefaction["smithwilson"] = "smithwilson";
280 rarefaction["heip"] = "heip";
281 rarefaction["npshannon"] = "npshannon";
282 rarefaction["shannoneven"] = "shannoneven";
283 rarefaction["simpson"] = "simpson";
284 rarefaction["invsimpson"] = "invsimpson";
285 rarefaction["simpsoneven"] = "simpsoneven";
286 rarefaction["bootstrap"] = "bootstrap";
287 rarefaction["nseqs"] = "nseqs";
288 rarefaction["coverage"] = "coverage";
289 rarefaction["default"] = "default";
291 catch(exception& e) {
292 m->errorOut(e, "ValidCalculator", "initialRarefaction");
297 /********************************************************************/
299 void ValidCalculators::initialSummary() {
301 summary["sobs"] = "sobs";
302 summary["chao"] = "chao";
303 summary["ace"] = "ace";
304 summary["jack"] = "jack";
305 summary["shannon"] = "shannon";
306 summary["heip"] = "heip";
307 summary["shannoneven"] = "shannoneven";
308 summary["smithwilson"] = "smithwilson";
309 summary["invsimpson"] = "invsimpson";
310 summary["npshannon"] = "npshannon";
311 summary["simpson"] = "simpson";
312 summary["simpsoneven"] = "simpsoneven";
313 summary["bergerparker"] = "bergerparker";
314 summary["geometric"] = "geometric";
315 summary["bootstrap"] = "bootstrap";
316 summary["logseries"] = "logseries";
317 summary["qstat"] = "qstat";
318 summary["bstick"] = "bstick";
319 summary["nseqs"] = "nseqs";
320 summary["goodscoverage"]= "goodscoverage";
321 summary["coverage"] = "coverage";
322 summary["efron"] = "efron";
323 summary["boneh"] = "boneh";
324 summary["solow"] = "solow";
325 summary["shen"] = "shen";
326 summary["default"] = "default";
328 catch(exception& e) {
329 m->errorOut(e, "ValidCalculator", "initialSummary");
334 /********************************************************************/
335 void ValidCalculators::initialSharedSummary() {
337 sharedsummary["sharedsobs"] = "sharedsobs";
338 sharedsummary["sharedchao"] = "sharedchao";
339 sharedsummary["sharedace"] = "sharedace";
340 sharedsummary["jabund"] = "jabund";
341 sharedsummary["sorabund"] = "sorabund";
342 sharedsummary["jclass"] = "jclass";
343 sharedsummary["sorclass"] = "sorclass";
344 sharedsummary["jest"] = "jest";
345 sharedsummary["sorest"] = "sorest";
346 sharedsummary["thetayc"] = "thetayc";
347 sharedsummary["thetan"] = "thetan";
348 sharedsummary["kstest"] = "kstest";
349 sharedsummary["whittaker"] = "whittaker";
350 sharedsummary["sharednseqs"] = "sharednseqs";
351 sharedsummary["ochiai"] = "ochiai";
352 sharedsummary["anderberg"] = "anderberg";
353 sharedsummary["kulczynski"] = "kulczynski";
354 sharedsummary["kulczynskicody"] = "kulczynskicody";
355 sharedsummary["lennon"] = "lennon";
356 sharedsummary["morisitahorn"] = "morisitahorn";
357 sharedsummary["braycurtis"] = "braycurtis";
358 sharedsummary["default"] = "default";
360 catch(exception& e) {
361 m->errorOut(e, "ValidCalculator", "initialSharedSummary");
367 /********************************************************************/
369 void ValidCalculators::initialSharedRarefact() {
371 sharedrarefaction["sharedobserved"] = "sharedobserved";
372 sharedrarefaction["sharednseqs"] = "sharednseqs";
373 sharedrarefaction["default"] = "default";
375 catch(exception& e) {
376 m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
382 /********************************************************************/
383 void ValidCalculators::initialVennSingle() {
385 vennsingle["sobs"] = "sobs";
386 vennsingle["chao"] = "chao";
387 vennsingle["ace"] = "ace";
388 vennsingle["jack"] = "jack";
389 vennsingle["nseqs"] = "nseqs";
390 vennsingle["default"] = "default";
392 catch(exception& e) {
393 m->errorOut(e, "ValidCalculator", "initialVennSingle");
398 /********************************************************************/
399 void ValidCalculators::initialVennShared() {
401 vennshared["sharedsobs"] = "sharedsobs";
402 vennshared["sharedchao"] = "sharedchao";
403 vennshared["sharedace"] = "sharedace";
404 vennshared["nseqs"] = "nseqs";
405 vennshared["default"] = "default";
407 catch(exception& e) {
408 m->errorOut(e, "ValidCalculator", "initialVennShared");
413 /********************************************************************/
414 void ValidCalculators::initialTreeGroups() {
416 treegroup["jabund"] = "jabund";
417 treegroup["sorabund"] = "sorabund";
418 treegroup["jclass"] = "jclass";
419 treegroup["sorclass"] = "sorclass";
420 treegroup["jest"] = "jest";
421 treegroup["sorest"] = "sorest";
422 treegroup["thetayc"] = "thetayc";
423 treegroup["thetan"] = "thetan";
424 treegroup["morisitahorn"] = "morisitahorn";
425 treegroup["braycurtis"] = "braycurtis";
427 catch(exception& e) {
428 m->errorOut(e, "ValidCalculator", "initialTreeGroups");
432 /********************************************************************/
433 void ValidCalculators::initialHeat() {
435 heat["jabund"] = "jabund";
436 heat["sorabund"] = "sorabund";
437 heat["jclass"] = "jclass";
438 heat["sorclass"] = "sorclass";
439 heat["jest"] = "jest";
440 heat["sorest"] = "sorest";
441 heat["thetayc"] = "thetayc";
442 heat["thetan"] = "thetan";
443 heat["morisitahorn"] = "morisitahorn";
444 heat["braycurtis"] = "braycurtis";
446 catch(exception& e) {
447 m->errorOut(e, "ValidCalculator", "initialHeat");
452 /********************************************************************/
453 void ValidCalculators::initialMatrix() {
455 matrix["jabund"] = "jabund";
456 matrix["sorabund"] = "sorabund";
457 matrix["jclass"] = "jclass";
458 matrix["sorclass"] = "sorclass";
459 matrix["jest"] = "jest";
460 matrix["sorest"] = "sorest";
461 matrix["thetayc"] = "thetayc";
462 matrix["thetan"] = "thetan";
463 matrix["morisitahorn"] = "morisitahorn";
464 matrix["braycurtis"] = "braycurtis";
466 catch(exception& e) {
467 m->errorOut(e, "ValidCalculator", "initialMatrix");
472 /********************************************************************/
473 void ValidCalculators::initialBoot() {
475 boot["jabund"] = "jabund";
476 boot["sorabund"] = "sorabund";
477 boot["jclass"] = "jclass";
478 boot["sorclass"] = "orclass";
479 boot["jest"] = "jest";
480 boot["sorest"] = "sorest";
481 boot["thetayc"] = "thetayc";
482 boot["thetan"] = "thetan";
483 boot["morisitahorn"] = "morisitahorn";
484 boot["braycurtis"] = "braycurtis";
486 catch(exception& e) {
487 m->errorOut(e, "ValidCalculator", "initialBoot");
491 /********************************************************************/
492 void ValidCalculators::initialDistance() {
494 distance["nogaps"] = "nogaps";
495 distance["eachgap"] = "eachgap";
496 distance["onegap"] = "onegap";
498 catch(exception& e) {
499 m->errorOut(e, "ValidCalculator", "initialDistance");
504 /********************************************************************/
505 void ValidCalculators::printCalc(string parameter, ostream& out) {
507 out << "The available estimators for calc are ";
508 //are you looking for a calculator for a single parameter
509 if (parameter == "single") {
510 for (it = single.begin(); it != single.end(); it++) {
511 out << it->first << ", ";
513 //are you looking for a calculator for a shared parameter
514 }else if (parameter == "shared") {
515 for (it = shared.begin(); it != shared.end(); it++) {
516 out << it->first << ", ";
518 //are you looking for a calculator for a rarefaction parameter
519 }else if (parameter == "rarefaction") {
520 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
521 out << it->first << ", ";
523 //are you looking for a calculator for a summary parameter
524 }else if (parameter == "summary") {
525 for (it = summary.begin(); it != summary.end(); it++) {
526 out << it->first << ", ";
528 //are you looking for a calculator for a sharedsummary parameter
529 }else if (parameter == "sharedsummary") {
530 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
531 out << it->first << ", ";
533 }else if (parameter == "sharedrarefaction") {
534 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
535 out << it->first << ", ";
537 }else if (parameter == "vennsingle") {
538 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
539 out << it->first << ", ";
541 }else if (parameter == "vennshared") {
542 for (it = vennshared.begin(); it != vennshared.end(); it++) {
543 out << it->first << ", ";
545 }else if (parameter == "treegroup") {
546 for (it = treegroup.begin(); it != treegroup.end(); it++) {
547 out << it->first << ", ";
549 }else if (parameter == "matrix") {
550 for (it = matrix.begin(); it != matrix.end(); it++) {
551 out << it->first << ", ";
553 }else if (parameter == "heat") {
554 for (it = heat.begin(); it != heat.end(); it++) {
555 out << it->first << ", ";
557 }else if (parameter == "boot") {
558 for (it = boot.begin(); it != boot.end(); it++) {
559 out << it->first << ", ";
561 }else if (parameter == "distance") {
562 for (it = distance.begin(); it != distance.end(); it++) {
563 out << it->first << ", ";
569 catch(exception& e) {
570 m->errorOut(e, "ValidCalculator", "printCalc");
574 /********************************************************************/