]> git.donarmstrong.com Git - mothur.git/blob - validcalculator.cpp
working on pam
[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 #include "ace.h"
12 #include "sobs.h"
13 #include "nseqs.h"
14 #include "chao1.h"
15 #include "bootstrap.h"
16 #include "simpson.h"
17 #include "simpsoneven.h"
18 #include "invsimpson.h"
19 #include "npshannon.h"
20 #include "shannon.h"
21 #include "smithwilson.h"
22 #include "heip.h"
23 #include "shannoneven.h"
24 #include "jackknife.h"
25 #include "geom.h"
26 #include "qstat.h"
27 #include "logsd.h"
28 #include "bergerparker.h"
29 #include "bstick.h"
30 #include "goodscoverage.h"
31 #include "efron.h"
32 #include "boneh.h"
33 #include "solow.h"
34 #include "shen.h"
35 #include "coverage.h"
36 #include "sharedsobscollectsummary.h"
37 #include "sharedchao1.h"
38 #include "sharedace.h"
39 #include "sharedjabund.h"
40 #include "sharedsorabund.h"
41 #include "sharedjclass.h"
42 #include "sharedsorclass.h"
43 #include "sharedjest.h"
44 #include "sharedsorest.h"
45 #include "sharedthetayc.h"
46 #include "sharedthetan.h"
47 #include "sharedkstest.h"
48 #include "whittaker.h"
49 #include "sharednseqs.h"
50 #include "sharedochiai.h"
51 #include "sharedanderbergs.h"
52 #include "sharedkulczynski.h"
53 #include "sharedkulczynskicody.h"
54 #include "sharedlennon.h"
55 #include "sharedmorisitahorn.h"
56 #include "sharedbraycurtis.h"
57 #include "sharedjackknife.h"
58 #include "whittaker.h"
59 #include "odum.h"
60 #include "canberra.h"
61 #include "structeuclidean.h"
62 #include "structchord.h"
63 #include "hellinger.h"
64 #include "manhattan.h"
65 #include "structpearson.h"
66 #include "soergel.h"
67 #include "spearman.h"
68 #include "structkulczynski.h"
69 #include "structchi2.h"
70 #include "speciesprofile.h"
71 #include "hamming.h"
72 #include "gower.h"
73 #include "memchi2.h"
74 #include "memchord.h"
75 #include "memeuclidean.h"
76 #include "mempearson.h"
77 #include "sharedsobs.h"
78 #include "sharednseqs.h"
79 #include "sharedjsd.h"
80
81
82 /********************************************************************/
83 ValidCalculators::ValidCalculators() {
84         try {
85                 m = MothurOut::getInstance();
86                 
87                 initialSingle();  
88                 initialShared();
89                 initialRarefaction();
90                 initialSharedRarefact();
91                 initialSummary();
92                 initialSharedSummary();
93                 initialVennSingle();
94                 initialVennShared();
95                 initialTreeGroups();
96                 initialBoot();
97                 initialDistance();
98                 initialMatrix();
99                 initialHeat();
100                 
101                 for(it = single.begin(); it != single.end(); it++) { allCalcs.insert(it->first); } 
102                 for(it = shared.begin(); it != shared.end(); it++) { allCalcs.insert(it->first); } 
103                 for(it = rarefaction.begin(); it != rarefaction.end(); it++) { allCalcs.insert(it->first); } 
104                 for(it = summary.begin(); it != summary.end(); it++) { allCalcs.insert(it->first); } 
105                 for(it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) { allCalcs.insert(it->first); } 
106                 for(it = sharedsummary.begin(); it != sharedsummary.end(); it++) { allCalcs.insert(it->first); } 
107                 for(it = vennsingle.begin(); it != vennsingle.end(); it++) { allCalcs.insert(it->first); } 
108                 for(it = vennshared.begin(); it != vennshared.end(); it++) { allCalcs.insert(it->first); } 
109                 for(it = treegroup.begin(); it != treegroup.end(); it++) { allCalcs.insert(it->first); } 
110                 for(it = matrix.begin(); it != matrix.end(); it++) { allCalcs.insert(it->first); } 
111                 for(it = heat.begin(); it != heat.end(); it++) { allCalcs.insert(it->first); } 
112                 for(it = boot.begin(); it != boot.end(); it++) { allCalcs.insert(it->first); } 
113                 for(it = distance.begin(); it != distance.end(); it++) { allCalcs.insert(it->first); } 
114                 
115         }
116         catch(exception& e) {
117                 m->errorOut(e, "ValidCalculator", "ValidCalculator");
118                 exit(1);
119         }
120 }
121 /********************************************************************/
122 ValidCalculators::~ValidCalculators() {}
123 /********************************************************************/
124 void ValidCalculators::printCitations(vector<string> Estimators) {
125         try {
126                 
127                 for (int i = 0; i < Estimators.size(); i++) {
128                         //is this citation, do nothing
129                         if ((Estimators[i] == "citation") || (Estimators[i] == "default") || (Estimators[i] == "eachgap") || (Estimators[i] == "nogaps") || (Estimators[i] == "onegap")) {}
130                         //is this a valid calculator
131                         else if (allCalcs.count(Estimators[i]) != 0) {
132                                 if (Estimators[i] == "sobs") { Calculator* temp = new Sobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
133                                 }else if (Estimators[i] == "chao") { Calculator* temp = new Chao1(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
134                                 }else if (Estimators[i] == "nseqs") { Calculator* temp = new NSeqs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
135                                 }else if (Estimators[i] == "coverage") { Calculator* temp = new Coverage(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
136                                 }else if (Estimators[i] == "ace") { Calculator* temp = new Ace(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
137                                 
138                                 }else if (Estimators[i] == "jack") { Calculator* temp = new Jackknife(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
139                                 }else if (Estimators[i] == "shannon") { Calculator* temp = new Shannon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
140                                 }else if (Estimators[i] == "shannoneven") { Calculator* temp = new ShannonEven(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
141                                 }else if (Estimators[i] == "npshannon") { Calculator* temp = new NPShannon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
142                                 }else if (Estimators[i] == "heip") { Calculator* temp = new Heip(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
143                                 
144                                 }else if (Estimators[i] == "smithwilson") { Calculator* temp = new SmithWilson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
145                                 }else if (Estimators[i] == "simpson") { Calculator* temp = new Simpson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
146                                 }else if (Estimators[i] == "simpsoneven") { Calculator* temp = new SimpsonEven(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
147                                 }else if (Estimators[i] == "invsimpson") { Calculator* temp = new InvSimpson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
148                                 }else if (Estimators[i] == "bootstrap") { Calculator* temp = new Bootstrap(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
149                                 
150                                 }else if (Estimators[i] == "geometric") { Calculator* temp = new Geom(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
151                                 }else if (Estimators[i] == "qstat") { Calculator* temp = new QStat(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
152                                 }else if (Estimators[i] == "logseries") { Calculator* temp = new LogSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
153                                 }else if (Estimators[i] == "bergerparker") { Calculator* temp = new BergerParker(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
154                                 }else if (Estimators[i] == "bstick") { Calculator* temp = new BStick(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
155                                 
156                                 }else if (Estimators[i] == "goodscoverage") { Calculator* temp = new GoodsCoverage(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
157                                 }else if (Estimators[i] == "efron") { Calculator* temp = new Efron(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
158                                 }else if (Estimators[i] == "boneh") { Calculator* temp = new Boneh(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
159                                 }else if (Estimators[i] == "solow") { Calculator* temp = new Solow(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
160                                 }else if (Estimators[i] == "shen") { Calculator* temp = new Shen(10, 10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
161                                 
162                                 }else if (Estimators[i] == "sharedchao") { Calculator* temp = new SharedChao1(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
163                                 }else if (Estimators[i] == "sharedsobs") { Calculator* temp = new SharedSobsCS(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
164                                 }else if (Estimators[i] == "sharedace") { Calculator* temp = new SharedAce(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
165                                 }else if (Estimators[i] == "jabund") {  Calculator* temp = new JAbund(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
166                                 }else if (Estimators[i] == "sorabund") { Calculator* temp = new SorAbund(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
167                                 
168                                 }else if (Estimators[i] == "jclass") { Calculator* temp = new Jclass(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
169                                 }else if (Estimators[i] == "sorclass") { Calculator* temp = new SorClass(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
170                                 }else if (Estimators[i] == "jest") { Calculator* temp = new Jest(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
171                                 }else if (Estimators[i] == "sorest") { Calculator* temp = new SorEst(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
172                                 }else if (Estimators[i] == "thetayc") { Calculator* temp = new ThetaYC(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
173                                 
174                                 }else if (Estimators[i] == "thetan") { Calculator* temp = new ThetaN(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
175                                 }else if (Estimators[i] == "kstest") { Calculator* temp = new KSTest(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
176                                 }else if (Estimators[i] == "whittaker") { Calculator* temp = new Whittaker(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
177                                 }else if (Estimators[i] == "sharednseqs") { Calculator* temp = new SharedNSeqs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
178                                 }else if (Estimators[i] == "ochiai") { Calculator* temp = new Ochiai(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
179                                 
180                                 }else if (Estimators[i] == "anderberg") { Calculator* temp = new Anderberg(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
181                                 }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
182                                 }else if (Estimators[i] == "kulczynskicody") { Calculator* temp = new KulczynskiCody(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
183                                 }else if (Estimators[i] == "lennon") { Calculator* temp = new Lennon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
184                                 }else if (Estimators[i] == "morisitahorn") { Calculator* temp = new MorHorn(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
185                                 
186                                 }else if (Estimators[i] == "braycurtis") { Calculator* temp = new BrayCurtis(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
187                                 }else if (Estimators[i] == "odum") { Calculator* temp = new Odum(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
188                                 }else if (Estimators[i] == "canberra") { Calculator* temp = new Canberra(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
189                                 }else if (Estimators[i] == "structeuclidean") { Calculator* temp = new StructEuclidean(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
190                                 }else if (Estimators[i] == "structchord") { Calculator* temp = new StructChord(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
191                                 
192                                 }else if (Estimators[i] == "hellinger") { Calculator* temp = new Hellinger(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
193                                 }else if (Estimators[i] == "manhattan") { Calculator* temp = new Manhattan(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
194                                 }else if (Estimators[i] == "structpearson") { Calculator* temp = new StructPearson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
195                                 }else if (Estimators[i] == "soergel") { Calculator* temp = new Soergel(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
196                                 }else if (Estimators[i] == "spearman") { Calculator* temp = new Spearman(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
197                                 
198                                 }else if (Estimators[i] == "structkulczynski") { Calculator* temp = new StructKulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
199                                 }else if (Estimators[i] == "speciesprofile") { Calculator* temp = new SpeciesProfile(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
200                                 }else if (Estimators[i] == "hamming") { Calculator* temp = new Hamming(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
201                                 }else if (Estimators[i] == "structchi2") { Calculator* temp = new StructChi2(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
202                                 }else if (Estimators[i] == "gower") { Calculator* temp = new Gower(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
203                                 
204                                 }else if (Estimators[i] == "memchi2") { Calculator* temp = new MemChi2(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
205                                 }else if (Estimators[i] == "memchord") { Calculator* temp = new MemChord(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
206                                 }else if (Estimators[i] == "memeuclidean") { Calculator* temp = new MemEuclidean(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
207                                 }else if (Estimators[i] == "mempearson") { Calculator* temp = new MemPearson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
208                                 }else if (Estimators[i] == "sharedobserved") { Calculator* temp = new SharedSobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
209                                 }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
210                 }else if (Estimators[i] == "jsd") { Calculator* temp = new JSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
211                                 }else { m->mothurOut("[ERROR]: Missing else if for " + Estimators[i] + " in printCitations."); m->mothurOutEndLine(); }
212                         }else { m->mothurOut(Estimators[i] + " is not a valid calculator, no citation will be given."); m->mothurOutEndLine(); }
213                 }
214                         
215         }
216         catch(exception& e) {
217                 m->errorOut(e, "ValidCalculator", "printCitations");
218                 exit(1);
219         }
220 }
221 /********************************************************************/
222
223 bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
224         try {   
225                 //are you looking for a calculator for a single parameter
226                 if (parameter == "single") {
227                         //is it valid
228                         if ((single.find(calculator)) != (single.end())) {
229                                 return true;
230                         }else { 
231                                 m->mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
232                                 for (it = single.begin(); it != single.end(); it++) {
233                                         m->mothurOut(it->first + ", ");
234                                 }
235                                 m->mothurOutEndLine();
236                                 return false; }
237                 //are you looking for a calculator for a shared parameter
238                 }else if (parameter == "shared") {
239                         //is it valid
240                         if ((shared.find(calculator)) != (shared.end())) {
241                                 return true;
242                         }else { 
243                                 m->mothurOut(calculator +  " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ");
244                                 for (it = shared.begin(); it != shared.end(); it++) {
245                                         m->mothurOut(it->first + ", ");
246                                 }
247                                 m->mothurOutEndLine();
248                                 return false; }
249                 //are you looking for a calculator for a rarefaction parameter
250                 }else if (parameter == "rarefaction") {
251                         //is it valid
252                         if ((rarefaction.find(calculator)) != (rarefaction.end())) {
253                                 return true;
254                         }else { 
255                                 m->mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
256                                 for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
257                                         m->mothurOut(it->first + ", ");
258                                 }
259                                 m->mothurOutEndLine();
260                                 return false; }
261                 //are you looking for a calculator for a summary parameter
262                 }else if (parameter == "summary") {
263                         //is it valid
264                         if ((summary.find(calculator)) != (summary.end())) {
265                                 return true;
266                         }else { 
267                                 m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
268                                 for (it = summary.begin(); it != summary.end(); it++) {
269                                         m->mothurOut(it->first + ", ");
270                                 }
271                                 m->mothurOutEndLine();
272                                 return false; }
273                 //are you looking for a calculator for a sharedsummary parameter
274                 }else if (parameter == "sharedsummary") {
275                         //is it valid
276                         if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
277                                 return true;
278                         }else { 
279                                 m->mothurOut(calculator +  " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
280                                 for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
281                                         m->mothurOut(it->first + ", ");
282                                 }
283                                 m->mothurOutEndLine();
284                                 return false; }
285                 }else if (parameter == "sharedrarefaction") {
286                         //is it valid
287                         if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
288                                 return true;
289                         }else { 
290                                 m->mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
291                                 for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
292                                         m->mothurOut(it->first + ", ");
293                                 }
294                                 m->mothurOutEndLine();
295                                 return false; }
296                 }else if (parameter == "vennsingle") {
297                         //is it valid
298                         if ((vennsingle.find(calculator)) != (vennsingle.end())) {
299                                 return true;
300                         }else { 
301                                 m->mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
302                                 for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
303                                         m->mothurOut(it->first + ", ");
304                                 }
305                                 m->mothurOutEndLine();
306                                 return false; }
307                 }else if (parameter == "vennshared") {
308                         //is it valid
309                         if ((vennshared.find(calculator)) != (vennshared.end())) {
310                                 return true;
311                         }else { 
312                                 m->mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
313                                 for (it = vennshared.begin(); it != vennshared.end(); it++) {
314                                         m->mothurOut(it->first + ", ");
315                                 }
316                                 m->mothurOutEndLine();
317                                 return false; }
318                 }else if (parameter == "treegroup") {
319                         //is it valid
320                         if ((treegroup.find(calculator)) != (treegroup.end())) {
321                                 return true;
322                         }else { 
323                                 m->mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
324                                 for (it = treegroup.begin(); it != treegroup.end(); it++) {
325                                         m->mothurOut(it->first + ", ");
326                                 }
327                                 m->mothurOutEndLine();
328                                 return false; }
329                 }else if (parameter == "matrix") {
330                         //is it valid
331                         if ((matrix.find(calculator)) != (matrix.end())) {
332                                 return true;
333                         }else { 
334                                 m->mothurOut(calculator +  " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
335                                 for (it = matrix.begin(); it != matrix.end(); it++) {
336                                         m->mothurOut(it->first + ", ");
337                                 }
338                                 m->mothurOutEndLine();
339                                 return false; }
340                 }else if (parameter == "heat") {
341                         //is it valid
342                         if ((heat.find(calculator)) != (heat.end())) {
343                                 return true;
344                         }else { 
345                                 m->mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
346                                 for (it = heat.begin(); it != heat.end(); it++) {
347                                         m->mothurOut(it->first + ", ");
348                                 }
349                                 m->mothurOutEndLine();
350                                 return false; }
351                 }else if (parameter == "boot") {
352                         //is it valid
353                         if ((boot.find(calculator)) != (boot.end())) {
354                                 return true;
355                         }else { 
356                                 m->mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
357                                 for (it = boot.begin(); it != boot.end(); it++) {
358                                         m->mothurOut(it->first + ", ");
359                                 }
360                                 m->mothurOutEndLine();
361                                 return false; }
362                 }else if (parameter == "distance") {
363                         //is it valid
364                         if ((distance.find(calculator)) != (distance.end())) {
365                                 return true;
366                         }else { 
367                                 m->mothurOut(calculator +  " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
368                                 for (it = distance.begin(); it != distance.end(); it++) {
369                                         m->mothurOut(it->first + ", ");
370                                 }
371                                 m->mothurOutEndLine();
372                                 return false; }
373                 //not a valid parameter
374                 }else { return false; }
375                 
376         }
377         catch(exception& e) {
378                 m->errorOut(e, "ValidCalculator", "isValidCalculator");
379                 exit(1);
380         }
381 }
382
383 /********************************************************************/
384 void ValidCalculators::initialSingle() {
385         try {   
386                 single["sobs"]          = "sobs";
387                 single["chao"]              = "chao";
388                 single["ace"]               = "ace";
389                 single["jack"]              = "jack";
390                 single["shannon"]           = "shannon";
391                 single["npshannon"]     = "npshannon";
392                 single["shannoneven"]   = "shannoneven";
393                 single["smithwilson"]   = "smithwilson";
394                 single["heip"]                  = "heip";
395                 single["simpson"]           = "simpson";
396                 single["simpsoneven"]   = "simpsoneven";
397                 single["invsimpson"]    = "invsimpson";
398                 single["bergerparker"]  = "bergerparker";
399                 single["bootstrap"]     = "bootstrap";
400                 single["geometric"]     = "geometric";
401                 single["logseries"]             = "logseries";
402                 single["qstat"]         = "qstat";
403                 single["bstick"]        = "bstick";
404                 single["goodscoverage"] = "goodscoverage";
405                 single["nseqs"]                 = "nseqs";
406                 single["coverage"]              = "coverage";
407                 single["efron"]         = "efron";
408                 single["boneh"]         = "boneh";
409                 single["solow"]         = "solow";
410                 single["shen"]          = "shen";
411                 single["default"]           = "default";
412         }
413         catch(exception& e) {
414                 m->errorOut(e, "ValidCalculator", "initialSingle");
415                 exit(1);
416         }
417 }
418
419 /********************************************************************/
420 void ValidCalculators::initialShared() {
421         try {   
422                 shared["sharedsobs"]                    = "sharedsobs";
423                 shared["sharedchao"]                    = "sharedchao";
424                 shared["sharedace"]                             = "sharedace";
425                 shared["jabund"]                                = "jabund";
426                 shared["sorabund"]                              = "sorabund";
427                 shared["jclass"]                                = "jclass";
428                 shared["sorclass"]                              = "sorclass";
429                 shared["jest"]                                  = "jest";
430                 shared["sorest"]                                = "sorest";
431                 shared["thetayc"]                               = "thetayc";
432                 shared["thetan"]                                = "thetan";
433                 shared["kstest"]                                = "kstest";
434                 shared["whittaker"]                         = "whittaker";
435                 shared["sharednseqs"]                   = "sharednseqs";
436                 shared["ochiai"]                                = "ochiai";
437                 shared["anderberg"]                             = "anderberg";
438                 shared["kulczynski"]                    = "kulczynski";
439                 shared["kulczynskicody"]                = "kulczynskicody";
440                 shared["lennon"]                                = "lennon";
441                 shared["morisitahorn"]                  = "morisitahorn";
442                 shared["braycurtis"]                    = "braycurtis";
443                 shared["odum"]                                  = "odum";
444                 shared["canberra"]                              = "canberra";
445                 shared["structeuclidean"]               = "structeuclidean";
446                 shared["structchord"]                   = "structchord";
447                 shared["hellinger"]                             = "hellinger";
448                 shared["manhattan"]                             = "manhattan";
449                 shared["structpearson"]                 = "structpearson";
450                 shared["soergel"]                               = "soergel";
451                 shared["spearman"]                              = "spearman";
452                 shared["structkulczynski"]              = "structkulczynski";
453                 shared["structchi2"]                    = "structchi2";
454                 shared["speciesprofile"]                = "speciesprofile";
455                 shared["hamming"]                               = "hamming";
456                 shared["gower"]                                 = "gower";
457                 shared["memchi2"]                               = "memchi2";
458                 shared["memchord"]                              = "memchord";
459                 shared["memeuclidean"]                  = "memeuclidean";
460                 shared["mempearson"]                    = "mempearson";
461         shared["jsd"]                           = "jsd";
462                 shared["default"]                   = "default";
463         }
464         catch(exception& e) {
465                 m->errorOut(e, "ValidCalculator", "initialShared");
466                 exit(1);
467         }
468 }
469
470 /********************************************************************/
471 void ValidCalculators::initialRarefaction() {
472         try {   
473                 rarefaction["sobs"]                     = "sobs";
474                 rarefaction["chao"]                     = "chao";
475                 rarefaction["ace"]                      = "ace";
476                 rarefaction["jack"]                     = "jack";
477                 rarefaction["shannon"]          = "shannon";
478                 rarefaction["smithwilson"]      = "smithwilson";
479                 rarefaction["heip"]                     = "heip";
480                 rarefaction["npshannon"]        = "npshannon";
481                 rarefaction["shannoneven"]      = "shannoneven";
482                 rarefaction["simpson"]          = "simpson";
483                 rarefaction["invsimpson"]       = "invsimpson";
484                 rarefaction["simpsoneven"]      = "simpsoneven";
485                 rarefaction["bootstrap"]        = "bootstrap";
486                 rarefaction["nseqs"]            = "nseqs";
487                 rarefaction["coverage"]         = "coverage";
488                 rarefaction["default"]      = "default";
489         }
490         catch(exception& e) {
491                 m->errorOut(e, "ValidCalculator", "initialRarefaction");
492                 exit(1);
493         }
494 }
495
496 /********************************************************************/
497
498 void ValidCalculators::initialSummary() {
499         try {   
500                 summary["sobs"]                 = "sobs";
501                 summary["chao"]                 = "chao";
502                 summary["ace"]                  = "ace";
503                 summary["jack"]                 = "jack";
504                 summary["shannon"]              = "shannon";
505                 summary["heip"]                 = "heip";
506                 summary["shannoneven"]  = "shannoneven";
507                 summary["smithwilson"]  = "smithwilson";
508                 summary["invsimpson"]   = "invsimpson";
509                 summary["npshannon"]    = "npshannon";
510                 summary["simpson"]              = "simpson";
511                 summary["simpsoneven"]  = "simpsoneven";
512                 summary["bergerparker"] = "bergerparker";
513                 summary["geometric"]    = "geometric";
514                 summary["bootstrap"]    = "bootstrap";
515                 summary["logseries"]    = "logseries";
516                 summary["qstat"]        = "qstat";
517                 summary["bstick"]       = "bstick";
518                 summary["nseqs"]                = "nseqs";
519                 summary["goodscoverage"]= "goodscoverage";
520                 summary["coverage"]             = "coverage";
521                 summary["efron"]        = "efron";
522                 summary["boneh"]        = "boneh";
523                 summary["solow"]        = "solow";
524                 summary["shen"]         = "shen";
525                 summary["default"]          = "default";
526         }
527         catch(exception& e) {
528                 m->errorOut(e, "ValidCalculator", "initialSummary");
529                 exit(1);
530         }
531 }
532
533 /********************************************************************/
534 void ValidCalculators::initialSharedSummary() {
535         try {   
536                 sharedsummary["sharedsobs"]                             = "sharedsobs";
537                 sharedsummary["sharedchao"]                             = "sharedchao";
538                 sharedsummary["sharedace"]                              = "sharedace";
539                 sharedsummary["jabund"]                                 = "jabund";
540                 sharedsummary["sorabund"]                               = "sorabund";
541                 sharedsummary["jclass"]                                 = "jclass";
542                 sharedsummary["sorclass"]                               = "sorclass";
543                 sharedsummary["jest"]                                   = "jest";
544                 sharedsummary["sorest"]                                 = "sorest";
545                 sharedsummary["thetayc"]                                = "thetayc";
546                 sharedsummary["thetan"]                                 = "thetan";
547                 sharedsummary["kstest"]                                 = "kstest";
548                 sharedsummary["whittaker"]                              = "whittaker";
549                 sharedsummary["sharednseqs"]                    = "sharednseqs";
550                 sharedsummary["ochiai"]                                 = "ochiai";
551                 sharedsummary["anderberg"]                              = "anderberg";
552                 sharedsummary["kulczynski"]                             = "kulczynski";
553                 sharedsummary["kulczynskicody"]                 = "kulczynskicody";
554                 sharedsummary["lennon"]                                 = "lennon";
555                 sharedsummary["morisitahorn"]                   = "morisitahorn";
556                 sharedsummary["braycurtis"]                             = "braycurtis";
557                 sharedsummary["odum"]                                   = "odum";
558                 sharedsummary["canberra"]                               = "canberra";
559                 sharedsummary["structeuclidean"]                = "structeuclidean";
560                 sharedsummary["structchord"]                    = "structchord";
561                 sharedsummary["hellinger"]                              = "hellinger";
562                 sharedsummary["manhattan"]                              = "manhattan";
563                 sharedsummary["structpearson"]                  = "structpearson";
564                 sharedsummary["structkulczynski"]               = "structkulczynski";
565                 sharedsummary["structchi2"]                             = "structchi2";
566                 sharedsummary["soergel"]                                = "soergel";
567                 sharedsummary["spearman"]                               = "spearman";
568                 sharedsummary["speciesprofile"]                 = "speciesprofile";
569                 sharedsummary["hamming"]                                = "hamming";
570                 sharedsummary["gower"]                                  = "gower";
571                 sharedsummary["memchi2"]                                = "memchi2";
572                 sharedsummary["memchord"]                               = "memchord";
573                 sharedsummary["memeuclidean"]                   = "memeuclidean";
574                 sharedsummary["mempearson"]                             = "mempearson";
575         sharedsummary["jsd"]                            = "jsd";
576                 sharedsummary["default"]                                = "default";
577         }
578         catch(exception& e) {
579                 m->errorOut(e, "ValidCalculator", "initialSharedSummary");
580                 exit(1);
581         }
582 }
583
584
585 /********************************************************************/
586
587 void ValidCalculators::initialSharedRarefact() {
588         try {   
589                 sharedrarefaction["sharedobserved"]     = "sharedobserved";
590                 sharedrarefaction["sharednseqs"]        = "sharednseqs";
591                 sharedrarefaction["default"]        = "default";
592         }
593         catch(exception& e) {
594                 m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
595                 exit(1);
596         }
597 }
598
599
600 /********************************************************************/
601 void ValidCalculators::initialVennSingle() {
602         try {
603                 vennsingle["sobs"]              = "sobs";
604                 vennsingle["chao"]                  = "chao";
605                 vennsingle["ace"]                       = "ace";
606                 vennsingle["jack"]                  = "jack";
607                 vennsingle["default"]           = "default";
608         }
609         catch(exception& e) {
610                 m->errorOut(e, "ValidCalculator", "initialVennSingle");
611                 exit(1);
612         }
613 }
614
615 /********************************************************************/
616 void ValidCalculators::initialVennShared() {
617         try {
618                 vennshared["sharedsobs"]        = "sharedsobs";
619                 vennshared["sharedchao"]        = "sharedchao";
620                 vennshared["sharedace"]         = "sharedace";
621                 vennshared["default"]           = "default";
622         }
623         catch(exception& e) {
624                 m->errorOut(e, "ValidCalculator", "initialVennShared");
625                 exit(1);
626         }
627 }
628
629 /********************************************************************/
630 void ValidCalculators::initialTreeGroups() {
631         try {   
632                 treegroup["sharedsobs"]                         = "sharedsobs";
633                 treegroup["sharedchao"]                         = "sharedchao";
634                 treegroup["sharedace"]                          = "sharedace";
635                 treegroup["jabund"]                                     = "jabund";
636                 treegroup["sorabund"]                           = "sorabund";
637                 treegroup["jclass"]                                     = "jclass";
638                 treegroup["sorclass"]                           = "sorclass";
639                 treegroup["jest"]                                       = "jest";
640                 treegroup["sorest"]                                     = "sorest";
641                 treegroup["thetayc"]                            = "thetayc";
642                 treegroup["thetan"]                                     = "thetan";
643                 treegroup["kstest"]                                     = "kstest";
644                 treegroup["whittaker"]                          = "whittaker";
645                 treegroup["sharednseqs"]                        = "sharednseqs";
646                 treegroup["ochiai"]                                     = "ochiai";
647                 treegroup["anderberg"]                          = "anderberg";
648                 treegroup["kulczynski"]                         = "kulczynski";
649                 treegroup["kulczynskicody"]                     = "kulczynskicody";
650                 treegroup["lennon"]                                     = "lennon";
651                 treegroup["morisitahorn"]                       = "morisitahorn";
652                 treegroup["braycurtis"]                         = "braycurtis";
653                 treegroup["odum"]                                       = "odum";
654                 treegroup["canberra"]                           = "canberra";
655                 treegroup["structeuclidean"]            = "structeuclidean";
656                 treegroup["structchord"]                        = "structchord";
657                 treegroup["hellinger"]                          = "hellinger";
658                 treegroup["manhattan"]                          = "manhattan";
659                 treegroup["structpearson"]                      = "structpearson";
660                 treegroup["structkulczynski"]           = "structkulczynski";
661                 treegroup["structchi2"]                         = "structchi2";
662                 treegroup["soergel"]                            = "soergel";
663                 treegroup["spearman"]                           = "spearman";
664                 treegroup["speciesprofile"]                     = "speciesprofile";
665                 treegroup["hamming"]                            = "hamming";
666                 treegroup["gower"]                                      = "gower";
667                 treegroup["memchi2"]                            = "memchi2";
668                 treegroup["memchord"]                           = "memchord";
669                 treegroup["memeuclidean"]                       = "memeuclidean";
670                 treegroup["mempearson"]                         = "mempearson";
671                 
672         }
673         catch(exception& e) {
674                 m->errorOut(e, "ValidCalculator", "initialTreeGroups");
675                 exit(1);
676         }
677 }
678 /********************************************************************/
679 void ValidCalculators::initialHeat() {
680         try {   
681                 heat["jabund"]                          = "jabund";
682                 heat["sorabund"]                        = "sorabund";
683                 heat["jclass"]                          = "jclass";
684                 heat["sorclass"]                        = "sorclass";
685                 heat["jest"]                            = "jest";
686                 heat["sorest"]                          = "sorest";
687                 heat["thetayc"]                         = "thetayc";
688                 heat["thetan"]                          = "thetan";
689                 heat["morisitahorn"]            = "morisitahorn";
690                 heat["braycurtis"]                      = "braycurtis";
691         }
692         catch(exception& e) {
693                 m->errorOut(e, "ValidCalculator", "initialHeat");
694                 exit(1);
695         }
696 }
697
698 /********************************************************************/
699 void ValidCalculators::initialMatrix() {
700         try {   
701                 matrix["sharedsobs"]                            = "sharedsobs";
702                 matrix["sharedchao"]                            = "sharedchao";
703                 matrix["sharedace"]                             = "sharedace";
704                 matrix["jabund"]                                        = "jabund";
705                 matrix["sorabund"]                              = "sorabund";
706                 matrix["jclass"]                                        = "jclass";
707                 matrix["sorclass"]                              = "sorclass";
708                 matrix["jest"]                                  = "jest";
709                 matrix["sorest"]                                        = "sorest";
710                 matrix["thetayc"]                               = "thetayc";
711                 matrix["thetan"]                                        = "thetan";
712                 matrix["kstest"]                                        = "kstest";
713                 matrix["whittaker"]                             = "whittaker";
714                 matrix["sharednseqs"]                   = "sharednseqs";
715                 matrix["ochiai"]                                        = "ochiai";
716                 matrix["anderberg"]                             = "anderberg";
717                 matrix["kulczynski"]                            = "kulczynski";
718                 matrix["kulczynskicody"]                        = "kulczynskicody";
719                 matrix["lennon"]                                        = "lennon";
720                 matrix["morisitahorn"]                  = "morisitahorn";
721                 matrix["braycurtis"]                            = "braycurtis";
722                 matrix["odum"]                                  = "odum";
723                 matrix["canberra"]                              = "canberra";
724                 matrix["structeuclidean"]               = "structeuclidean";
725                 matrix["structchord"]                   = "structchord";
726                 matrix["hellinger"]                             = "hellinger";
727                 matrix["manhattan"]                             = "manhattan";
728                 matrix["structpearson"]                 = "structpearson";
729                 matrix["structkulczynski"]              = "structkulczynski";
730                 matrix["structchi2"]                            = "structchi2";
731                 matrix["soergel"]                               = "soergel";
732                 matrix["spearman"]                              = "spearman";
733                 matrix["speciesprofile"]                        = "speciesprofile";
734                 matrix["hamming"]                               = "hamming";
735                 matrix["gower"]                                 = "gower";
736                 matrix["memchi2"]                               = "memchi2";
737                 matrix["memchord"]                              = "memchord";
738                 matrix["memeuclidean"]                  = "memeuclidean";
739                 matrix["mempearson"]                            = "mempearson";
740         matrix["jsd"]                           = "jsd";
741                 
742         }
743         catch(exception& e) {
744                 m->errorOut(e, "ValidCalculator", "initialMatrix");
745                 exit(1);
746         }
747 }
748
749 /********************************************************************/
750 void ValidCalculators::initialBoot() {
751         try {   
752                 boot["jabund"]                          = "jabund";
753                 boot["sorabund"]                        = "sorabund";
754                 boot["jclass"]                          = "jclass";
755                 boot["sorclass"]                        = "orclass";
756                 boot["jest"]                            = "jest";
757                 boot["sorest"]                          = "sorest";
758                 boot["thetayc"]                         = "thetayc";
759                 boot["thetan"]                          = "thetan";
760                 boot["morisitahorn"]            = "morisitahorn";
761                 boot["braycurtis"]                      = "braycurtis";
762         }
763         catch(exception& e) {
764                 m->errorOut(e, "ValidCalculator", "initialBoot");
765                 exit(1);
766         }
767 }
768 /********************************************************************/
769 void ValidCalculators::initialDistance() {
770         try {   
771                 distance["nogaps"]              = "nogaps";
772                 distance["eachgap"]             = "eachgap";
773                 distance["onegap"]              = "onegap";
774         }
775         catch(exception& e) {
776                 m->errorOut(e, "ValidCalculator", "initialDistance");
777                 exit(1);
778         }
779 }
780
781 /********************************************************************/
782 void ValidCalculators::printCalc(string parameter, ostream& out) {
783         try{
784                 out << "The available estimators for calc are ";
785                 //are you looking for a calculator for a single parameter
786                 if (parameter == "single") {
787                         for (it = single.begin(); it != single.end(); it++) {
788                                 out << it->first << ", ";
789                         }
790                 //are you looking for a calculator for a shared parameter
791                 }else if (parameter == "shared") {
792                         for (it = shared.begin(); it != shared.end(); it++) {
793                                 out << it->first << ", ";
794                         }
795                 //are you looking for a calculator for a rarefaction parameter
796                 }else if (parameter == "rarefaction") {
797                         for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
798                                 out << it->first << ", ";
799                         }
800                 //are you looking for a calculator for a summary parameter
801                 }else if (parameter == "summary") {
802                         for (it = summary.begin(); it != summary.end(); it++) {
803                                 out << it->first << ", ";
804                         }
805                 //are you looking for a calculator for a sharedsummary parameter
806                 }else if (parameter == "sharedsummary") {
807                         for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
808                                 out << it->first << ", ";
809                         }
810                 }else if (parameter == "sharedrarefaction") {
811                         for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
812                                 out << it->first << ", ";
813                         }
814                 }else if (parameter == "vennsingle") {
815                         for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
816                                 out << it->first << ", ";
817                         }
818                 }else if (parameter == "vennshared") {
819                         for (it = vennshared.begin(); it != vennshared.end(); it++) {
820                                 out << it->first << ", ";
821                         }
822                 }else if (parameter == "treegroup") {
823                         for (it = treegroup.begin(); it != treegroup.end(); it++) {
824                                 out << it->first << ", ";
825                         }
826                 }else if (parameter == "matrix") {
827                         for (it = matrix.begin(); it != matrix.end(); it++) {
828                                 out << it->first << ", ";
829                         }
830                 }else if (parameter == "heat") {
831                         for (it = heat.begin(); it != heat.end(); it++) {
832                                 out << it->first << ", ";
833                         }
834                 }else if (parameter == "boot") {
835                         for (it = boot.begin(); it != boot.end(); it++) {
836                                 out << it->first << ", ";
837                         }
838                 }else if (parameter == "distance") {
839                         for (it = distance.begin(); it != distance.end(); it++) {
840                                 out << it->first << ", ";
841                         }
842                 }
843
844                 out << endl;
845         }
846         catch(exception& e) {
847                 m->errorOut(e, "ValidCalculator", "printCalc");
848                 exit(1);
849         }
850 }
851 /********************************************************************/
852 string ValidCalculators::printCalc(string parameter) {
853         try{
854                 string output = "The available estimators for calc are ";
855                 //are you looking for a calculator for a single parameter
856                 if (parameter == "single") {
857                         for (it = single.begin(); it != single.end(); it++) {
858                                 output += it->first + ", ";
859                         }
860                         //are you looking for a calculator for a shared parameter
861                 }else if (parameter == "shared") {
862                         for (it = shared.begin(); it != shared.end(); it++) {
863                                 output += it->first + ", ";
864                         }
865                         //are you looking for a calculator for a rarefaction parameter
866                 }else if (parameter == "rarefaction") {
867                         for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
868                                 output += it->first + ", ";
869                         }
870                         //are you looking for a calculator for a summary parameter
871                 }else if (parameter == "summary") {
872                         for (it = summary.begin(); it != summary.end(); it++) {
873                                 output += it->first + ", ";
874                         }
875                         //are you looking for a calculator for a sharedsummary parameter
876                 }else if (parameter == "sharedsummary") {
877                         for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
878                                 output += it->first + ", ";
879                         }
880                 }else if (parameter == "sharedrarefaction") {
881                         for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
882                                 output += it->first + ", ";
883                         }
884                 }else if (parameter == "vennsingle") {
885                         for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
886                                 output += it->first + ", ";
887                         }
888                 }else if (parameter == "vennshared") {
889                         for (it = vennshared.begin(); it != vennshared.end(); it++) {
890                                 output += it->first + ", ";
891                         }
892                 }else if (parameter == "treegroup") {
893                         for (it = treegroup.begin(); it != treegroup.end(); it++) {
894                                 output += it->first + ", ";
895                         }
896                 }else if (parameter == "matrix") {
897                         for (it = matrix.begin(); it != matrix.end(); it++) {
898                                 output += it->first + ", ";
899                         }
900                 }else if (parameter == "heat") {
901                         for (it = heat.begin(); it != heat.end(); it++) {
902                                 output += it->first + ", ";
903                         }
904                 }else if (parameter == "boot") {
905                         for (it = boot.begin(); it != boot.end(); it++) {
906                                 output += it->first + ", ";
907                         }
908                 }else if (parameter == "distance") {
909                         for (it = distance.begin(); it != distance.end(); it++) {
910                                 output += it->first + ", ";
911                         }
912                 }
913                 
914                 //rip off comma
915                 output = output.substr(0, output.length()-1);
916                 output += "\n";
917                 
918                 return output;
919         }
920         catch(exception& e) {
921                 m->errorOut(e, "ValidCalculator", "printCalc");
922                 exit(1);
923         }
924 }
925 /********************************************************************/
926
927