]> git.donarmstrong.com Git - mothur.git/blob - validcalculator.cpp
finishing the container classes, combining read.otu and read.list commands. some...
[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["sharedSobs"]                    = "sharedSobs";
118                 shared["sharedChao"]                    = "sharedChao";
119                 shared["sharedAce"]                             = "sharedAce";
120                 shared["sharedJabund"]                  = "sharedJabund";
121                 shared["sharedSorensonAbund"]   = "sharedSorensonAbund";
122                 shared["sharedJclass"]                  = "sharedJclass";
123                 shared["sharedSorClass"]                = "sharedSorClass";
124                 shared["sharedJest"]                    = "sharedJest";
125                 shared["sharedSorEst"]                  = "sharedSorEst";
126                 shared["SharedThetaYC"]                 = "SharedThetaYC";
127                 shared["SharedThetaN"]                  = "SharedThetaN";
128                 shared["default"]                   = "default";
129         }
130         catch(exception& e) {
131                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
132                 exit(1);
133         }
134         catch(...) {
135                 cout << "An unknown error has occurred in the ValidCalculator class function initialShared. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
136                 exit(1);
137         }       
138 }
139
140 /********************************************************************/
141 void ValidCalculators::initialRarefaction() {
142         try {   
143                 rarefaction["sobs"]                     = "sobs";
144                 rarefaction["chao"]                     = "chao";
145                 rarefaction["ace"]                      = "ace";
146                 rarefaction["jack"]                     = "jack";
147                 rarefaction["shannon"]          = "shannon";
148                 rarefaction["npshannon"]        = "npshannon";
149                 rarefaction["simpson"]          = "simpson";
150                 rarefaction["bootstrap"]        = "bootstrap";
151                 rarefaction["default"]      = "default";
152         }
153         catch(exception& e) {
154                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
155                 exit(1);
156         }
157         catch(...) {
158                 cout << "An unknown error has occurred in the ValidCalculator class function initialRarefaction. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
159                 exit(1);
160         }       
161 }
162
163 /********************************************************************/
164
165 void ValidCalculators::initialSummary() {
166         try {   
167                 summary["sobs"]                 = "sobs";
168                 summary["chao"]                 = "chao";
169                 summary["ace"]                  = "ace";
170                 summary["jack"]                 = "jack";
171                 summary["shannon"]              = "shannon";
172                 summary["npshannon"]    = "npshannon";
173                 summary["simpson"]              = "simpson";
174                 summary["bootstrap"]    = "bootstrap";
175                 summary["default"]          = "default";
176         }
177         catch(exception& e) {
178                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
179                 exit(1);
180         }
181         catch(...) {
182                 cout << "An unknown error has occurred in the ValidCalculator class function initialSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
183                 exit(1);
184         }       
185 }
186
187 /********************************************************************/
188 void ValidCalculators::initialSharedSummary() {
189         try {   
190                 sharedsummary["sharedSobs"]                             = "sharedSobs";
191                 sharedsummary["sharedChao"]                             = "sharedChao";
192                 sharedsummary["sharedAce"]                              = "sharedAce";
193                 sharedsummary["sharedJabund"]                   = "sharedJabund";
194                 sharedsummary["sharedSorensonAbund"]    = "sharedSorensonAbund";
195                 sharedsummary["sharedJclass"]                   = "sharedJclass";
196                 sharedsummary["sharedSorClass"]                 = "sharedSorClass";
197                 sharedsummary["sharedJest"]                             = "sharedJest";
198                 sharedsummary["sharedSorEst"]                   = "sharedSorEst";
199                 sharedsummary["SharedThetaYC"]                  = "SharedThetaYC";
200                 sharedsummary["SharedThetaN"]                   = "SharedThetaN";
201                 sharedsummary["default"]                                = "default";
202         }
203         catch(exception& e) {
204                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
205                 exit(1);
206         }
207         catch(...) {
208                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedSummary. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
209                 exit(1);
210         }       
211 }
212
213
214 /********************************************************************/
215
216 void ValidCalculators::initialSharedRarefact() {
217         try {   
218                 sharedrarefaction["sharedobserved"]     = "sharedobserved";
219                 sharedrarefaction["default"]        = "default";
220         }
221         catch(exception& e) {
222                 cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
223                 exit(1);
224         }
225         catch(...) {
226                 cout << "An unknown error has occurred in the ValidCalculator class function initialSharedRarefact. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
227                 exit(1);
228         }       
229 }
230
231 /********************************************************************/
232
233
234