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();
28 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
32 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
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 cout << 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 cout << it->first << ", ";
57 //are you looking for a calculator for a shared parameter
58 }else if (parameter == "shared") {
60 if ((shared.find(calculator)) != (shared.end())) {
63 cout << 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 cout << it->first << ", ";
69 //are you looking for a calculator for a rarefaction parameter
70 }else if (parameter == "rarefaction") {
72 if ((rarefaction.find(calculator)) != (rarefaction.end())) {
75 cout << 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 cout << it->first << ", ";
81 //are you looking for a calculator for a summary parameter
82 }else if (parameter == "summary") {
84 if ((summary.find(calculator)) != (summary.end())) {
87 cout << 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 cout << it->first << ", ";
93 //are you looking for a calculator for a sharedsummary parameter
94 }else if (parameter == "sharedsummary") {
96 if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
99 cout << 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 cout << it->first << ", ";
105 }else if (parameter == "sharedrarefaction") {
107 if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
110 cout << 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 cout << it->first << ", ";
116 }else if (parameter == "vennsingle") {
118 if ((vennsingle.find(calculator)) != (vennsingle.end())) {
121 cout << 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 cout << it->first << ", ";
127 }else if (parameter == "vennshared") {
129 if ((vennshared.find(calculator)) != (vennshared.end())) {
132 cout << 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 cout << it->first << ", ";
138 }else if (parameter == "treegroup") {
140 if ((treegroup.find(calculator)) != (treegroup.end())) {
143 cout << 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 cout << it->first << ", ";
149 }else if (parameter == "boot") {
151 if ((boot.find(calculator)) != (boot.end())) {
154 cout << calculator << " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ";
155 for (it = boot.begin(); it != boot.end(); it++) {
156 cout << it->first << ", ";
160 }else if (parameter == "distance") {
162 if ((distance.find(calculator)) != (distance.end())) {
165 cout << calculator << " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ";
166 for (it = distance.begin(); it != distance.end(); it++) {
167 cout << it->first << ", ";
171 //not a valid parameter
172 }else { return false; }
175 catch(exception& e) {
176 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
180 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
185 /********************************************************************/
186 void ValidCalculators::initialSingle() {
188 single["sobs"] = "sobs";
189 single["chao"] = "chao";
190 single["ace"] = "ace";
191 single["jack"] = "jack";
192 single["shannon"] = "shannon";
193 single["npshannon"] = "npshannon";
194 single["simpson"] = "simpson";
195 single["bergerparker"] = "bergerparker";
196 single["bootstrap"] = "bootstrap";
197 single["geometric"] = "geometric";
198 single["logseries"] = "logseries";
199 single["qstat"] = "qstat";
200 single["bstick"] = "bstick";
201 single["goodscoverage"] = "goodscoverage";
202 single["nseqs"] = "nseqs";
203 single["coverage"] = "coverage";
204 single["efron"] = "efron";
205 single["boneh"] = "boneh";
206 single["solow"] = "solow";
207 single["default"] = "default";
209 catch(exception& e) {
210 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
214 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
219 /********************************************************************/
220 void ValidCalculators::initialShared() {
222 shared["sharedsobs"] = "sharedsobs";
223 shared["sharedchao"] = "sharedchao";
224 shared["sharedace"] = "sharedace";
225 shared["jabund"] = "jabund";
226 shared["sorabund"] = "sorabund";
227 shared["jclass"] = "jclass";
228 shared["sorclass"] = "sorclass";
229 shared["jest"] = "jest";
230 shared["sorest"] = "sorest";
231 shared["thetayc"] = "thetayc";
232 shared["thetan"] = "thetan";
233 shared["kstest"] = "kstest";
234 shared["whittaker"] = "whittaker";
235 shared["sharednseqs"] = "sharednseqs";
236 shared["ochiai"] = "ochiai";
237 shared["anderberg"] = "anderberg";
238 shared["kulczynski"] = "kulczynski";
239 shared["kulczynskicody"] = "kulczynskicody";
240 shared["lennon"] = "lennon";
241 shared["morisitahorn"] = "morisitahorn";
242 shared["braycurtis"] = "braycurtis";
243 shared["default"] = "default";
245 catch(exception& e) {
246 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
250 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
255 /********************************************************************/
256 void ValidCalculators::initialRarefaction() {
258 rarefaction["sobs"] = "sobs";
259 rarefaction["chao"] = "chao";
260 rarefaction["ace"] = "ace";
261 rarefaction["jack"] = "jack";
262 rarefaction["shannon"] = "shannon";
263 rarefaction["npshannon"] = "npshannon";
264 rarefaction["simpson"] = "simpson";
265 rarefaction["bootstrap"] = "bootstrap";
266 rarefaction["nseqs"] = "nseqs";
267 rarefaction["coverage"] = "coverage";
268 rarefaction["default"] = "default";
270 catch(exception& e) {
271 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
275 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
280 /********************************************************************/
282 void ValidCalculators::initialSummary() {
284 summary["sobs"] = "sobs";
285 summary["chao"] = "chao";
286 summary["ace"] = "ace";
287 summary["jack"] = "jack";
288 summary["shannon"] = "shannon";
289 summary["npshannon"] = "npshannon";
290 summary["simpson"] = "simpson";
291 summary["bergerparker"] = "bergerparker";
292 summary["geometric"] = "geometric";
293 summary["bootstrap"] = "bootstrap";
294 summary["logseries"] = "logseries";
295 summary["qstat"] = "qstat";
296 summary["bstick"] = "bstick";
297 summary["nseqs"] = "nseqs";
298 summary["goodscoverage"]= "goodscoverage";
299 summary["coverage"] = "coverage";
300 summary["efron"] = "efron";
301 summary["boneh"] = "boneh";
302 summary["solow"] = "solow";
303 summary["default"] = "default";
305 catch(exception& e) {
306 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
310 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
315 /********************************************************************/
316 void ValidCalculators::initialSharedSummary() {
318 sharedsummary["sharedsobs"] = "sharedsobs";
319 sharedsummary["sharedchao"] = "sharedchao";
320 sharedsummary["sharedace"] = "sharedace";
321 sharedsummary["jabund"] = "jabund";
322 sharedsummary["sorabund"] = "sorabund";
323 sharedsummary["jclass"] = "jclass";
324 sharedsummary["sorclass"] = "sorclass";
325 sharedsummary["jest"] = "jest";
326 sharedsummary["sorest"] = "sorest";
327 sharedsummary["thetayc"] = "thetayc";
328 sharedsummary["thetan"] = "thetan";
329 sharedsummary["kstest"] = "kstest";
330 sharedsummary["whittaker"] = "whittaker";
331 sharedsummary["sharednseqs"] = "sharednseqs";
332 sharedsummary["ochiai"] = "ochiai";
333 sharedsummary["anderberg"] = "anderberg";
334 sharedsummary["kulczynski"] = "kulczynski";
335 sharedsummary["kulczynskicody"] = "kulczynskicody";
336 sharedsummary["lennon"] = "lennon";
337 sharedsummary["morisitahorn"] = "morisitahorn";
338 sharedsummary["braycurtis"] = "braycurtis";
339 sharedsummary["default"] = "default";
341 catch(exception& e) {
342 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
346 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
352 /********************************************************************/
354 void ValidCalculators::initialSharedRarefact() {
356 sharedrarefaction["sharedobserved"] = "sharedobserved";
357 sharedrarefaction["sharednseqs"] = "sharednseqs";
358 sharedrarefaction["default"] = "default";
360 catch(exception& e) {
361 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
365 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
371 /********************************************************************/
372 void ValidCalculators::initialVennSingle() {
374 vennsingle["sobs"] = "sobs";
375 vennsingle["chao"] = "chao";
376 vennsingle["ace"] = "ace";
377 vennsingle["jack"] = "jack";
378 vennsingle["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::initialVennShared() {
393 vennshared["sharedsobs"] = "sharedsobs";
394 vennshared["sharedchao"] = "sharedchao";
395 vennshared["sharedace"] = "sharedace";
396 vennshared["default"] = "default";
398 catch(exception& e) {
399 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
403 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
408 /********************************************************************/
409 void ValidCalculators::initialTreeGroups() {
411 treegroup["jabund"] = "jabund";
412 treegroup["sorabund"] = "sorabund";
413 treegroup["jclass"] = "jclass";
414 treegroup["sorclass"] = "sorclass";
415 treegroup["jest"] = "jest";
416 treegroup["sorest"] = "sorest";
417 treegroup["thetayc"] = "thetayc";
418 treegroup["thetan"] = "thetan";
419 treegroup["morisitahorn"] = "morisitahorn";
420 treegroup["braycurtis"] = "braycurtis";
422 catch(exception& e) {
423 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
427 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
431 /********************************************************************/
432 void ValidCalculators::initialBoot() {
434 boot["jabund"] = "jabund";
435 boot["sorabund"] = "sorabund";
436 boot["jclass"] = "jclass";
437 boot["sorclass"] = "orclass";
438 boot["jest"] = "jest";
439 boot["sorest"] = "sorest";
440 boot["thetayc"] = "thetayc";
441 boot["thetan"] = "thetan";
442 boot["morisitahorn"] = "morisitahorn";
443 boot["braycurtis"] = "braycurtis";
445 catch(exception& e) {
446 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
450 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
454 /********************************************************************/
455 void ValidCalculators::initialDistance() {
457 distance["nogaps"] = "nogaps";
458 distance["eachgap"] = "eachgap";
459 distance["onegap"] = "onegap";
461 catch(exception& e) {
462 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
466 cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
471 /********************************************************************/
472 void ValidCalculators::printCalc(string parameter, ostream& out) {
474 out << "The available estimators for calc are ";
475 //are you looking for a calculator for a single parameter
476 if (parameter == "single") {
477 for (it = single.begin(); it != single.end(); it++) {
478 out << it->first << ", ";
480 //are you looking for a calculator for a shared parameter
481 }else if (parameter == "shared") {
482 for (it = shared.begin(); it != shared.end(); it++) {
483 out << it->first << ", ";
485 //are you looking for a calculator for a rarefaction parameter
486 }else if (parameter == "rarefaction") {
487 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
488 out << it->first << ", ";
490 //are you looking for a calculator for a summary parameter
491 }else if (parameter == "summary") {
492 for (it = summary.begin(); it != summary.end(); it++) {
493 out << it->first << ", ";
495 //are you looking for a calculator for a sharedsummary parameter
496 }else if (parameter == "sharedsummary") {
497 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
498 out << it->first << ", ";
500 }else if (parameter == "sharedrarefaction") {
501 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
502 out << it->first << ", ";
504 }else if (parameter == "vennsingle") {
505 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
506 out << it->first << ", ";
508 }else if (parameter == "vennshared") {
509 for (it = vennshared.begin(); it != vennshared.end(); it++) {
510 out << it->first << ", ";
512 }else if (parameter == "treegroup") {
513 for (it = treegroup.begin(); it != treegroup.end(); it++) {
514 out << it->first << ", ";
516 }else if (parameter == "boot") {
517 for (it = boot.begin(); it != boot.end(); it++) {
518 out << it->first << ", ";
520 }else if (parameter == "distance") {
521 for (it = distance.begin(); it != distance.end(); it++) {
522 out << it->first << ", ";
528 catch(exception& e) {
529 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
533 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
538 /********************************************************************/