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();
27 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
31 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
36 /********************************************************************/
38 ValidCalculators::~ValidCalculators() {}
40 /********************************************************************/
42 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
44 //are you looking for a calculator for a single parameter
45 if (parameter == "single") {
47 if ((single.find(calculator)) != (single.end())) {
50 cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
51 for (it = single.begin(); it != single.end(); it++) {
52 cout << it->first << ", ";
56 //are you looking for a calculator for a shared parameter
57 }else if (parameter == "shared") {
59 if ((shared.find(calculator)) != (shared.end())) {
62 cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded. Valid estimators are ";
63 for (it = shared.begin(); it != shared.end(); it++) {
64 cout << it->first << ", ";
68 //are you looking for a calculator for a rarefaction parameter
69 }else if (parameter == "rarefaction") {
71 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
74 cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
75 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
76 cout << it->first << ", ";
80 //are you looking for a calculator for a summary parameter
81 }else if (parameter == "summary") {
83 if ((summary.find(calculator)) != (summary.end())) {
86 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
87 for (it = summary.begin(); it != summary.end(); it++) {
88 cout << it->first << ", ";
92 //are you looking for a calculator for a sharedsummary parameter
93 }else if (parameter == "sharedsummary") {
95 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
98 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
99 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
100 cout << it->first << ", ";
104 }else if (parameter == "sharedrarefaction") {
106 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
109 cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
110 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
111 cout << it->first << ", ";
115 }else if (parameter == "vennsingle") {
117 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
120 cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
121 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
122 cout << it->first << ", ";
126 }else if (parameter == "vennshared") {
128 if ((vennshared.find(calculator)) != (vennshared.end())) {
131 cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
132 for (it = vennshared.begin(); it != vennshared.end(); it++) {
133 cout << it->first << ", ";
137 }else if (parameter == "treegroup") {
139 if ((treegroup.find(calculator)) != (treegroup.end())) {
142 cout << calculator << " is not a valid estimator for the tree.shared command in shared mode and will be disregarded. Valid estimators are ";
143 for (it = treegroup.begin(); it != treegroup.end(); it++) {
144 cout << it->first << ", ";
148 }else if (parameter == "boot") {
150 if ((boot.find(calculator)) != (boot.end())) {
153 cout << calculator << " is not a valid estimator for the bootstrap.shared command in shared mode and will be disregarded. Valid estimators are ";
154 for (it = boot.begin(); it != boot.end(); it++) {
155 cout << it->first << ", ";
159 //not a valid parameter
160 }else { return false; }
163 catch(exception& e) {
164 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
168 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
173 /********************************************************************/
174 void ValidCalculators::initialSingle() {
176 single["sobs"] = "sobs";
177 single["chao"] = "chao";
178 single["ace"] = "ace";
179 single["jack"] = "jack";
180 single["shannon"] = "shannon";
181 single["npshannon"] = "npshannon";
182 single["simpson"] = "simpson";
183 single["bergerparker"] = "bergerparker";
184 single["bootstrap"] = "bootstrap";
185 single["geometric"] = "geometric";
186 single["logseries"] = "logseries";
187 single["qstat"] = "qstat";
188 single["bstick"] = "bstick";
189 single["nseqs"] = "nseqs";
190 single["coverage"] = "coverage";
192 single["default"] = "default";
194 catch(exception& e) {
195 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
199 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
204 /********************************************************************/
205 void ValidCalculators::initialShared() {
207 shared["sharedsobs"] = "sharedsobs";
208 shared["sharedchao"] = "sharedchao";
209 shared["sharedace"] = "sharedace";
210 shared["jabund"] = "jabund";
211 shared["sorensonabund"] = "sorensonabund";
212 shared["jclass"] = "jclass";
213 shared["sorclass"] = "sorclass";
214 shared["jest"] = "jest";
215 shared["sorest"] = "sorest";
216 shared["thetayc"] = "thetayc";
217 shared["thetan"] = "thetan";
218 shared["kstest"] = "kstest";
219 shared["bdiversity"] = "bdiversity";
220 shared["sharednseqs"] = "sharednseqs";
221 shared["ochiai"] = "ochiai";
222 shared["anderberg"] = "anderberg";
223 shared["kulczynski"] = "kulczynski";
224 shared["kulczynskicody"] = "kulczynskicody";
225 shared["lennon"] = "lennon";
226 shared["morisitahorn"] = "morisitahorn";
227 shared["braycurtis"] = "braycurtis";
228 shared["default"] = "default";
230 catch(exception& e) {
231 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
235 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
240 /********************************************************************/
241 void ValidCalculators::initialRarefaction() {
243 rarefaction["sobs"] = "sobs";
244 rarefaction["chao"] = "chao";
245 rarefaction["ace"] = "ace";
246 rarefaction["jack"] = "jack";
247 rarefaction["shannon"] = "shannon";
248 rarefaction["npshannon"] = "npshannon";
249 rarefaction["simpson"] = "simpson";
250 rarefaction["bootstrap"] = "bootstrap";
251 rarefaction["nseqs"] = "nseqs";
252 rarefaction["coverage"] = "coverage";
253 rarefaction["default"] = "default";
255 catch(exception& e) {
256 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
260 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
265 /********************************************************************/
267 void ValidCalculators::initialSummary() {
269 summary["sobs"] = "sobs";
270 summary["chao"] = "chao";
271 summary["ace"] = "ace";
272 summary["jack"] = "jack";
273 summary["shannon"] = "shannon";
274 summary["npshannon"] = "npshannon";
275 summary["simpson"] = "simpson";
276 summary["bergerparker"] = "bergerparker";
277 summary["geometric"] = "geometric";
278 summary["bootstrap"] = "bootstrap";
279 summary["logsd"] = "logsd";
280 summary["qstat"] = "qstat";
281 summary["bstick"] = "bstick";
282 summary["nseqs"] = "nseqs";
283 summary["coverage"] = "coverage";
284 summary["default"] = "default";
286 catch(exception& e) {
287 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
291 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
296 /********************************************************************/
297 void ValidCalculators::initialSharedSummary() {
299 sharedsummary["sharedsobs"] = "sharedsobs";
300 sharedsummary["sharedchao"] = "sharedchao";
301 sharedsummary["sharedace"] = "sharedace";
302 sharedsummary["jabund"] = "jabund";
303 sharedsummary["sorensonabund"] = "sorensonabund";
304 sharedsummary["jclass"] = "jclass";
305 sharedsummary["sorclass"] = "sorclass";
306 sharedsummary["jest"] = "jest";
307 sharedsummary["sorest"] = "sorest";
308 sharedsummary["thetayc"] = "thetayc";
309 sharedsummary["thetan"] = "thetan";
310 sharedsummary["kstest"] = "kstest";
311 sharedsummary["bdiversity"] = "bdiversity";
312 sharedsummary["sharednseqs"] = "sharednseqs";
313 sharedsummary["ochiai"] = "ochiai";
314 sharedsummary["anderberg"] = "anderberg";
315 sharedsummary["kulczynski"] = "kulczynski";
316 sharedsummary["kulczynskicody"] = "kulczynskicody";
317 sharedsummary["lennon"] = "lennon";
318 sharedsummary["morisitahorn"] = "morisitahorn";
319 sharedsummary["braycurtis"] = "braycurtis";
320 sharedsummary["default"] = "default";
322 catch(exception& e) {
323 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
327 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
333 /********************************************************************/
335 void ValidCalculators::initialSharedRarefact() {
337 sharedrarefaction["sharedobserved"] = "sharedobserved";
338 sharedrarefaction["sharednseqs"] = "sharednseqs";
339 sharedrarefaction["default"] = "default";
341 catch(exception& e) {
342 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
346 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
352 /********************************************************************/
353 void ValidCalculators::initialVennSingle() {
355 vennsingle["sobs"] = "sobs";
356 vennsingle["chao"] = "chao";
357 vennsingle["ace"] = "ace";
358 vennsingle["jack"] = "jack";
359 vennsingle["default"] = "default";
361 catch(exception& e) {
362 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
366 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
371 /********************************************************************/
372 void ValidCalculators::initialVennShared() {
374 vennshared["sharedsobs"] = "sharedsobs";
375 vennshared["sharedchao"] = "sharedchao";
376 vennshared["sharedace"] = "sharedace";
377 vennshared["default"] = "default";
379 catch(exception& e) {
380 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
384 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
389 /********************************************************************/
390 void ValidCalculators::initialTreeGroups() {
392 treegroup["jabund"] = "jabund";
393 treegroup["sorensonabund"] = "sorensonabund";
394 treegroup["jclass"] = "jclass";
395 treegroup["sorclass"] = "sorclass";
396 treegroup["jest"] = "jest";
397 treegroup["sorest"] = "sorest";
398 treegroup["thetayc"] = "thetayc";
399 treegroup["thetan"] = "thetan";
400 treegroup["morisitahorn"] = "morisitahorn";
402 catch(exception& e) {
403 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
407 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
411 /********************************************************************/
412 void ValidCalculators::initialBoot() {
414 boot["jabund"] = "jabund";
415 boot["sorensonabund"] = "sorensonabund";
416 boot["jclass"] = "jclass";
417 boot["sorclass"] = "orclass";
418 boot["jest"] = "jest";
419 boot["sorest"] = "sorest";
420 boot["thetayc"] = "thetayc";
421 boot["thetan"] = "thetan";
422 boot["morisitahorn"] = "morisitahorn";
424 catch(exception& e) {
425 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
429 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
434 /********************************************************************/
435 void ValidCalculators::printCalc(string parameter, ostream& out) {
437 out << "The available estimators for calc are ";
438 //are you looking for a calculator for a single parameter
439 if (parameter == "single") {
440 for (it = single.begin(); it != single.end(); it++) {
441 out << it->first << ", ";
443 //are you looking for a calculator for a shared parameter
444 }else if (parameter == "shared") {
445 for (it = shared.begin(); it != shared.end(); it++) {
446 out << it->first << ", ";
448 //are you looking for a calculator for a rarefaction parameter
449 }else if (parameter == "rarefaction") {
450 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
451 out << it->first << ", ";
453 //are you looking for a calculator for a summary parameter
454 }else if (parameter == "summary") {
455 for (it = summary.begin(); it != summary.end(); it++) {
456 out << it->first << ", ";
458 //are you looking for a calculator for a sharedsummary parameter
459 }else if (parameter == "sharedsummary") {
460 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
461 out << it->first << ", ";
463 }else if (parameter == "sharedrarefaction") {
464 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
465 out << it->first << ", ";
467 }else if (parameter == "vennsingle") {
468 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
469 out << it->first << ", ";
471 }else if (parameter == "vennshared") {
472 for (it = vennshared.begin(); it != vennshared.end(); it++) {
473 out << it->first << ", ";
475 }else if (parameter == "treegroup") {
476 for (it = treegroup.begin(); it != treegroup.end(); it++) {
477 out << it->first << ", ";
479 }else if (parameter == "boot") {
480 for (it = boot.begin(); it != boot.end(); it++) {
481 out << it->first << ", ";
486 catch(exception& e) {
487 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
491 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
496 /********************************************************************/