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["odum"] = "odum";
264 shared["canberra"] = "canberra";
265 shared["structeuclidean"] = "structeuclidean";
266 shared["structchord"] = "structchord";
267 shared["hellinger"] = "hellinger";
268 shared["manhattan"] = "manhattan";
269 shared["structpearson"] = "structpearson";
270 shared["soergel"] = "soergel";
271 shared["spearman"] = "spearman";
272 shared["structkulczynski"] = "structkulczynski";
273 shared["structchi2"] = "structchi2";
274 shared["speciesprofile"] = "speciesprofile";
275 shared["hamming"] = "hamming";
276 shared["gower"] = "gower";
277 shared["memchi2"] = "memchi2";
278 shared["memchord"] = "memchord";
279 shared["memeuclidean"] = "memeuclidean";
280 shared["mempearson"] = "mempearson";
281 shared["default"] = "default";
283 catch(exception& e) {
284 m->errorOut(e, "ValidCalculator", "initialShared");
289 /********************************************************************/
290 void ValidCalculators::initialRarefaction() {
292 rarefaction["sobs"] = "sobs";
293 rarefaction["chao"] = "chao";
294 rarefaction["ace"] = "ace";
295 rarefaction["jack"] = "jack";
296 rarefaction["shannon"] = "shannon";
297 rarefaction["smithwilson"] = "smithwilson";
298 rarefaction["heip"] = "heip";
299 rarefaction["npshannon"] = "npshannon";
300 rarefaction["shannoneven"] = "shannoneven";
301 rarefaction["simpson"] = "simpson";
302 rarefaction["invsimpson"] = "invsimpson";
303 rarefaction["simpsoneven"] = "simpsoneven";
304 rarefaction["bootstrap"] = "bootstrap";
305 rarefaction["nseqs"] = "nseqs";
306 rarefaction["coverage"] = "coverage";
307 rarefaction["default"] = "default";
309 catch(exception& e) {
310 m->errorOut(e, "ValidCalculator", "initialRarefaction");
315 /********************************************************************/
317 void ValidCalculators::initialSummary() {
319 summary["sobs"] = "sobs";
320 summary["chao"] = "chao";
321 summary["ace"] = "ace";
322 summary["jack"] = "jack";
323 summary["shannon"] = "shannon";
324 summary["heip"] = "heip";
325 summary["shannoneven"] = "shannoneven";
326 summary["smithwilson"] = "smithwilson";
327 summary["invsimpson"] = "invsimpson";
328 summary["npshannon"] = "npshannon";
329 summary["simpson"] = "simpson";
330 summary["simpsoneven"] = "simpsoneven";
331 summary["bergerparker"] = "bergerparker";
332 summary["geometric"] = "geometric";
333 summary["bootstrap"] = "bootstrap";
334 summary["logseries"] = "logseries";
335 summary["qstat"] = "qstat";
336 summary["bstick"] = "bstick";
337 summary["nseqs"] = "nseqs";
338 summary["goodscoverage"]= "goodscoverage";
339 summary["coverage"] = "coverage";
340 summary["efron"] = "efron";
341 summary["boneh"] = "boneh";
342 summary["solow"] = "solow";
343 summary["shen"] = "shen";
344 summary["default"] = "default";
346 catch(exception& e) {
347 m->errorOut(e, "ValidCalculator", "initialSummary");
352 /********************************************************************/
353 void ValidCalculators::initialSharedSummary() {
355 sharedsummary["sharedsobs"] = "sharedsobs";
356 sharedsummary["sharedchao"] = "sharedchao";
357 sharedsummary["sharedace"] = "sharedace";
358 sharedsummary["jabund"] = "jabund";
359 sharedsummary["sorabund"] = "sorabund";
360 sharedsummary["jclass"] = "jclass";
361 sharedsummary["sorclass"] = "sorclass";
362 sharedsummary["jest"] = "jest";
363 sharedsummary["sorest"] = "sorest";
364 sharedsummary["thetayc"] = "thetayc";
365 sharedsummary["thetan"] = "thetan";
366 sharedsummary["kstest"] = "kstest";
367 sharedsummary["whittaker"] = "whittaker";
368 sharedsummary["sharednseqs"] = "sharednseqs";
369 sharedsummary["ochiai"] = "ochiai";
370 sharedsummary["anderberg"] = "anderberg";
371 sharedsummary["kulczynski"] = "kulczynski";
372 sharedsummary["kulczynskicody"] = "kulczynskicody";
373 sharedsummary["lennon"] = "lennon";
374 sharedsummary["morisitahorn"] = "morisitahorn";
375 sharedsummary["braycurtis"] = "braycurtis";
376 sharedsummary["odum"] = "odum";
377 sharedsummary["canberra"] = "canberra";
378 sharedsummary["structeuclidean"] = "structeuclidean";
379 sharedsummary["structchord"] = "structchord";
380 sharedsummary["hellinger"] = "hellinger";
381 sharedsummary["manhattan"] = "manhattan";
382 sharedsummary["structpearson"] = "structpearson";
383 sharedsummary["structkulczynski"] = "structkulczynski";
384 sharedsummary["structchi2"] = "structchi2";
385 sharedsummary["soergel"] = "soergel";
386 sharedsummary["spearman"] = "spearman";
387 sharedsummary["speciesprofile"] = "speciesprofile";
388 sharedsummary["hamming"] = "hamming";
389 sharedsummary["gower"] = "gower";
390 sharedsummary["memchi2"] = "memchi2";
391 sharedsummary["memchord"] = "memchord";
392 sharedsummary["memeuclidean"] = "memeuclidean";
393 sharedsummary["mempearson"] = "mempearson";
394 sharedsummary["default"] = "default";
396 catch(exception& e) {
397 m->errorOut(e, "ValidCalculator", "initialSharedSummary");
403 /********************************************************************/
405 void ValidCalculators::initialSharedRarefact() {
407 sharedrarefaction["sharedobserved"] = "sharedobserved";
408 sharedrarefaction["sharednseqs"] = "sharednseqs";
409 sharedrarefaction["default"] = "default";
411 catch(exception& e) {
412 m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
418 /********************************************************************/
419 void ValidCalculators::initialVennSingle() {
421 vennsingle["sobs"] = "sobs";
422 vennsingle["chao"] = "chao";
423 vennsingle["ace"] = "ace";
424 vennsingle["jack"] = "jack";
425 vennsingle["default"] = "default";
427 catch(exception& e) {
428 m->errorOut(e, "ValidCalculator", "initialVennSingle");
433 /********************************************************************/
434 void ValidCalculators::initialVennShared() {
436 vennshared["sharedsobs"] = "sharedsobs";
437 vennshared["sharedchao"] = "sharedchao";
438 vennshared["sharedace"] = "sharedace";
439 vennshared["default"] = "default";
441 catch(exception& e) {
442 m->errorOut(e, "ValidCalculator", "initialVennShared");
447 /********************************************************************/
448 void ValidCalculators::initialTreeGroups() {
450 treegroup["jabund"] = "jabund";
451 treegroup["sorabund"] = "sorabund";
452 treegroup["jclass"] = "jclass";
453 treegroup["sorclass"] = "sorclass";
454 treegroup["jest"] = "jest";
455 treegroup["sorest"] = "sorest";
456 treegroup["thetayc"] = "thetayc";
457 treegroup["thetan"] = "thetan";
458 treegroup["morisitahorn"] = "morisitahorn";
459 treegroup["braycurtis"] = "braycurtis";
461 catch(exception& e) {
462 m->errorOut(e, "ValidCalculator", "initialTreeGroups");
466 /********************************************************************/
467 void ValidCalculators::initialHeat() {
469 heat["jabund"] = "jabund";
470 heat["sorabund"] = "sorabund";
471 heat["jclass"] = "jclass";
472 heat["sorclass"] = "sorclass";
473 heat["jest"] = "jest";
474 heat["sorest"] = "sorest";
475 heat["thetayc"] = "thetayc";
476 heat["thetan"] = "thetan";
477 heat["morisitahorn"] = "morisitahorn";
478 heat["braycurtis"] = "braycurtis";
480 catch(exception& e) {
481 m->errorOut(e, "ValidCalculator", "initialHeat");
486 /********************************************************************/
487 void ValidCalculators::initialMatrix() {
489 matrix["jabund"] = "jabund";
490 matrix["sorabund"] = "sorabund";
491 matrix["jclass"] = "jclass";
492 matrix["sorclass"] = "sorclass";
493 matrix["jest"] = "jest";
494 matrix["sorest"] = "sorest";
495 matrix["thetayc"] = "thetayc";
496 matrix["thetan"] = "thetan";
497 matrix["morisitahorn"] = "morisitahorn";
498 matrix["braycurtis"] = "braycurtis";
500 catch(exception& e) {
501 m->errorOut(e, "ValidCalculator", "initialMatrix");
506 /********************************************************************/
507 void ValidCalculators::initialBoot() {
509 boot["jabund"] = "jabund";
510 boot["sorabund"] = "sorabund";
511 boot["jclass"] = "jclass";
512 boot["sorclass"] = "orclass";
513 boot["jest"] = "jest";
514 boot["sorest"] = "sorest";
515 boot["thetayc"] = "thetayc";
516 boot["thetan"] = "thetan";
517 boot["morisitahorn"] = "morisitahorn";
518 boot["braycurtis"] = "braycurtis";
520 catch(exception& e) {
521 m->errorOut(e, "ValidCalculator", "initialBoot");
525 /********************************************************************/
526 void ValidCalculators::initialDistance() {
528 distance["nogaps"] = "nogaps";
529 distance["eachgap"] = "eachgap";
530 distance["onegap"] = "onegap";
532 catch(exception& e) {
533 m->errorOut(e, "ValidCalculator", "initialDistance");
538 /********************************************************************/
539 void ValidCalculators::printCalc(string parameter, ostream& out) {
541 out << "The available estimators for calc are ";
542 //are you looking for a calculator for a single parameter
543 if (parameter == "single") {
544 for (it = single.begin(); it != single.end(); it++) {
545 out << it->first << ", ";
547 //are you looking for a calculator for a shared parameter
548 }else if (parameter == "shared") {
549 for (it = shared.begin(); it != shared.end(); it++) {
550 out << it->first << ", ";
552 //are you looking for a calculator for a rarefaction parameter
553 }else if (parameter == "rarefaction") {
554 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
555 out << it->first << ", ";
557 //are you looking for a calculator for a summary parameter
558 }else if (parameter == "summary") {
559 for (it = summary.begin(); it != summary.end(); it++) {
560 out << it->first << ", ";
562 //are you looking for a calculator for a sharedsummary parameter
563 }else if (parameter == "sharedsummary") {
564 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
565 out << it->first << ", ";
567 }else if (parameter == "sharedrarefaction") {
568 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
569 out << it->first << ", ";
571 }else if (parameter == "vennsingle") {
572 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
573 out << it->first << ", ";
575 }else if (parameter == "vennshared") {
576 for (it = vennshared.begin(); it != vennshared.end(); it++) {
577 out << it->first << ", ";
579 }else if (parameter == "treegroup") {
580 for (it = treegroup.begin(); it != treegroup.end(); it++) {
581 out << it->first << ", ";
583 }else if (parameter == "matrix") {
584 for (it = matrix.begin(); it != matrix.end(); it++) {
585 out << it->first << ", ";
587 }else if (parameter == "heat") {
588 for (it = heat.begin(); it != heat.end(); it++) {
589 out << it->first << ", ";
591 }else if (parameter == "boot") {
592 for (it = boot.begin(); it != boot.end(); it++) {
593 out << it->first << ", ";
595 }else if (parameter == "distance") {
596 for (it = distance.begin(); it != distance.end(); it++) {
597 out << it->first << ", ";
603 catch(exception& e) {
604 m->errorOut(e, "ValidCalculator", "printCalc");
608 /********************************************************************/