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["default"] = "default";
206 catch(exception& e) {
207 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
211 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
216 /********************************************************************/
217 void ValidCalculators::initialShared() {
219 shared["sharedsobs"] = "sharedsobs";
220 shared["sharedchao"] = "sharedchao";
221 shared["sharedace"] = "sharedace";
222 shared["jabund"] = "jabund";
223 shared["sorabund"] = "sorabund";
224 shared["jclass"] = "jclass";
225 shared["sorclass"] = "sorclass";
226 shared["jest"] = "jest";
227 shared["sorest"] = "sorest";
228 shared["thetayc"] = "thetayc";
229 shared["thetan"] = "thetan";
230 shared["kstest"] = "kstest";
231 shared["whittaker"] = "whittaker";
232 shared["sharednseqs"] = "sharednseqs";
233 shared["ochiai"] = "ochiai";
234 shared["anderberg"] = "anderberg";
235 shared["kulczynski"] = "kulczynski";
236 shared["kulczynskicody"] = "kulczynskicody";
237 shared["lennon"] = "lennon";
238 shared["morisitahorn"] = "morisitahorn";
239 shared["braycurtis"] = "braycurtis";
240 shared["default"] = "default";
242 catch(exception& e) {
243 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
247 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
252 /********************************************************************/
253 void ValidCalculators::initialRarefaction() {
255 rarefaction["sobs"] = "sobs";
256 rarefaction["chao"] = "chao";
257 rarefaction["ace"] = "ace";
258 rarefaction["jack"] = "jack";
259 rarefaction["shannon"] = "shannon";
260 rarefaction["npshannon"] = "npshannon";
261 rarefaction["simpson"] = "simpson";
262 rarefaction["bootstrap"] = "bootstrap";
263 rarefaction["nseqs"] = "nseqs";
264 rarefaction["coverage"] = "coverage";
265 rarefaction["default"] = "default";
267 catch(exception& e) {
268 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
272 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
277 /********************************************************************/
279 void ValidCalculators::initialSummary() {
281 summary["sobs"] = "sobs";
282 summary["chao"] = "chao";
283 summary["ace"] = "ace";
284 summary["jack"] = "jack";
285 summary["shannon"] = "shannon";
286 summary["npshannon"] = "npshannon";
287 summary["simpson"] = "simpson";
288 summary["bergerparker"] = "bergerparker";
289 summary["geometric"] = "geometric";
290 summary["bootstrap"] = "bootstrap";
291 summary["logseries"] = "logseries";
292 summary["qstat"] = "qstat";
293 summary["bstick"] = "bstick";
294 summary["nseqs"] = "nseqs";
295 summary["goodscoverage"]= "goodscoverage";
296 summary["coverage"] = "coverage";
297 summary["default"] = "default";
299 catch(exception& e) {
300 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
304 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
309 /********************************************************************/
310 void ValidCalculators::initialSharedSummary() {
312 sharedsummary["sharedsobs"] = "sharedsobs";
313 sharedsummary["sharedchao"] = "sharedchao";
314 sharedsummary["sharedace"] = "sharedace";
315 sharedsummary["jabund"] = "jabund";
316 sharedsummary["sorabund"] = "sorabund";
317 sharedsummary["jclass"] = "jclass";
318 sharedsummary["sorclass"] = "sorclass";
319 sharedsummary["jest"] = "jest";
320 sharedsummary["sorest"] = "sorest";
321 sharedsummary["thetayc"] = "thetayc";
322 sharedsummary["thetan"] = "thetan";
323 sharedsummary["kstest"] = "kstest";
324 sharedsummary["whittaker"] = "whittaker";
325 sharedsummary["sharednseqs"] = "sharednseqs";
326 sharedsummary["ochiai"] = "ochiai";
327 sharedsummary["anderberg"] = "anderberg";
328 sharedsummary["kulczynski"] = "kulczynski";
329 sharedsummary["kulczynskicody"] = "kulczynskicody";
330 sharedsummary["lennon"] = "lennon";
331 sharedsummary["morisitahorn"] = "morisitahorn";
332 sharedsummary["braycurtis"] = "braycurtis";
333 sharedsummary["default"] = "default";
335 catch(exception& e) {
336 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
340 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
346 /********************************************************************/
348 void ValidCalculators::initialSharedRarefact() {
350 sharedrarefaction["sharedobserved"] = "sharedobserved";
351 sharedrarefaction["sharednseqs"] = "sharednseqs";
352 sharedrarefaction["default"] = "default";
354 catch(exception& e) {
355 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
359 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
365 /********************************************************************/
366 void ValidCalculators::initialVennSingle() {
368 vennsingle["sobs"] = "sobs";
369 vennsingle["chao"] = "chao";
370 vennsingle["ace"] = "ace";
371 vennsingle["jack"] = "jack";
372 vennsingle["default"] = "default";
374 catch(exception& e) {
375 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
379 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
384 /********************************************************************/
385 void ValidCalculators::initialVennShared() {
387 vennshared["sharedsobs"] = "sharedsobs";
388 vennshared["sharedchao"] = "sharedchao";
389 vennshared["sharedace"] = "sharedace";
390 vennshared["default"] = "default";
392 catch(exception& e) {
393 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
397 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
402 /********************************************************************/
403 void ValidCalculators::initialTreeGroups() {
405 treegroup["jabund"] = "jabund";
406 treegroup["sorabund"] = "sorabund";
407 treegroup["jclass"] = "jclass";
408 treegroup["sorclass"] = "sorclass";
409 treegroup["jest"] = "jest";
410 treegroup["sorest"] = "sorest";
411 treegroup["thetayc"] = "thetayc";
412 treegroup["thetan"] = "thetan";
413 treegroup["morisitahorn"] = "morisitahorn";
414 treegroup["braycurtis"] = "braycurtis";
416 catch(exception& e) {
417 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
421 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
425 /********************************************************************/
426 void ValidCalculators::initialBoot() {
428 boot["jabund"] = "jabund";
429 boot["sorabund"] = "sorabund";
430 boot["jclass"] = "jclass";
431 boot["sorclass"] = "orclass";
432 boot["jest"] = "jest";
433 boot["sorest"] = "sorest";
434 boot["thetayc"] = "thetayc";
435 boot["thetan"] = "thetan";
436 boot["morisitahorn"] = "morisitahorn";
437 boot["braycurtis"] = "braycurtis";
439 catch(exception& e) {
440 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
444 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
448 /********************************************************************/
449 void ValidCalculators::initialDistance() {
451 distance["nogaps"] = "nogaps";
452 distance["eachgap"] = "eachgap";
453 distance["onegap"] = "onegap";
455 catch(exception& e) {
456 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
460 cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
465 /********************************************************************/
466 void ValidCalculators::printCalc(string parameter, ostream& out) {
468 out << "The available estimators for calc are ";
469 //are you looking for a calculator for a single parameter
470 if (parameter == "single") {
471 for (it = single.begin(); it != single.end(); it++) {
472 out << it->first << ", ";
474 //are you looking for a calculator for a shared parameter
475 }else if (parameter == "shared") {
476 for (it = shared.begin(); it != shared.end(); it++) {
477 out << it->first << ", ";
479 //are you looking for a calculator for a rarefaction parameter
480 }else if (parameter == "rarefaction") {
481 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
482 out << it->first << ", ";
484 //are you looking for a calculator for a summary parameter
485 }else if (parameter == "summary") {
486 for (it = summary.begin(); it != summary.end(); it++) {
487 out << it->first << ", ";
489 //are you looking for a calculator for a sharedsummary parameter
490 }else if (parameter == "sharedsummary") {
491 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
492 out << it->first << ", ";
494 }else if (parameter == "sharedrarefaction") {
495 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
496 out << it->first << ", ";
498 }else if (parameter == "vennsingle") {
499 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
500 out << it->first << ", ";
502 }else if (parameter == "vennshared") {
503 for (it = vennshared.begin(); it != vennshared.end(); it++) {
504 out << it->first << ", ";
506 }else if (parameter == "treegroup") {
507 for (it = treegroup.begin(); it != treegroup.end(); it++) {
508 out << it->first << ", ";
510 }else if (parameter == "boot") {
511 for (it = boot.begin(); it != boot.end(); it++) {
512 out << it->first << ", ";
514 }else if (parameter == "distance") {
515 for (it = distance.begin(); it != distance.end(); it++) {
516 out << it->first << ", ";
522 catch(exception& e) {
523 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
527 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
532 /********************************************************************/