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