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["shen"] = "shen";
208 single["default"] = "default";
210 catch(exception& e) {
211 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
215 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
220 /********************************************************************/
221 void ValidCalculators::initialShared() {
223 shared["sharedsobs"] = "sharedsobs";
224 shared["sharedchao"] = "sharedchao";
225 shared["sharedace"] = "sharedace";
226 shared["jabund"] = "jabund";
227 shared["sorabund"] = "sorabund";
228 shared["jclass"] = "jclass";
229 shared["sorclass"] = "sorclass";
230 shared["jest"] = "jest";
231 shared["sorest"] = "sorest";
232 shared["thetayc"] = "thetayc";
233 shared["thetan"] = "thetan";
234 shared["kstest"] = "kstest";
235 shared["whittaker"] = "whittaker";
236 shared["sharednseqs"] = "sharednseqs";
237 shared["ochiai"] = "ochiai";
238 shared["anderberg"] = "anderberg";
239 shared["kulczynski"] = "kulczynski";
240 shared["kulczynskicody"] = "kulczynskicody";
241 shared["lennon"] = "lennon";
242 shared["morisitahorn"] = "morisitahorn";
243 shared["braycurtis"] = "braycurtis";
244 shared["default"] = "default";
246 catch(exception& e) {
247 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
251 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
256 /********************************************************************/
257 void ValidCalculators::initialRarefaction() {
259 rarefaction["sobs"] = "sobs";
260 rarefaction["chao"] = "chao";
261 rarefaction["ace"] = "ace";
262 rarefaction["jack"] = "jack";
263 rarefaction["shannon"] = "shannon";
264 rarefaction["npshannon"] = "npshannon";
265 rarefaction["simpson"] = "simpson";
266 rarefaction["bootstrap"] = "bootstrap";
267 rarefaction["nseqs"] = "nseqs";
268 rarefaction["coverage"] = "coverage";
269 rarefaction["default"] = "default";
271 catch(exception& e) {
272 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
276 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
281 /********************************************************************/
283 void ValidCalculators::initialSummary() {
285 summary["sobs"] = "sobs";
286 summary["chao"] = "chao";
287 summary["ace"] = "ace";
288 summary["jack"] = "jack";
289 summary["shannon"] = "shannon";
290 summary["npshannon"] = "npshannon";
291 summary["simpson"] = "simpson";
292 summary["bergerparker"] = "bergerparker";
293 summary["geometric"] = "geometric";
294 summary["bootstrap"] = "bootstrap";
295 summary["logseries"] = "logseries";
296 summary["qstat"] = "qstat";
297 summary["bstick"] = "bstick";
298 summary["nseqs"] = "nseqs";
299 summary["goodscoverage"]= "goodscoverage";
300 summary["coverage"] = "coverage";
301 summary["efron"] = "efron";
302 summary["boneh"] = "boneh";
303 summary["solow"] = "solow";
304 summary["shen"] = "shen";
305 summary["default"] = "default";
307 catch(exception& e) {
308 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
312 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
317 /********************************************************************/
318 void ValidCalculators::initialSharedSummary() {
320 sharedsummary["sharedsobs"] = "sharedsobs";
321 sharedsummary["sharedchao"] = "sharedchao";
322 sharedsummary["sharedace"] = "sharedace";
323 sharedsummary["jabund"] = "jabund";
324 sharedsummary["sorabund"] = "sorabund";
325 sharedsummary["jclass"] = "jclass";
326 sharedsummary["sorclass"] = "sorclass";
327 sharedsummary["jest"] = "jest";
328 sharedsummary["sorest"] = "sorest";
329 sharedsummary["thetayc"] = "thetayc";
330 sharedsummary["thetan"] = "thetan";
331 sharedsummary["kstest"] = "kstest";
332 sharedsummary["whittaker"] = "whittaker";
333 sharedsummary["sharednseqs"] = "sharednseqs";
334 sharedsummary["ochiai"] = "ochiai";
335 sharedsummary["anderberg"] = "anderberg";
336 sharedsummary["kulczynski"] = "kulczynski";
337 sharedsummary["kulczynskicody"] = "kulczynskicody";
338 sharedsummary["lennon"] = "lennon";
339 sharedsummary["morisitahorn"] = "morisitahorn";
340 sharedsummary["braycurtis"] = "braycurtis";
341 sharedsummary["default"] = "default";
343 catch(exception& e) {
344 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
348 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
354 /********************************************************************/
356 void ValidCalculators::initialSharedRarefact() {
358 sharedrarefaction["sharedobserved"] = "sharedobserved";
359 sharedrarefaction["sharednseqs"] = "sharednseqs";
360 sharedrarefaction["default"] = "default";
362 catch(exception& e) {
363 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
367 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
373 /********************************************************************/
374 void ValidCalculators::initialVennSingle() {
376 vennsingle["sobs"] = "sobs";
377 vennsingle["chao"] = "chao";
378 vennsingle["ace"] = "ace";
379 vennsingle["jack"] = "jack";
380 vennsingle["default"] = "default";
382 catch(exception& e) {
383 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
387 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
392 /********************************************************************/
393 void ValidCalculators::initialVennShared() {
395 vennshared["sharedsobs"] = "sharedsobs";
396 vennshared["sharedchao"] = "sharedchao";
397 vennshared["sharedace"] = "sharedace";
398 vennshared["default"] = "default";
400 catch(exception& e) {
401 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
405 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
410 /********************************************************************/
411 void ValidCalculators::initialTreeGroups() {
413 treegroup["jabund"] = "jabund";
414 treegroup["sorabund"] = "sorabund";
415 treegroup["jclass"] = "jclass";
416 treegroup["sorclass"] = "sorclass";
417 treegroup["jest"] = "jest";
418 treegroup["sorest"] = "sorest";
419 treegroup["thetayc"] = "thetayc";
420 treegroup["thetan"] = "thetan";
421 treegroup["morisitahorn"] = "morisitahorn";
422 treegroup["braycurtis"] = "braycurtis";
424 catch(exception& e) {
425 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
429 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
433 /********************************************************************/
434 void ValidCalculators::initialBoot() {
436 boot["jabund"] = "jabund";
437 boot["sorabund"] = "sorabund";
438 boot["jclass"] = "jclass";
439 boot["sorclass"] = "orclass";
440 boot["jest"] = "jest";
441 boot["sorest"] = "sorest";
442 boot["thetayc"] = "thetayc";
443 boot["thetan"] = "thetan";
444 boot["morisitahorn"] = "morisitahorn";
445 boot["braycurtis"] = "braycurtis";
447 catch(exception& e) {
448 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
452 cout << "An unknown error has occurred in the ValidCalculator class function initialBoot. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
456 /********************************************************************/
457 void ValidCalculators::initialDistance() {
459 distance["nogaps"] = "nogaps";
460 distance["eachgap"] = "eachgap";
461 distance["onegap"] = "onegap";
463 catch(exception& e) {
464 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
468 cout << "An unknown error has occurred in the ValidCalculator class function initialDistance. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
473 /********************************************************************/
474 void ValidCalculators::printCalc(string parameter, ostream& out) {
476 out << "The available estimators for calc are ";
477 //are you looking for a calculator for a single parameter
478 if (parameter == "single") {
479 for (it = single.begin(); it != single.end(); it++) {
480 out << it->first << ", ";
482 //are you looking for a calculator for a shared parameter
483 }else if (parameter == "shared") {
484 for (it = shared.begin(); it != shared.end(); it++) {
485 out << it->first << ", ";
487 //are you looking for a calculator for a rarefaction parameter
488 }else if (parameter == "rarefaction") {
489 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
490 out << it->first << ", ";
492 //are you looking for a calculator for a summary parameter
493 }else if (parameter == "summary") {
494 for (it = summary.begin(); it != summary.end(); it++) {
495 out << it->first << ", ";
497 //are you looking for a calculator for a sharedsummary parameter
498 }else if (parameter == "sharedsummary") {
499 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
500 out << it->first << ", ";
502 }else if (parameter == "sharedrarefaction") {
503 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
504 out << it->first << ", ";
506 }else if (parameter == "vennsingle") {
507 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
508 out << it->first << ", ";
510 }else if (parameter == "vennshared") {
511 for (it = vennshared.begin(); it != vennshared.end(); it++) {
512 out << it->first << ", ";
514 }else if (parameter == "treegroup") {
515 for (it = treegroup.begin(); it != treegroup.end(); it++) {
516 out << it->first << ", ";
518 }else if (parameter == "boot") {
519 for (it = boot.begin(); it != boot.end(); it++) {
520 out << it->first << ", ";
522 }else if (parameter == "distance") {
523 for (it = distance.begin(); it != distance.end(); it++) {
524 out << it->first << ", ";
530 catch(exception& e) {
531 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
535 cout << "An unknown error has occurred in the ValidCalculator class function printCalc. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
540 /********************************************************************/