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["goodscoverage"] = "goodscoverage";
190 single["nseqs"] = "nseqs";
191 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["sorabund"] = "sorabund";
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["whittaker"] = "whittaker";
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["logseries"] = "logseries";
280 summary["qstat"] = "qstat";
281 summary["bstick"] = "bstick";
282 summary["nseqs"] = "nseqs";
283 summary["goodscoverage"]= "goodscoverage";
284 summary["coverage"] = "coverage";
285 summary["default"] = "default";
287 catch(exception& e) {
288 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
292 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
297 /********************************************************************/
298 void ValidCalculators::initialSharedSummary() {
300 sharedsummary["sharedsobs"] = "sharedsobs";
301 sharedsummary["sharedchao"] = "sharedchao";
302 sharedsummary["sharedace"] = "sharedace";
303 sharedsummary["jabund"] = "jabund";
304 sharedsummary["sorabund"] = "sorabund";
305 sharedsummary["jclass"] = "jclass";
306 sharedsummary["sorclass"] = "sorclass";
307 sharedsummary["jest"] = "jest";
308 sharedsummary["sorest"] = "sorest";
309 sharedsummary["thetayc"] = "thetayc";
310 sharedsummary["thetan"] = "thetan";
311 sharedsummary["kstest"] = "kstest";
312 sharedsummary["whittaker"] = "whittaker";
313 sharedsummary["sharednseqs"] = "sharednseqs";
314 sharedsummary["ochiai"] = "ochiai";
315 sharedsummary["anderberg"] = "anderberg";
316 sharedsummary["kulczynski"] = "kulczynski";
317 sharedsummary["kulczynskicody"] = "kulczynskicody";
318 sharedsummary["lennon"] = "lennon";
319 sharedsummary["morisitahorn"] = "morisitahorn";
320 sharedsummary["braycurtis"] = "braycurtis";
321 sharedsummary["default"] = "default";
323 catch(exception& e) {
324 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
328 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
334 /********************************************************************/
336 void ValidCalculators::initialSharedRarefact() {
338 sharedrarefaction["sharedobserved"] = "sharedobserved";
339 sharedrarefaction["sharednseqs"] = "sharednseqs";
340 sharedrarefaction["default"] = "default";
342 catch(exception& e) {
343 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
347 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
353 /********************************************************************/
354 void ValidCalculators::initialVennSingle() {
356 vennsingle["sobs"] = "sobs";
357 vennsingle["chao"] = "chao";
358 vennsingle["ace"] = "ace";
359 vennsingle["jack"] = "jack";
360 vennsingle["default"] = "default";
362 catch(exception& e) {
363 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
367 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
372 /********************************************************************/
373 void ValidCalculators::initialVennShared() {
375 vennshared["sharedsobs"] = "sharedsobs";
376 vennshared["sharedchao"] = "sharedchao";
377 vennshared["sharedace"] = "sharedace";
378 vennshared["default"] = "default";
380 catch(exception& e) {
381 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
385 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
390 /********************************************************************/
391 void ValidCalculators::initialTreeGroups() {
393 treegroup["jabund"] = "jabund";
394 treegroup["sorabund"] = "sorabund";
395 treegroup["jclass"] = "jclass";
396 treegroup["sorclass"] = "sorclass";
397 treegroup["jest"] = "jest";
398 treegroup["sorest"] = "sorest";
399 treegroup["thetayc"] = "thetayc";
400 treegroup["thetan"] = "thetan";
401 treegroup["morisitahorn"] = "morisitahorn";
402 treegroup["braycurtis"] = "braycurtis";
404 catch(exception& e) {
405 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
409 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
413 /********************************************************************/
414 void ValidCalculators::initialBoot() {
416 boot["jabund"] = "jabund";
417 boot["sorabund"] = "sorabund";
418 boot["jclass"] = "jclass";
419 boot["sorclass"] = "orclass";
420 boot["jest"] = "jest";
421 boot["sorest"] = "sorest";
422 boot["thetayc"] = "thetayc";
423 boot["thetan"] = "thetan";
424 boot["morisitahorn"] = "morisitahorn";
425 boot["braycurtis"] = "braycurtis";
427 catch(exception& e) {
428 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
432 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
437 /********************************************************************/
438 void ValidCalculators::printCalc(string parameter, ostream& out) {
440 out << "The available estimators for calc are ";
441 //are you looking for a calculator for a single parameter
442 if (parameter == "single") {
443 for (it = single.begin(); it != single.end(); it++) {
444 out << it->first << ", ";
446 //are you looking for a calculator for a shared parameter
447 }else if (parameter == "shared") {
448 for (it = shared.begin(); it != shared.end(); it++) {
449 out << it->first << ", ";
451 //are you looking for a calculator for a rarefaction parameter
452 }else if (parameter == "rarefaction") {
453 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
454 out << it->first << ", ";
456 //are you looking for a calculator for a summary parameter
457 }else if (parameter == "summary") {
458 for (it = summary.begin(); it != summary.end(); it++) {
459 out << it->first << ", ";
461 //are you looking for a calculator for a sharedsummary parameter
462 }else if (parameter == "sharedsummary") {
463 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
464 out << it->first << ", ";
466 }else if (parameter == "sharedrarefaction") {
467 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
468 out << it->first << ", ";
470 }else if (parameter == "vennsingle") {
471 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
472 out << it->first << ", ";
474 }else if (parameter == "vennshared") {
475 for (it = vennshared.begin(); it != vennshared.end(); it++) {
476 out << it->first << ", ";
478 }else if (parameter == "treegroup") {
479 for (it = treegroup.begin(); it != treegroup.end(); it++) {
480 out << it->first << ", ";
482 }else if (parameter == "boot") {
483 for (it = boot.begin(); it != boot.end(); it++) {
484 out << it->first << ", ";
489 catch(exception& e) {
490 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
494 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
499 /********************************************************************/