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["stricteuclidean"] = "stricteuclidean";
266 shared["strictchord"] = "strictchord";
267 shared["hellinger"] = "hellinger";
268 shared["manhattan"] = "manhattan";
269 shared["strictpearson"] = "strictpearson";
270 shared["soergel"] = "soergel";
271 shared["spearman"] = "spearman";
272 shared["strictkulczynski"] = "strictkulczynski";
273 shared["speciesprofile"] = "speciesprofile";
274 shared["hamming"] = "hamming";
275 shared["default"] = "default";
277 catch(exception& e) {
278 m->errorOut(e, "ValidCalculator", "initialShared");
283 /********************************************************************/
284 void ValidCalculators::initialRarefaction() {
286 rarefaction["sobs"] = "sobs";
287 rarefaction["chao"] = "chao";
288 rarefaction["ace"] = "ace";
289 rarefaction["jack"] = "jack";
290 rarefaction["shannon"] = "shannon";
291 rarefaction["smithwilson"] = "smithwilson";
292 rarefaction["heip"] = "heip";
293 rarefaction["npshannon"] = "npshannon";
294 rarefaction["shannoneven"] = "shannoneven";
295 rarefaction["simpson"] = "simpson";
296 rarefaction["invsimpson"] = "invsimpson";
297 rarefaction["simpsoneven"] = "simpsoneven";
298 rarefaction["bootstrap"] = "bootstrap";
299 rarefaction["nseqs"] = "nseqs";
300 rarefaction["coverage"] = "coverage";
301 rarefaction["default"] = "default";
303 catch(exception& e) {
304 m->errorOut(e, "ValidCalculator", "initialRarefaction");
309 /********************************************************************/
311 void ValidCalculators::initialSummary() {
313 summary["sobs"] = "sobs";
314 summary["chao"] = "chao";
315 summary["ace"] = "ace";
316 summary["jack"] = "jack";
317 summary["shannon"] = "shannon";
318 summary["heip"] = "heip";
319 summary["shannoneven"] = "shannoneven";
320 summary["smithwilson"] = "smithwilson";
321 summary["invsimpson"] = "invsimpson";
322 summary["npshannon"] = "npshannon";
323 summary["simpson"] = "simpson";
324 summary["simpsoneven"] = "simpsoneven";
325 summary["bergerparker"] = "bergerparker";
326 summary["geometric"] = "geometric";
327 summary["bootstrap"] = "bootstrap";
328 summary["logseries"] = "logseries";
329 summary["qstat"] = "qstat";
330 summary["bstick"] = "bstick";
331 summary["nseqs"] = "nseqs";
332 summary["goodscoverage"]= "goodscoverage";
333 summary["coverage"] = "coverage";
334 summary["efron"] = "efron";
335 summary["boneh"] = "boneh";
336 summary["solow"] = "solow";
337 summary["shen"] = "shen";
338 summary["default"] = "default";
340 catch(exception& e) {
341 m->errorOut(e, "ValidCalculator", "initialSummary");
346 /********************************************************************/
347 void ValidCalculators::initialSharedSummary() {
349 sharedsummary["sharedsobs"] = "sharedsobs";
350 sharedsummary["sharedchao"] = "sharedchao";
351 sharedsummary["sharedace"] = "sharedace";
352 sharedsummary["jabund"] = "jabund";
353 sharedsummary["sorabund"] = "sorabund";
354 sharedsummary["jclass"] = "jclass";
355 sharedsummary["sorclass"] = "sorclass";
356 sharedsummary["jest"] = "jest";
357 sharedsummary["sorest"] = "sorest";
358 sharedsummary["thetayc"] = "thetayc";
359 sharedsummary["thetan"] = "thetan";
360 sharedsummary["kstest"] = "kstest";
361 sharedsummary["whittaker"] = "whittaker";
362 sharedsummary["sharednseqs"] = "sharednseqs";
363 sharedsummary["ochiai"] = "ochiai";
364 sharedsummary["anderberg"] = "anderberg";
365 sharedsummary["kulczynski"] = "kulczynski";
366 sharedsummary["kulczynskicody"] = "kulczynskicody";
367 sharedsummary["lennon"] = "lennon";
368 sharedsummary["morisitahorn"] = "morisitahorn";
369 sharedsummary["braycurtis"] = "braycurtis";
370 sharedsummary["odum"] = "odum";
371 sharedsummary["canberra"] = "canberra";
372 sharedsummary["stricteuclidean"] = "stricteuclidean";
373 sharedsummary["strictchord"] = "strictchord";
374 sharedsummary["hellinger"] = "hellinger";
375 sharedsummary["manhattan"] = "manhattan";
376 sharedsummary["strictpearson"] = "strictpearson";
377 sharedsummary["strictkulczynski"] = "strictkulczynski";
378 sharedsummary["soergel"] = "soergel";
379 sharedsummary["spearman"] = "spearman";
380 sharedsummary["speciesprofile"] = "speciesprofile";
381 sharedsummary["hamming"] = "hamming";
382 sharedsummary["default"] = "default";
384 catch(exception& e) {
385 m->errorOut(e, "ValidCalculator", "initialSharedSummary");
391 /********************************************************************/
393 void ValidCalculators::initialSharedRarefact() {
395 sharedrarefaction["sharedobserved"] = "sharedobserved";
396 sharedrarefaction["sharednseqs"] = "sharednseqs";
397 sharedrarefaction["default"] = "default";
399 catch(exception& e) {
400 m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
406 /********************************************************************/
407 void ValidCalculators::initialVennSingle() {
409 vennsingle["sobs"] = "sobs";
410 vennsingle["chao"] = "chao";
411 vennsingle["ace"] = "ace";
412 vennsingle["jack"] = "jack";
413 vennsingle["default"] = "default";
415 catch(exception& e) {
416 m->errorOut(e, "ValidCalculator", "initialVennSingle");
421 /********************************************************************/
422 void ValidCalculators::initialVennShared() {
424 vennshared["sharedsobs"] = "sharedsobs";
425 vennshared["sharedchao"] = "sharedchao";
426 vennshared["sharedace"] = "sharedace";
427 vennshared["default"] = "default";
429 catch(exception& e) {
430 m->errorOut(e, "ValidCalculator", "initialVennShared");
435 /********************************************************************/
436 void ValidCalculators::initialTreeGroups() {
438 treegroup["jabund"] = "jabund";
439 treegroup["sorabund"] = "sorabund";
440 treegroup["jclass"] = "jclass";
441 treegroup["sorclass"] = "sorclass";
442 treegroup["jest"] = "jest";
443 treegroup["sorest"] = "sorest";
444 treegroup["thetayc"] = "thetayc";
445 treegroup["thetan"] = "thetan";
446 treegroup["morisitahorn"] = "morisitahorn";
447 treegroup["braycurtis"] = "braycurtis";
449 catch(exception& e) {
450 m->errorOut(e, "ValidCalculator", "initialTreeGroups");
454 /********************************************************************/
455 void ValidCalculators::initialHeat() {
457 heat["jabund"] = "jabund";
458 heat["sorabund"] = "sorabund";
459 heat["jclass"] = "jclass";
460 heat["sorclass"] = "sorclass";
461 heat["jest"] = "jest";
462 heat["sorest"] = "sorest";
463 heat["thetayc"] = "thetayc";
464 heat["thetan"] = "thetan";
465 heat["morisitahorn"] = "morisitahorn";
466 heat["braycurtis"] = "braycurtis";
468 catch(exception& e) {
469 m->errorOut(e, "ValidCalculator", "initialHeat");
474 /********************************************************************/
475 void ValidCalculators::initialMatrix() {
477 matrix["jabund"] = "jabund";
478 matrix["sorabund"] = "sorabund";
479 matrix["jclass"] = "jclass";
480 matrix["sorclass"] = "sorclass";
481 matrix["jest"] = "jest";
482 matrix["sorest"] = "sorest";
483 matrix["thetayc"] = "thetayc";
484 matrix["thetan"] = "thetan";
485 matrix["morisitahorn"] = "morisitahorn";
486 matrix["braycurtis"] = "braycurtis";
488 catch(exception& e) {
489 m->errorOut(e, "ValidCalculator", "initialMatrix");
494 /********************************************************************/
495 void ValidCalculators::initialBoot() {
497 boot["jabund"] = "jabund";
498 boot["sorabund"] = "sorabund";
499 boot["jclass"] = "jclass";
500 boot["sorclass"] = "orclass";
501 boot["jest"] = "jest";
502 boot["sorest"] = "sorest";
503 boot["thetayc"] = "thetayc";
504 boot["thetan"] = "thetan";
505 boot["morisitahorn"] = "morisitahorn";
506 boot["braycurtis"] = "braycurtis";
508 catch(exception& e) {
509 m->errorOut(e, "ValidCalculator", "initialBoot");
513 /********************************************************************/
514 void ValidCalculators::initialDistance() {
516 distance["nogaps"] = "nogaps";
517 distance["eachgap"] = "eachgap";
518 distance["onegap"] = "onegap";
520 catch(exception& e) {
521 m->errorOut(e, "ValidCalculator", "initialDistance");
526 /********************************************************************/
527 void ValidCalculators::printCalc(string parameter, ostream& out) {
529 out << "The available estimators for calc are ";
530 //are you looking for a calculator for a single parameter
531 if (parameter == "single") {
532 for (it = single.begin(); it != single.end(); it++) {
533 out << it->first << ", ";
535 //are you looking for a calculator for a shared parameter
536 }else if (parameter == "shared") {
537 for (it = shared.begin(); it != shared.end(); it++) {
538 out << it->first << ", ";
540 //are you looking for a calculator for a rarefaction parameter
541 }else if (parameter == "rarefaction") {
542 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
543 out << it->first << ", ";
545 //are you looking for a calculator for a summary parameter
546 }else if (parameter == "summary") {
547 for (it = summary.begin(); it != summary.end(); it++) {
548 out << it->first << ", ";
550 //are you looking for a calculator for a sharedsummary parameter
551 }else if (parameter == "sharedsummary") {
552 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
553 out << it->first << ", ";
555 }else if (parameter == "sharedrarefaction") {
556 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
557 out << it->first << ", ";
559 }else if (parameter == "vennsingle") {
560 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
561 out << it->first << ", ";
563 }else if (parameter == "vennshared") {
564 for (it = vennshared.begin(); it != vennshared.end(); it++) {
565 out << it->first << ", ";
567 }else if (parameter == "treegroup") {
568 for (it = treegroup.begin(); it != treegroup.end(); it++) {
569 out << it->first << ", ";
571 }else if (parameter == "matrix") {
572 for (it = matrix.begin(); it != matrix.end(); it++) {
573 out << it->first << ", ";
575 }else if (parameter == "heat") {
576 for (it = heat.begin(); it != heat.end(); it++) {
577 out << it->first << ", ";
579 }else if (parameter == "boot") {
580 for (it = boot.begin(); it != boot.end(); it++) {
581 out << it->first << ", ";
583 }else if (parameter == "distance") {
584 for (it = distance.begin(); it != distance.end(); it++) {
585 out << it->first << ", ";
591 catch(exception& e) {
592 m->errorOut(e, "ValidCalculator", "printCalc");
596 /********************************************************************/