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["geom"] = "geom";
186 single["logsd"] = "logsd";
187 single["qstat"] = "qstat";
188 single["bstick"] = "bstick";
189 single["nseqs"] = "nseqs";
190 single["default"] = "default";
192 catch(exception& e) {
193 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
197 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
202 /********************************************************************/
203 void ValidCalculators::initialShared() {
205 shared["sharedsobs"] = "sharedsobs";
206 shared["sharedchao"] = "sharedchao";
207 shared["sharedace"] = "sharedace";
208 shared["jabund"] = "jabund";
209 shared["sorensonabund"] = "sorensonabund";
210 shared["jclass"] = "jclass";
211 shared["sorclass"] = "sorclass";
212 shared["jest"] = "jest";
213 shared["sorest"] = "sorest";
214 shared["thetayc"] = "thetayc";
215 shared["thetan"] = "thetan";
216 shared["kstest"] = "kstest";
217 shared["bdiversity"] = "bdiversity";
218 shared["sharednseqs"] = "sharednseqs";
219 shared["ochiai"] = "ochiai";
220 shared["anderberg"] = "anderberg";
221 shared["kulczynski"] = "kulczynski";
222 shared["kulczynskicody"] = "kulczynskicody";
223 shared["lennon"] = "lennon";
224 shared["morisitahorn"] = "morisitahorn";
225 shared["braycurtis"] = "braycurtis";
226 shared["default"] = "default";
228 catch(exception& e) {
229 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
233 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
238 /********************************************************************/
239 void ValidCalculators::initialRarefaction() {
241 rarefaction["sobs"] = "sobs";
242 rarefaction["chao"] = "chao";
243 rarefaction["ace"] = "ace";
244 rarefaction["jack"] = "jack";
245 rarefaction["shannon"] = "shannon";
246 rarefaction["npshannon"] = "npshannon";
247 rarefaction["simpson"] = "simpson";
248 rarefaction["bootstrap"] = "bootstrap";
249 rarefaction["nseqs"] = "nseqs";
250 rarefaction["default"] = "default";
252 catch(exception& e) {
253 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
257 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
262 /********************************************************************/
264 void ValidCalculators::initialSummary() {
266 summary["sobs"] = "sobs";
267 summary["chao"] = "chao";
268 summary["ace"] = "ace";
269 summary["jack"] = "jack";
270 summary["shannon"] = "shannon";
271 summary["npshannon"] = "npshannon";
272 summary["simpson"] = "simpson";
273 summary["bergerparker"] = "bergerparker";
274 summary["geom"] = "geom";
275 summary["bootstrap"] = "bootstrap";
276 summary["logsd"] = "logsd";
277 summary["qstat"] = "qstat";
278 summary["bstick"] = "bstick";
279 summary["nseqs"] = "nseqs";
280 summary["default"] = "default";
282 catch(exception& e) {
283 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
287 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
292 /********************************************************************/
293 void ValidCalculators::initialSharedSummary() {
295 sharedsummary["sharedsobs"] = "sharedsobs";
296 sharedsummary["sharedchao"] = "sharedchao";
297 sharedsummary["sharedace"] = "sharedace";
298 sharedsummary["jabund"] = "jabund";
299 sharedsummary["sorensonabund"] = "sorensonabund";
300 sharedsummary["jclass"] = "jclass";
301 sharedsummary["sorclass"] = "sorclass";
302 sharedsummary["jest"] = "jest";
303 sharedsummary["sorest"] = "sorest";
304 sharedsummary["thetayc"] = "thetayc";
305 sharedsummary["thetan"] = "thetan";
306 sharedsummary["kstest"] = "kstest";
307 sharedsummary["bdiversity"] = "bdiversity";
308 sharedsummary["sharednseqs"] = "sharednseqs";
309 sharedsummary["ochiai"] = "ochiai";
310 sharedsummary["anderberg"] = "anderberg";
311 sharedsummary["kulczynski"] = "kulczynski";
312 sharedsummary["kulczynskicody"] = "kulczynskicody";
313 sharedsummary["lennon"] = "lennon";
314 sharedsummary["morisitahorn"] = "morisitahorn";
315 sharedsummary["braycurtis"] = "braycurtis";
316 sharedsummary["default"] = "default";
318 catch(exception& e) {
319 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
323 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
329 /********************************************************************/
331 void ValidCalculators::initialSharedRarefact() {
333 sharedrarefaction["sharedobserved"] = "sharedobserved";
334 sharedrarefaction["sharednseqs"] = "sharednseqs";
335 sharedrarefaction["default"] = "default";
337 catch(exception& e) {
338 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
342 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
348 /********************************************************************/
349 void ValidCalculators::initialVennSingle() {
351 vennsingle["sobs"] = "sobs";
352 vennsingle["chao"] = "chao";
353 vennsingle["ace"] = "ace";
354 vennsingle["jack"] = "jack";
355 vennsingle["default"] = "default";
357 catch(exception& e) {
358 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
362 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
367 /********************************************************************/
368 void ValidCalculators::initialVennShared() {
370 vennshared["sharedsobs"] = "sharedsobs";
371 vennshared["sharedchao"] = "sharedchao";
372 vennshared["sharedace"] = "sharedace";
373 vennshared["default"] = "default";
375 catch(exception& e) {
376 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
380 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
385 /********************************************************************/
386 void ValidCalculators::initialTreeGroups() {
388 treegroup["jabund"] = "jabund";
389 treegroup["sorensonabund"] = "sorensonabund";
390 treegroup["jclass"] = "jclass";
391 treegroup["sorclass"] = "sorclass";
392 treegroup["jest"] = "jest";
393 treegroup["sorest"] = "sorest";
394 treegroup["thetayc"] = "thetayc";
395 treegroup["thetan"] = "thetan";
396 treegroup["morisitahorn"] = "morisitahorn";
398 catch(exception& e) {
399 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
403 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
407 /********************************************************************/
408 void ValidCalculators::initialBoot() {
410 boot["jabund"] = "jabund";
411 boot["sorensonabund"] = "sorensonabund";
412 boot["jclass"] = "jclass";
413 boot["sorclass"] = "orclass";
414 boot["jest"] = "jest";
415 boot["sorest"] = "sorest";
416 boot["thetayc"] = "thetayc";
417 boot["thetan"] = "thetan";
418 boot["morisitahorn"] = "morisitahorn";
420 catch(exception& e) {
421 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
425 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
430 /********************************************************************/
431 void ValidCalculators::printCalc(string parameter, ostream& out) {
433 out << "The available estimators for calc are ";
434 //are you looking for a calculator for a single parameter
435 if (parameter == "single") {
436 for (it = single.begin(); it != single.end(); it++) {
437 out << it->first << ", ";
439 //are you looking for a calculator for a shared parameter
440 }else if (parameter == "shared") {
441 for (it = shared.begin(); it != shared.end(); it++) {
442 out << it->first << ", ";
444 //are you looking for a calculator for a rarefaction parameter
445 }else if (parameter == "rarefaction") {
446 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
447 out << it->first << ", ";
449 //are you looking for a calculator for a summary parameter
450 }else if (parameter == "summary") {
451 for (it = summary.begin(); it != summary.end(); it++) {
452 out << it->first << ", ";
454 //are you looking for a calculator for a sharedsummary parameter
455 }else if (parameter == "sharedsummary") {
456 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
457 out << it->first << ", ";
459 }else if (parameter == "sharedrarefaction") {
460 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
461 out << it->first << ", ";
463 }else if (parameter == "vennsingle") {
464 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
465 out << it->first << ", ";
467 }else if (parameter == "vennshared") {
468 for (it = vennshared.begin(); it != vennshared.end(); it++) {
469 out << it->first << ", ";
471 }else if (parameter == "treegroup") {
472 for (it = treegroup.begin(); it != treegroup.end(); it++) {
473 out << it->first << ", ";
475 }else if (parameter == "boot") {
476 for (it = boot.begin(); it != boot.end(); it++) {
477 out << it->first << ", ";
482 catch(exception& e) {
483 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
487 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
492 /********************************************************************/