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