]> git.donarmstrong.com Git - mothur.git/blob - validcalculator.cpp
added nseqs and sharednseqs calculators, removed excess tabs in output files.
[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 { 
46                                 cout << calculator << " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ";
47                                 for (it = single.begin(); it != single.end(); it++) {
48                                         cout << it->first << ", ";
49                                 }
50                                 cout << endl;
51                                 return false; }
52                 //are you looking for a calculator for a shared parameter
53                 }else if (parameter == "shared") {
54                         //is it valid
55                         if ((shared.find(calculator)) != (shared.end())) {
56                                 return true;
57                         }else { 
58                                 cout << calculator << " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ";
59                                 for (it = shared.begin(); it != shared.end(); it++) {
60                                         cout << it->first << ", ";
61                                 }
62                                 cout << endl;
63                                 return false; }
64                 //are you looking for a calculator for a rarefaction parameter
65                 }else if (parameter == "rarefaction") {
66                         //is it valid
67                         if ((rarefaction.find(calculator)) != (rarefaction.end())) {
68                                 return true;
69                         }else { 
70                                 cout << calculator << " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ";
71                                 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
72                                         cout << it->first << ", ";
73                                 }
74                                 cout << endl;
75                                 return false; }
76                 //are you looking for a calculator for a summary parameter
77                 }else if (parameter == "summary") {
78                         //is it valid
79                         if ((summary.find(calculator)) != (summary.end())) {
80                                 return true;
81                         }else { 
82                                 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
83                                 for (it = summary.begin(); it != summary.end(); it++) {
84                                         cout << it->first << ", ";
85                                 }
86                                 cout << endl;
87                                 return false; }
88                 //are you looking for a calculator for a sharedsummary parameter
89                 }else if (parameter == "sharedsummary") {
90                         //is it valid
91                         if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
92                                 return true;
93                         }else { 
94                                 cout << calculator << " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ";
95                                 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
96                                         cout << it->first << ", ";
97                                 }
98                                 cout << endl;
99                                 return false; }
100                 }else if (parameter == "sharedrarefaction") {
101                         //is it valid
102                         if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
103                                 return true;
104                         }else { 
105                                 cout << calculator << " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ";
106                                 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
107                                         cout << it->first << ", ";
108                                 }
109                                 cout << endl;
110                                 return false; }
111                 //not a valid paramter
112                 }else { return false; }
113                 
114         }
115         catch(exception& e) {
116                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
117                 exit(1);
118         }
119         catch(...) {
120                 cout << "An unknown error has occurred in the ValidCalculator class function isValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
121                 exit(1);
122         }       
123 }
124
125 /********************************************************************/
126 void ValidCalculators::initialSingle() {
127         try {   
128         
129                 single["sobs"]          = "sobs";
130                 single["chao"]          = "chao";
131                 single["ace"]           = "ace";
132                 single["jack"]          = "jack";
133                 single["shannon"]       = "shannon";
134                 single["npshannon"]     = "npshannon";
135                 single["simpson"]       = "simpson";
136                 single["bootstrap"]     = "bootstrap";
137                 single["default"]       = "default";
138                 single["nseqs"]         = "nseqs";
139         }
140         catch(exception& e) {
141                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
142                 exit(1);
143         }
144         catch(...) {
145                 cout << "An unknown error has occurred in the ValidCalculator class function initialSingle. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
146                 exit(1);
147         }       
148 }
149
150 /********************************************************************/
151 void ValidCalculators::initialShared() {
152         try {   
153                 shared["sharedsobs"]                    = "sharedsobs";
154                 shared["sharedchao"]                    = "sharedchao";
155                 shared["sharedace"]                             = "sharedace";
156                 shared["sharedjabund"]                  = "sharedjabund";
157                 shared["sharedsorensonabund"]   = "sharedsorensonabund";
158                 shared["sharedjclass"]                  = "sharedjclass";
159                 shared["sharedsorclass"]                = "sharedsorclass";
160                 shared["sharedjest"]                    = "sharedjest";
161                 shared["sharedsorest"]                  = "sharedsorest";
162                 shared["sharedthetayc"]                 = "sharedthetayc";
163                 shared["sharedthetan"]                  = "sharedthetan";
164                 shared["sharednseqs"]                   = "sharednseqs";
165                 shared["default"]                   = "default";
166         }
167         catch(exception& e) {
168                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
169                 exit(1);
170         }
171         catch(...) {
172                 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
173                 exit(1);
174         }       
175 }
176
177 /********************************************************************/
178 void ValidCalculators::initialRarefaction() {
179         try {   
180                 rarefaction["sobs"]                     = "sobs";
181                 rarefaction["chao"]                     = "chao";
182                 rarefaction["ace"]                      = "ace";
183                 rarefaction["jack"]                     = "jack";
184                 rarefaction["shannon"]          = "shannon";
185                 rarefaction["npshannon"]        = "npshannon";
186                 rarefaction["simpson"]          = "simpson";
187                 rarefaction["bootstrap"]        = "bootstrap";
188                 rarefaction["nseqs"]            = "nseqs";
189                 rarefaction["default"]      = "default";
190         }
191         catch(exception& e) {
192                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
193                 exit(1);
194         }
195         catch(...) {
196                 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
197                 exit(1);
198         }       
199 }
200
201 /********************************************************************/
202
203 void ValidCalculators::initialSummary() {
204         try {   
205                 summary["sobs"]                 = "sobs";
206                 summary["chao"]                 = "chao";
207                 summary["ace"]                  = "ace";
208                 summary["jack"]                 = "jack";
209                 summary["shannon"]              = "shannon";
210                 summary["npshannon"]    = "npshannon";
211                 summary["simpson"]              = "simpson";
212                 summary["bootstrap"]    = "bootstrap";
213                 summary["nseqs"]                = "nseqs";
214                 summary["default"]          = "default";
215         }
216         catch(exception& e) {
217                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
218                 exit(1);
219         }
220         catch(...) {
221                 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
222                 exit(1);
223         }       
224 }
225
226 /********************************************************************/
227 void ValidCalculators::initialSharedSummary() {
228         try {   
229                 sharedsummary["sharedsobs"]                             = "sharedsobs";
230                 sharedsummary["sharedchao"]                             = "sharedchao";
231                 sharedsummary["sharedace"]                              = "sharedace";
232                 sharedsummary["sharedjabund"]                   = "sharedjabund";
233                 sharedsummary["sharedsorensonabund"]    = "sharedsorensonabund";
234                 sharedsummary["sharedjclass"]                   = "sharedjclass";
235                 sharedsummary["sharedsorclass"]                 = "sharedsorclass";
236                 sharedsummary["sharedjest"]                             = "sharedjest";
237                 sharedsummary["sharedsorest"]                   = "sharedsorest";
238                 sharedsummary["sharedthetayc"]                  = "sharedthetayc";
239                 sharedsummary["sharedthetan"]                   = "sharedthetan";
240                 sharedsummary["sharednseqs"]                    = "sharednseqs";
241                 sharedsummary["default"]                                = "default";
242         }
243         catch(exception& e) {
244                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
245                 exit(1);
246         }
247         catch(...) {
248                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
249                 exit(1);
250         }       
251 }
252
253
254 /********************************************************************/
255
256 void ValidCalculators::initialSharedRarefact() {
257         try {   
258                 sharedrarefaction["sharedobserved"]     = "sharedobserved";
259                 sharedrarefaction["sharednseqs"]        = "sharednseqs";
260                 sharedrarefaction["default"]        = "default";
261         }
262         catch(exception& e) {
263                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
264                 exit(1);
265         }
266         catch(...) {
267                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
268                 exit(1);
269         }       
270 }
271
272 /********************************************************************/
273
274
275