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