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