]> git.donarmstrong.com Git - mothur.git/blob - validcalculator.cpp
Initial revision
[mothur.git] / validcalculator.cpp
1 /*
2  *  validcalculator.cpp
3  *  Dotur
4  *
5  *  Created by Sarah Westcott on 1/5/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "validcalculator.h"
11
12 /********************************************************************/
13 ValidCalculators::ValidCalculators() {
14         try {
15                  initialSingle();
16                  initialShared();
17                  initialRarefaction();
18                  initialSharedRarefact();
19                  initialSummary();
20                  initialSharedSummary();
21         }
22         catch(exception& e) {
23                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
24                 exit(1);
25         }
26         catch(...) {
27                 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
28                 exit(1);
29         }                
30 }
31
32 /********************************************************************/
33
34 ValidCalculators::~ValidCalculators() {}
35
36 /********************************************************************/
37
38 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
39         try {   
40                 //are you looking for a calculator for a single parameter
41                 if (parameter == "single") {
42                         //is it valid
43                         if ((single.find(calculator)) != (single.end())) {
44                                 return true;
45                         }else { cout << calculator << " is not a valid single estimator. Valid single estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
46                 //are you looking for a calculator for a shared parameter
47                 }else if (parameter == "shared") {
48                         //is it valid
49                         if ((shared.find(calculator)) != (shared.end())) {
50                                 return true;
51                         }else { cout << calculator << " is not a valid shared estimator.  Valid shared estimators are sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
52                 //are you looking for a calculator for a rarefaction parameter
53                 }else if (parameter == "rarefaction") {
54                         //is it valid
55                         if ((rarefaction.find(calculator)) != (rarefaction.end())) {
56                                 return true;
57                         }else { cout << calculator << " is not a valid rarefaction estimator. Valid rarefaction estimators are rarefaction-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson." << endl; return false; }
58                 //are you looking for a calculator for a summary parameter
59                 }else if (parameter == "summary") {
60                         //is it valid
61                         if ((summary.find(calculator)) != (summary.end())) {
62                                 return true;
63                         }else { cout << calculator << " is not a valid summary estimator. Valid summary estimators are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson." << endl; return false; }
64                 //are you looking for a calculator for a sharedsummary parameter
65                 }else if (parameter == "sharedsummary") {
66                         //is it valid
67                         if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
68                                 return true;
69                         }else { cout << calculator << " is not a valid sharedsummary estimator. Valid sharedsummary estimators are: sharedChao-sharedAce-sharedJabund-sharedSorensonAbund-sharedJclass-sharedSorClass-sharedJest-sharedSorEst-SharedThetaYC-SharedThetaN." << endl; return false; }
70
71                 }else if (parameter == "sharedrarefaction") {
72                         //is it valid
73                         if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
74                                 return true;
75                         }else { cout << calculator << " is not a valid sharedrarefaction estimator. Valid sharedrarefaction estimator is sharedobserved." << endl; return false; }
76                 //not a valid paramter
77                 }else { return false; }
78                 
79         }
80         catch(exception& e) {
81                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
82                 exit(1);
83         }
84         catch(...) {
85                 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
86                 exit(1);
87         }       
88 }
89
90 /********************************************************************/
91 void ValidCalculators::initialSingle() {
92         try {   
93         
94                 single["sobs"]  = "sobs";
95                 single["chao"]          = "chao";
96                 single["ace"]           = "ace";
97                 single["jack"]          = "jack";
98                 single["shannon"]       = "shannon";
99                 single["npshannon"]     = "npshannon";
100                 single["simpson"]       = "simpson";
101                 single["bootstrap"]     = "bootstrap";
102                 single["default"]       = "default";
103         }
104         catch(exception& e) {
105                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
106                 exit(1);
107         }
108         catch(...) {
109                 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
110                 exit(1);
111         }       
112 }
113
114 /********************************************************************/
115 void ValidCalculators::initialShared() {
116         try {   
117                 shared["sharedChao"]                    = "sharedChao";
118                 shared["sharedAce"]                             = "sharedAce";
119                 shared["sharedJabund"]                  = "sharedJabund";
120                 shared["sharedSorensonAbund"]   = "sharedSorensonAbund";
121                 shared["sharedJclass"]                  = "sharedJclass";
122                 shared["sharedSorClass"]                = "sharedSorClass";
123                 shared["sharedJest"]                    = "sharedJest";
124                 shared["sharedSorEst"]                  = "sharedSorEst";
125                 shared["SharedThetaYC"]                 = "SharedThetaYC";
126                 shared["SharedThetaN"]                  = "SharedThetaN";
127                 shared["default"]                   = "default";
128         }
129         catch(exception& e) {
130                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
131                 exit(1);
132         }
133         catch(...) {
134                 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
135                 exit(1);
136         }       
137 }
138
139 /********************************************************************/
140 void ValidCalculators::initialRarefaction() {
141         try {   
142                 rarefaction["sobs"]                     = "sobs";
143                 rarefaction["chao"]                     = "chao";
144                 rarefaction["ace"]                      = "ace";
145                 rarefaction["jack"]                     = "jack";
146                 rarefaction["shannon"]          = "shannon";
147                 rarefaction["npshannon"]        = "npshannon";
148                 rarefaction["simpson"]          = "simpson";
149                 rarefaction["bootstrap"]        = "bootstrap";
150                 rarefaction["default"]      = "default";
151         }
152         catch(exception& e) {
153                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
154                 exit(1);
155         }
156         catch(...) {
157                 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
158                 exit(1);
159         }       
160 }
161
162 /********************************************************************/
163
164 void ValidCalculators::initialSummary() {
165         try {   
166                 summary["sobs"]                 = "sobs";
167                 summary["chao"]                 = "chao";
168                 summary["ace"]                  = "ace";
169                 summary["jack"]                 = "jack";
170                 summary["shannon"]              = "shannon";
171                 summary["npshannon"]    = "npshannon";
172                 summary["simpson"]              = "simpson";
173                 summary["bootstrap"]    = "bootstrap";
174                 summary["default"]          = "default";
175         }
176         catch(exception& e) {
177                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
178                 exit(1);
179         }
180         catch(...) {
181                 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
182                 exit(1);
183         }       
184 }
185
186 /********************************************************************/
187 void ValidCalculators::initialSharedSummary() {
188         try {   
189                 sharedsummary["sharedChao"]                             = "sharedChao";
190                 sharedsummary["sharedAce"]                              = "sharedAce";
191                 sharedsummary["sharedJabund"]                   = "sharedJabund";
192                 sharedsummary["sharedSorensonAbund"]    = "sharedSorensonAbund";
193                 sharedsummary["sharedJclass"]                   = "sharedJclass";
194                 sharedsummary["sharedSorClass"]                 = "sharedSorClass";
195                 sharedsummary["sharedJest"]                             = "sharedJest";
196                 sharedsummary["sharedSorEst"]                   = "sharedSorEst";
197                 sharedsummary["SharedThetaYC"]                  = "SharedThetaYC";
198                 sharedsummary["SharedThetaN"]                   = "SharedThetaN";
199                 sharedsummary["default"]                                = "default";
200         }
201         catch(exception& e) {
202                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
203                 exit(1);
204         }
205         catch(...) {
206                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
207                 exit(1);
208         }       
209 }
210
211
212 /********************************************************************/
213
214 void ValidCalculators::initialSharedRarefact() {
215         try {   
216                 sharedrarefaction["sharedobserved"]     = "sharedobserved";
217                 sharedrarefaction["default"]        = "default";
218         }
219         catch(exception& e) {
220                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
221                 exit(1);
222         }
223         catch(...) {
224                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
225                 exit(1);
226         }       
227 }
228
229 /********************************************************************/
230
231
232