]> git.donarmstrong.com Git - mothur.git/blob - validcalculator.cpp
removed "shared" from some of the calculator names and classes
[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                  initialVennSingle();
22                  initialVennShared();
23                  initialTreeGroups();
24         }
25         catch(exception& e) {
26                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
27                 exit(1);
28         }
29         catch(...) {
30                 cout << "An unknown error has occurred in the ValidCalculator class function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
31                 exit(1);
32         }                
33 }
34
35 /********************************************************************/
36
37 ValidCalculators::~ValidCalculators() {}
38
39 /********************************************************************/
40
41 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
42         try {   
43                 //are you looking for a calculator for a single parameter
44                 if (parameter == "single") {
45                         //is it valid
46                         if ((single.find(calculator)) != (single.end())) {
47                                 return true;
48                         }else { 
49                                 cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
50                                 for (it = single.begin(); it != single.end(); it++) {
51                                         cout << it->first << ", ";
52                                 }
53                                 cout << endl;
54                                 return false; }
55                 //are you looking for a calculator for a shared parameter
56                 }else if (parameter == "shared") {
57                         //is it valid
58                         if ((shared.find(calculator)) != (shared.end())) {
59                                 return true;
60                         }else { 
61                                 cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ";
62                                 for (it = shared.begin(); it != shared.end(); it++) {
63                                         cout << it->first << ", ";
64                                 }
65                                 cout << endl;
66                                 return false; }
67                 //are you looking for a calculator for a rarefaction parameter
68                 }else if (parameter == "rarefaction") {
69                         //is it valid
70                         if ((rarefaction.find(calculator)) != (rarefaction.end())) {
71                                 return true;
72                         }else { 
73                                 cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
74                                 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
75                                         cout << it->first << ", ";
76                                 }
77                                 cout << endl;
78                                 return false; }
79                 //are you looking for a calculator for a summary parameter
80                 }else if (parameter == "summary") {
81                         //is it valid
82                         if ((summary.find(calculator)) != (summary.end())) {
83                                 return true;
84                         }else { 
85                                 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
86                                 for (it = summary.begin(); it != summary.end(); it++) {
87                                         cout << it->first << ", ";
88                                 }
89                                 cout << endl;
90                                 return false; }
91                 //are you looking for a calculator for a sharedsummary parameter
92                 }else if (parameter == "sharedsummary") {
93                         //is it valid
94                         if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
95                                 return true;
96                         }else { 
97                                 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
98                                 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
99                                         cout << it->first << ", ";
100                                 }
101                                 cout << endl;
102                                 return false; }
103                 }else if (parameter == "sharedrarefaction") {
104                         //is it valid
105                         if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
106                                 return true;
107                         }else { 
108                                 cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
109                                 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
110                                         cout << it->first << ", ";
111                                 }
112                                 cout << endl;
113                                 return false; }
114                 }else if (parameter == "vennsingle") {
115                         //is it valid
116                         if ((vennsingle.find(calculator)) != (vennsingle.end())) {
117                                 return true;
118                         }else { 
119                                 cout << calculator << " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ";
120                                 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
121                                         cout << it->first << ", ";
122                                 }
123                                 cout << endl;
124                                 return false; }
125                 }else if (parameter == "vennshared") {
126                         //is it valid
127                         if ((vennshared.find(calculator)) != (vennshared.end())) {
128                                 return true;
129                         }else { 
130                                 cout << calculator << " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ";
131                                 for (it = vennshared.begin(); it != vennshared.end(); it++) {
132                                         cout << it->first << ", ";
133                                 }
134                                 cout << endl;
135                                 return false; }
136                 }else if (parameter == "treegroup") {
137                         //is it valid
138                         if ((treegroup.find(calculator)) != (treegroup.end())) {
139                                 return true;
140                         }else { 
141                                 cout << calculator << " is not a valid estimator for the tree.groups command in shared mode and will be disregarded. Valid estimators are ";
142                                 for (it = treegroup.begin(); it != treegroup.end(); it++) {
143                                         cout << it->first << ", ";
144                                 }
145                                 cout << endl;
146                                 return false; }
147
148                 //not a valid parameter
149                 }else { return false; }
150                 
151         }
152         catch(exception& e) {
153                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. 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 isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
158                 exit(1);
159         }       
160 }
161
162 /********************************************************************/
163 void ValidCalculators::initialSingle() {
164         try {   
165                 single["sobs"]          = "sobs";
166                 single["chao"]              = "chao";
167                 single["ace"]               = "ace";
168                 single["jack"]              = "jack";
169                 single["shannon"]           = "shannon";
170                 single["npshannon"]     = "npshannon";
171                 single["simpson"]           = "simpson";
172                 single["bergerparker"]  = "bergerparker";
173                 single["bootstrap"]     = "bootstrap";
174                 single["geom"]          = "geom";
175                 single["logsd"]         = "logsd";
176                 single["qstat"]         = "qstat";
177                 single["bstick"]        = "bstick";
178                 single["nseqs"]                 = "nseqs";
179                 single["default"]           = "default";
180         }
181         catch(exception& e) {
182                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
183                 exit(1);
184         }
185         catch(...) {
186                 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
187                 exit(1);
188         }       
189 }
190
191 /********************************************************************/
192 void ValidCalculators::initialShared() {
193         try {   
194                 shared["sharedsobs"]                    = "sharedsobs";
195                 shared["sharedchao"]                    = "sharedchao";
196                 shared["sharedace"]                             = "sharedace";
197                 shared["jabund"]                                = "jabund";
198                 shared["sorensonabund"]                 = "sorensonabund";
199                 shared["jclass"]                                = "jclass";
200                 shared["sorclass"]                              = "sorclass";
201                 shared["jest"]                                  = "jest";
202                 shared["sorest"]                                = "sorest";
203                 shared["thetayc"]                               = "thetayc";
204                 shared["thetan"]                                = "thetan";
205                 shared["kstest"]                                = "kstest";
206                 shared["bdiversity"]                    = "bdiversity";
207                 shared["sharednseqs"]                   = "sharednseqs";
208                 shared["ochiai"]                                = "ochiai";
209                 shared["anderberg"]                             = "anderberg";
210                 shared["kulczynski"]                    = "kulczynski";
211                 shared["kulczynskicody"]                = "kulczynskicody";
212                 shared["lennon"]                                = "lennon";
213                 shared["morisitahorn"]                  = "morisitahorn";
214                 shared["braycurtis"]                    = "braycurtis";
215                 shared["default"]                   = "default";
216         }
217         catch(exception& e) {
218                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
219                 exit(1);
220         }
221         catch(...) {
222                 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
223                 exit(1);
224         }       
225 }
226
227 /********************************************************************/
228 void ValidCalculators::initialRarefaction() {
229         try {   
230                 rarefaction["sobs"]                     = "sobs";
231                 rarefaction["chao"]                     = "chao";
232                 rarefaction["ace"]                      = "ace";
233                 rarefaction["jack"]                     = "jack";
234                 rarefaction["shannon"]          = "shannon";
235                 rarefaction["npshannon"]        = "npshannon";
236                 rarefaction["simpson"]          = "simpson";
237                 rarefaction["bootstrap"]        = "bootstrap";
238                 rarefaction["nseqs"]            = "nseqs";
239                 rarefaction["default"]      = "default";
240         }
241         catch(exception& e) {
242                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
243                 exit(1);
244         }
245         catch(...) {
246                 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
247                 exit(1);
248         }       
249 }
250
251 /********************************************************************/
252
253 void ValidCalculators::initialSummary() {
254         try {   
255                 summary["sobs"]                 = "sobs";
256                 summary["chao"]                 = "chao";
257                 summary["ace"]                  = "ace";
258                 summary["jack"]                 = "jack";
259                 summary["shannon"]              = "shannon";
260                 summary["npshannon"]    = "npshannon";
261                 summary["simpson"]              = "simpson";
262                 summary["bergerparker"] = "bergerparker";
263                 summary["geom"]         = "geom";
264                 summary["bootstrap"]    = "bootstrap";
265                 summary["logsd"]        = "logsd";
266                 summary["qstat"]        = "qstat";
267                 summary["bstick"]       = "bstick";
268                 summary["nseqs"]                = "nseqs";
269                 summary["default"]          = "default";
270         }
271         catch(exception& e) {
272                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
273                 exit(1);
274         }
275         catch(...) {
276                 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
277                 exit(1);
278         }       
279 }
280
281 /********************************************************************/
282 void ValidCalculators::initialSharedSummary() {
283         try {   
284                 sharedsummary["sharedsobs"]                             = "sharedsobs";
285                 sharedsummary["sharedchao"]                             = "sharedchao";
286                 sharedsummary["sharedace"]                              = "sharedace";
287                 sharedsummary["jabund"]                                 = "jabund";
288                 sharedsummary["sorensonabund"]                  = "sorensonabund";
289                 sharedsummary["jclass"]                                 = "jclass";
290                 sharedsummary["sorclass"]                               = "sorclass";
291                 sharedsummary["jest"]                                   = "jest";
292                 sharedsummary["sorest"]                                 = "sorest";
293                 sharedsummary["thetayc"]                                = "thetayc";
294                 sharedsummary["thetan"]                                 = "thetan";
295                 sharedsummary["kstest"]                                 = "kstest";
296                 sharedsummary["bdiversity"]                             = "bdiversity";
297                 sharedsummary["sharednseqs"]                    = "sharednseqs";
298                 sharedsummary["ochiai"]                                 = "ochiai";
299                 sharedsummary["anderberg"]                              = "anderberg";
300                 sharedsummary["kulczynski"]                             = "kulczynski";
301                 sharedsummary["kulczynskicody"]                 = "kulczynskicody";
302                 sharedsummary["lennon"]                                 = "lennon";
303                 sharedsummary["morisitahorn"]                   = "morisitahorn";
304                 sharedsummary["braycurtis"]                             = "braycurtis";
305                 sharedsummary["default"]                                = "default";
306         }
307         catch(exception& e) {
308                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
309                 exit(1);
310         }
311         catch(...) {
312                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
313                 exit(1);
314         }       
315 }
316
317
318 /********************************************************************/
319
320 void ValidCalculators::initialSharedRarefact() {
321         try {   
322                 sharedrarefaction["sharedobserved"]     = "sharedobserved";
323                 sharedrarefaction["sharednseqs"]        = "sharednseqs";
324                 sharedrarefaction["default"]        = "default";
325         }
326         catch(exception& e) {
327                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
328                 exit(1);
329         }
330         catch(...) {
331                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
332                 exit(1);
333         }       
334 }
335
336
337 /********************************************************************/
338 void ValidCalculators::initialVennSingle() {
339         try {
340                 vennsingle["sobs"]              = "sobs";
341                 vennsingle["chao"]                  = "chao";
342                 vennsingle["ace"]                       = "ace";
343                 vennsingle["jack"]                  = "jack";
344                 vennsingle["default"]           = "default";
345         }
346         catch(exception& e) {
347                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
348                 exit(1);
349         }
350         catch(...) {
351                 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
352                 exit(1);
353         }       
354 }
355
356 /********************************************************************/
357 void ValidCalculators::initialVennShared() {
358         try {
359                 vennshared["sharedsobs"]        = "sharedsobs";
360                 vennshared["sharedchao"]        = "sharedchao";
361                 vennshared["sharedace"]         = "sharedace";
362                 vennshared["default"]           = "default";
363         }
364         catch(exception& e) {
365                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
366                 exit(1);
367         }
368         catch(...) {
369                 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
370                 exit(1);
371         }       
372 }
373
374 /********************************************************************/
375 void ValidCalculators::initialTreeGroups() {
376         try {   
377                 treegroup["jabund"]                                     = "jabund";
378                 treegroup["sorensonabund"]                      = "sorensonabund";
379                 treegroup["jclass"]                                     = "jclass";
380                 treegroup["sorclass"]                           = "sorclass";
381                 treegroup["jest"]                                       = "jest";
382                 treegroup["sorest"]                                     = "sorest";
383                 treegroup["thetayc"]                            = "thetayc";
384                 treegroup["thetan"]                                     = "thetan";
385                 treegroup["morisitahorn"]                       = "morisitahorn";
386         }
387         catch(exception& e) {
388                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
389                 exit(1);
390         }
391         catch(...) {
392                 cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
393                 exit(1);
394         }       
395 }
396
397
398 /********************************************************************/
399
400
401
402