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