]> git.donarmstrong.com Git - mothur.git/blob - venn.cpp
added checks for ^C to quit command instead of program
[mothur.git] / venn.cpp
1 /*
2  *  venn.cpp
3  *  Mothur
4  *
5  *  Created by Sarah Westcott on 3/30/09.
6  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
7  *
8  */
9
10 #include "venn.h"
11 #include "ace.h"
12 #include "sobs.h"
13 #include "chao1.h"
14 #include "sharedchao1.h"
15 #include "sharedsobscollectsummary.h"
16
17
18 //**********************************************************************************************************************
19 Venn::Venn(string o) : outputDir(o) {
20         try {
21                 globaldata = GlobalData::getInstance();
22                 m = MothurOut::getInstance();
23
24         }
25         catch(exception& e) {
26                 m->errorOut(e, "Venn", "Venn");
27                 exit(1);
28         }
29 }
30 //**********************************************************************************************************************
31 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
32         try {
33                 
34                 vector<string> outputNames;
35                 
36                 for(int i=0;i<vCalcs.size();i++){
37                         string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + ".venn." + sabund->getLabel() + vCalcs[i]->getName() + ".svg";
38                         outputNames.push_back(filenamesvg);
39                         openOutputFile(filenamesvg, outsvg);
40                         
41                         if (m->control_pressed) { outsvg.close(); return outputNames; }
42
43                         vector<double> data = vCalcs[i]->getValues(sabund);
44                         
45                         //svg image
46                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
47                         outsvg << "<g>\n";
48                                 
49                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
50                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
51                         outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>"; 
52                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";  
53                         
54                         if (data.size() == 3) { 
55                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"380\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
56                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"410\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
57                         }
58                         
59                         outsvg << "</g>\n</svg>\n";
60                         outsvg.close();
61                 }
62                 
63                 return outputNames;
64         }
65         catch(exception& e) {
66                 m->errorOut(e, "Venn", "getPic");
67                 exit(1);
68         }
69 }
70 //**********************************************************************************************************************
71 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
72         try {
73                 
74                 vector<SharedRAbundVector*> subset;
75                 vector<string> outputNames;
76                 
77                 /******************* 1 Group **************************/
78                 if (lookup.size() == 1) {
79                                         
80                         SAbundVector s;
81                         s = lookup[0]->getSAbundVector();  SAbundVector* sabund = &s;
82                         
83                         //make a file for each calculator
84                         for(int i=0;i<vCalcs.size();i++){
85                                 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
86                                 outputNames.push_back(filenamesvg);
87                                 openOutputFile(filenamesvg, outsvg);
88                                 
89                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
90                                 
91                                 //in essence you want to run it like a single 
92                                 if (vCalcs[i]->getName() == "sharedsobs") {
93                                         singleCalc = new Sobs();
94                                 }else if (vCalcs[i]->getName() == "sharedchao") {
95                                         singleCalc = new Chao1();
96                                 }else if (vCalcs[i]->getName() == "sharedace") {
97                                         singleCalc = new Ace(10);
98                                 }
99                                 
100                                 vector<double> data = singleCalc->getValues(sabund);
101                         
102                                 //svg image
103                                 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
104                                 outsvg << "<g>\n";
105                                 
106                                 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
107                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
108                                 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"350\" cy=\"200\" r=\"150\"/>"; 
109                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"165\">" + lookup[0]->getGroup() + "</text>\n";
110                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(data[0]).length() / 2)) + "\" y=\"195\">" + toString(data[0]) + "</text>\n";  
111                         
112                                 if (data.size() == 3) { 
113                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"380\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
114                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"200\" y=\"410\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
115                                 }
116                         
117                                 outsvg << "</g>\n</svg>\n";
118                                 outsvg.close();
119                                 delete singleCalc;
120                                 
121                         }
122                 /******************* 2 Groups **************************/       
123                 
124                 }else if (lookup.size() == 2) {
125                         //get sabund vector pointers so you can use the single calculators
126                         //one for each group
127                         SAbundVector sA, sB;
128                         SAbundVector* sabundA; SAbundVector* sabundB;
129                         sabundA = new SAbundVector(lookup[0]->getSAbundVector());//  sabundA = &sA;
130                         sabundB = new SAbundVector(lookup[1]->getSAbundVector());//  sabundB = &sB;
131                         
132                         subset.clear();
133                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
134                         
135                         //make a file for each calculator
136                         for(int i=0;i<vCalcs.size();i++){
137                                 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
138                                 outputNames.push_back(filenamesvg);
139                                 openOutputFile(filenamesvg, outsvg);
140                                 
141                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
142                                 
143                                 //get estimates for sharedAB
144                                 vector<double> shared = vCalcs[i]->getValues(subset);
145                                 
146                                 //in essence you want to run it like a single 
147                                 if (vCalcs[i]->getName() == "sharedsobs") {
148                                         singleCalc = new Sobs();
149                                 }else if (vCalcs[i]->getName() == "sharedchao") {
150                                         singleCalc = new Chao1();
151                                 }//else if (vCalcs[i]->getName() == "sharedace") {
152                                         //singleCalc = new Ace(10);
153                                 //}
154                                 
155                                 //get estimates for numA
156                                 vector<double> numA = singleCalc->getValues(sabundA);
157
158                                 //get estimates for numB
159                                 vector<double> numB = singleCalc->getValues(sabundB);
160                                                 
161                                 //image window
162                                 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
163                                 outsvg << "<g>\n";
164
165                                 //draw circles
166                                 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"700\"/>"; 
167                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
168                                 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"250\" cy=\"200\" r=\"150\"/>"; 
169                                 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"435\" cy=\"200\" r=\"150\"/>"; 
170                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]).length() / 2)) + "\" y=\"195\">" + toString(numA[0] - shared[0]) + "</text>\n";
171                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(numB[0]).length() / 2)) + "\" y=\"195\">" + toString(numB[0] - shared[0]) + "</text>\n"; 
172                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"175\">" + lookup[0]->getGroup() + "</text>\n";
173                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"175\">" + lookup[1]->getGroup() + "</text>\n"; 
174                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(shared[0]).length() / 2)) + "\" y=\"195\">" + toString(shared[0]) + "</text>\n";  
175                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"460\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
176                                 if (numA.size() == 3) { 
177                                         outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
178                                 }else { outsvg << "</text>\n"; }
179                 
180                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"480\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
181                                 if (numB.size() == 3) { 
182                                         outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
183                                 }else { outsvg << "</text>\n"; }
184
185                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"500\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]) + "</text>\n";
186                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"520\">Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "</text>\n";
187                                 outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"540\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "</text>\n";
188                                 
189                                 //close file
190                                 outsvg << "</g>\n</svg>\n";
191                                 outsvg.close();
192                                 delete singleCalc;
193                         }
194                 /******************* 3 Groups **************************/
195                                                 
196                 }else if (lookup.size() == 3) {
197                         //get sabund vector pointers so you can use the single calculators
198                         //one for each group
199                         SAbundVector sA, sB, sC;
200                         SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
201                         sA = lookup[0]->getSAbundVector();  sabundA = &sA;
202                         sB = lookup[1]->getSAbundVector();  sabundB = &sB;
203                         sC = lookup[2]->getSAbundVector();  sabundC = &sC;
204                 
205                         //make a file for each calculator
206                         for(int i=0;i<vCalcs.size();i++){
207                         
208                                 string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
209                                 outputNames.push_back(filenamesvg);
210                                 openOutputFile(filenamesvg, outsvg);
211                                 
212                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
213                                 
214                                 if (vCalcs[i]->getName() == "sharedace") {
215                                 
216                                         singleCalc = new Ace(10);
217                                         
218                                         //get estimates for numA
219                                         vector<double> numA = singleCalc->getValues(sabundA);
220                         
221                                         //get estimates for numB
222                                         vector<double> numB = singleCalc->getValues(sabundB);
223                                 
224                                         //get estimates for numC
225                                         vector<double> numC = singleCalc->getValues(sabundC);
226
227
228                                         //get estimates for sharedAB, sharedAC and sharedBC
229                                         subset.clear();
230                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
231                                         vector<double> sharedAB = vCalcs[i]->getValues(subset);
232                                         
233                                         subset.clear();
234                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
235                                         vector<double> sharedAC = vCalcs[i]->getValues(subset);
236                                         
237                                         subset.clear();
238                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
239                                         vector<double> sharedBC = vCalcs[i]->getValues(subset);
240                                         
241                                         vector<double> sharedAwithBC;
242                                         vector<double> sharedBwithAC;
243                                         vector<double> sharedCwithAB;
244                                         
245                                         //find possible sharedABC values
246                                         float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
247
248                                         if (vCalcs[i]->getMultiple() == false) {
249                                                 //merge BC and estimate with shared with A
250                                                 SharedRAbundVector* merge = new SharedRAbundVector();
251                                                 for (int j = 0; j < lookup[1]->size(); j++) {
252                                                         merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
253                                                 }
254                                         
255                                                 subset.clear();
256                                                 subset.push_back(lookup[0]); subset.push_back(merge);
257                                                 sharedAwithBC = vCalcs[i]->getValues(subset);
258                                 
259                                                 delete merge;
260                                                 //merge AC and estimate with shared with B
261                                                 merge = new SharedRAbundVector();
262                                                 for (int j = 0; j < lookup[0]->size(); j++) {
263                                                         merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
264                                                 }
265                                         
266                                                 subset.clear();
267                                                 subset.push_back(merge); subset.push_back(lookup[1]);
268                                                 sharedBwithAC = vCalcs[i]->getValues(subset);
269                                 
270                                                 delete merge;
271                                                 //merge AB and estimate with shared with C
272                                                 merge = new SharedRAbundVector();
273                                                 for (int j = 0; j < lookup[0]->size(); j++) {
274                                                         merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
275                                                 }
276                                         
277                                                 subset.clear();
278                                                 subset.push_back(lookup[2]); subset.push_back(merge);
279                                                 sharedCwithAB = vCalcs[i]->getValues(subset);
280                                                 delete merge;
281                                         
282                                                 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
283                                                 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
284                                                 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
285          
286                                                 //if any of the possible m's are - throw them out
287                                                 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
288                                                 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
289                                                 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
290                         
291                                                 //sharedABC is the minimum of the 3 possibilities
292                                                 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
293                                                 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
294                                                 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }    
295                                         }else{
296                                                 vector<double> data = vCalcs[i]->getValues(lookup);
297                                                 sharedABC = data[0];
298                                                 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
299                                                 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
300                                                 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
301                                         }
302                                         
303                                         //image window
304                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 800 800\" >\n";
305                                         outsvg << "<g>\n";
306
307                                         //draw circles
308                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"800\" height=\"800\"/>"; 
309                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
310                                         outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>"; 
311                                         outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>"; 
312                                         outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>"; 
313
314                                         //place labels within overlaps
315                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"170\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n"; 
316                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "</text>\n";  
317                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\"  y=\"170\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";  
318                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\"  y=\"170\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
319                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"150\">" + lookup[1]->getGroup() + "</text>\n";  
320                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(268 - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\"  y=\"305\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";  
321                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\"   y=\"430\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n"; 
322                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"410\">" + lookup[2]->getGroup() + "</text>\n"; 
323                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"305\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";  
324                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"280\">" + toString(sharedABC) + "</text>\n"; 
325                                 
326                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]) + "</text>\n";
327                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]) + "</text>\n";
328                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]) + "</text>\n";
329                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"720\">The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
330                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"740\">The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
331                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"760\">The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
332                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"580\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
333                                         if (numA.size() == 3) { 
334                                                 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
335                                         }else { outsvg << "</text>\n"; }
336                         
337                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"600\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
338                                         if (numB.size() == 3) { 
339                                                 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
340                                         }else { outsvg << "</text>\n"; }
341                                         
342                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"620\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
343                                         if (numC.size() == 3) { 
344                                                 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "</text>\n";
345                                         }else { outsvg << "</text>\n"; }
346
347                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"640\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
348                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"780\">The total shared richness is " + toString(sharedABC) + "</text>\n";
349                                         
350                                         delete singleCalc;
351                                         
352                                 }else { //sharedchao and sharedsobs are multigroup
353                                         
354                                         vector<SharedRAbundVector*> subset;
355
356                                         //get estimates for numA
357                                         subset.push_back(lookup[0]);
358                                         vector<double> numA = vCalcs[i]->getValues(subset);
359                         
360                                         //get estimates for numB
361                                         subset.clear();
362                                         subset.push_back(lookup[1]);
363                                         vector<double> numB = vCalcs[i]->getValues(subset);
364                                 
365                                         //get estimates for numC
366                                         subset.clear();
367                                         subset.push_back(lookup[2]);
368                                         vector<double> numC = vCalcs[i]->getValues(subset);
369
370                                         subset.clear();
371                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
372                                         vector<double> sharedab =  vCalcs[i]->getValues(subset);
373                                         
374                                         subset.clear(); 
375                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
376                                         vector<double> sharedac =  vCalcs[i]->getValues(subset);
377                                         
378                                         subset.clear(); 
379                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
380                                         vector<double> sharedbc =  vCalcs[i]->getValues(subset);
381                                         
382                                         subset.clear(); 
383                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
384                                         vector<double> sharedabc =  vCalcs[i]->getValues(subset);
385                                         
386                                         //image window
387                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 800 800\" >\n";
388                                         outsvg << "<g>\n";
389
390                                         //draw circles
391                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"800\" height=\"800\"/>"; 
392                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
393                                         outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>"; 
394                                         outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>"; 
395                                         outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>"; 
396
397                                         //place labels within overlaps
398                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]).length() / 2)) + "\" y=\"170\">" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "</text>\n"; 
399                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "</text>\n";  
400                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedab[0] - sharedabc[0]).length() / 2)) + "\"  y=\"170\">" + toString(sharedab[0] - sharedabc[0]) + "</text>\n";  
401                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"  y=\"170\">" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
402                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(485 - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"150\">" + lookup[1]->getGroup() + "</text>\n";  
403                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(268 - ((int)toString(sharedac[0] - sharedabc[0]).length() / 2)) + "\"  y=\"305\">" + toString(sharedac[0] - sharedabc[0]) + "</text>\n";  
404                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"   y=\"430\">" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "</text>\n"; 
405                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(343 - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"410\">" + lookup[2]->getGroup() + "</text>\n"; 
406                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(408 - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"305\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";  
407                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(343 - ((int)toString(sharedabc[0]).length() / 2)) + "\"  y=\"280\">" + toString(sharedabc[0]) + "</text>\n"; 
408                                 
409                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"660\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]) + "</text>\n";
410                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"680\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]) + "</text>\n";
411                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"700\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]) + "</text>\n";
412                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"580\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
413                                         if (numA.size() == 3) { 
414                                                 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "</text>\n";
415                                         }else { outsvg << "</text>\n"; }
416                         
417                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"600\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
418                                         if (numB.size() == 3) { 
419                                                 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "</text>\n";
420                                         }else { outsvg << "</text>\n"; }
421                                         
422                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"620\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
423                                         if (numC.size() == 3) { 
424                                                 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "</text>\n";
425                                         }else { outsvg << "</text>\n"; }
426
427                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"640\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "</text>\n";
428                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"720\">The total shared richness is " + toString(sharedabc[0]) + "</text>\n";
429
430
431                                 }
432                 
433                                                                 
434                                 //close file
435                                 outsvg << "</g>\n</svg>\n";
436                                 outsvg.close();
437                                 
438
439                         }
440                         
441                 /******************* 4 Groups **************************/
442                 
443                 }else if (lookup.size() == 4) {
444                         //calc the shared otu
445                         float sharedABCD = 0;
446                         float numA = 0; float numB = 0; float numC = 0; float numD = 0;
447                         float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
448                         float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
449                         vector<double> data;
450                         //get sabund vector pointers so you can use the single calculators
451                         //one for each group
452                         SAbundVector sA, sB, sC, sD;
453                         SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
454                         sA = lookup[0]->getSAbundVector();  sabundA = &sA;
455                         sB = lookup[1]->getSAbundVector();  sabundB = &sB;
456                         sC = lookup[2]->getSAbundVector();  sabundC = &sC;
457                         sD = lookup[3]->getSAbundVector();  sabundD = &sD;
458                         
459                         //A = red, B = green, C = blue, D = yellow
460                         
461                         //make a file for each calculator
462                         for(int i=0;i<vCalcs.size();i++){
463                                 
464                                 if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups.  It will be disregarded. "); m->mothurOutEndLine(); }
465                                 else{
466                                         string filenamesvg = outputDir + getSimpleName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
467                                         outputNames.push_back(filenamesvg);
468                                         openOutputFile(filenamesvg, outsvg);
469
470                                         if (m->control_pressed) { outsvg.close(); return outputNames; }
471                                         
472                                         //in essence you want to run it like a single 
473                                         if (vCalcs[i]->getName() == "sharedsobs") {
474                                                 singleCalc = new Sobs();
475                                         }else if (vCalcs[i]->getName() == "sharedchao") {
476                                                 singleCalc = new Chao1();
477                                         }
478                                 
479                                         //get estimates for numA
480                                         data = singleCalc->getValues(sabundA);
481                                         numA = data[0];
482         //cout << "num a = " << numA << endl;   
483                         
484                                         //get estimates for numB
485                                         data = singleCalc->getValues(sabundB);
486                                         numB = data[0];
487         //cout << "num b = " << numB << endl;                           
488                                         //get estimates for numC
489                                         data = singleCalc->getValues(sabundC);
490                                         numC = data[0];
491         //cout << "num c = " << numC << endl;                           
492                                         //get estimates for numD
493                                         data = singleCalc->getValues(sabundD);
494                                         numD = data[0];
495 //cout << "num d = " << numD << endl;   
496
497                                         //get estimates for pairs
498                                         subset.clear();
499                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
500                                         data = vCalcs[i]->getValues(subset);
501                                         sharedAB = data[0];
502         //cout << "num ab = " << sharedAB << endl;                      
503                                         subset.clear();
504                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
505                                         data = vCalcs[i]->getValues(subset);
506                                         sharedAC = data[0];
507         //cout << "num ac = " << sharedAC << endl;                              
508                                         subset.clear();
509                                         subset.push_back(lookup[0]); subset.push_back(lookup[3]);
510                                         data = vCalcs[i]->getValues(subset);
511                                         sharedAD = data[0];
512         //cout << "num ad = " << sharedAD << endl;                      
513                                         subset.clear();
514                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
515                                         data = vCalcs[i]->getValues(subset);
516                                         sharedBC = data[0];
517         //cout << "num bc = " << sharedBC << endl;                              
518                                         subset.clear();
519                                         subset.push_back(lookup[1]); subset.push_back(lookup[3]);
520                                         data = vCalcs[i]->getValues(subset);
521                                         sharedBD = data[0];
522                 //cout << "num bd = " << sharedBD << endl;                                              
523                                         subset.clear();
524                                         subset.push_back(lookup[2]); subset.push_back(lookup[3]);
525                                         data = vCalcs[i]->getValues(subset);
526                                         sharedCD = data[0];
527                                                 
528         //cout << "num cd = " << sharedCD << endl;                              
529                                         //get estimates for combos of 3
530                                         subset.clear();
531                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
532                                         data = vCalcs[i]->getValues(subset);
533                                         sharedABC = data[0];
534                 //cout << "num abc = " << sharedABC << endl;                                    
535                                         subset.clear();
536                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
537                                         data = vCalcs[i]->getValues(subset);
538                                         sharedACD = data[0];
539                         //cout << "num acd = " << sharedACD << endl;    
540                                         subset.clear();
541                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
542                                         data = vCalcs[i]->getValues(subset);
543                                         sharedBCD = data[0];
544                 //cout << "num bcd = " << sharedBCD << endl;            
545                                         subset.clear();
546                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
547                                         data = vCalcs[i]->getValues(subset);
548                                         sharedABD = data[0];
549 //cout << "num abd = " << sharedABD << endl;
550                                         //get estimate for all four
551                                         data = vCalcs[i]->getValues(lookup);
552                                         sharedABCD = data[0];
553                 //cout << "num abcd = " << sharedABCD << endl << endl;  
554                 
555                                 
556                                                 
557                                         //image window
558                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 800\" >\n";
559                                         outsvg << "<g>\n";
560                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"700\" height=\"800\"/>"; 
561                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"265\" y=\"30\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
562
563                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"490\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA) + "</text>\n";
564                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"510\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB) + "</text>\n";
565                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"530\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC) + "</text>\n";
566                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"550\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD) + "</text>\n";
567                                         
568                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"570\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB) + "</text>\n";
569                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"590\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC) + "</text>\n";
570                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"610\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD) + "</text>\n";
571                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"630\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC) + "</text>\n";
572                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"650\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD) + "</text>\n";
573                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"670\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD) + "</text>\n";
574                                         
575                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"690\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC) + "</text>\n";
576                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"710\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD) + "</text>\n";
577                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"730\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD) + "</text>\n";
578                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"750\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD) + "</text>\n";
579                                                                         
580                                         //make adjustments
581                                         sharedABC = sharedABC - sharedABCD;
582                         //cout << "num abc = " << sharedABC << endl;            
583                                         sharedABD = sharedABD - sharedABCD;
584                                 //cout << "num abd = " << sharedABD << endl;
585                                         sharedACD = sharedACD - sharedABCD;
586                                 //cout << "num acd = " << sharedACD << endl;
587                                         sharedBCD = sharedBCD - sharedABCD;
588                                 //cout << "num bcd = " << sharedBCD << endl;
589                                         
590                                         sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD;  //cout << "num ab = " << sharedAB << endl;
591                                         sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD;  //cout << "num ac = " << sharedAC << endl;
592                                         sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD;  //cout << "num ad = " << sharedAD << endl;                           
593                                         sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD;  //cout << "num bc = " << sharedBC << endl;
594                                         sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl; 
595                                         sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD;  //cout << "num cd = " << sharedCD << endl;
596                                         
597                                         numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
598                         //cout << "num a = " << numA << endl;           
599                                         numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
600                         //cout << "num b = " << numB << endl;           
601                                         numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
602                         //cout << "num c = " << numC << endl;           
603                                         numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
604                         //cout << "num d = " << numD << endl;           
605                                         
606                                         //draw circles
607                                         outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n "; 
608                                         outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 355 215) \" cx=\"355\" cy=\"215\" rx=\"200\" ry=\"115\"/>\n ";
609                                         outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 440 315) \" cx=\"440\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
610                                         outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 270 315) \" cx=\"270\" cy=\"315\" rx=\"200\" ry=\"115\"/>\n ";
611                         
612                                         //A = red, B = green, C = blue, D = yellow
613                         
614                                         //place labels within overlaps
615                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)toString(numA).length() / 2)) + "\" y=\"110\">" + toString(numA)  + "</text>\n"; 
616                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(460 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "</text>\n";  
617                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedAB).length() / 2)) + "\"  y=\"160\">" + toString(sharedAB) + "</text>\n";  
618                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)toString(numB).length() / 2)) + "\"  y=\"110\">" + toString(numB)  + "</text>\n";  
619                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(250 - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"90\">" + lookup[1]->getGroup() + "</text>\n"; 
620                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(490 - ((int)toString(sharedAC).length() / 2)) + "\"  y=\"190\">" + toString(sharedAC) + "</text>\n";  
621                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(550 - ((int)toString(numC).length() / 2)) + "\"   y=\"230\">" + toString(numC) + "</text>\n";  
622                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(550 - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"210\">" + lookup[2]->getGroup() + "</text>\n";
623                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBD).length() / 2)) + "\" y=\"190\">" + toString(sharedBD) + "</text>\n";  
624                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(150 - ((int)toString(numD).length() / 2)) + "\"   y=\"230\">" + toString(numD) + "</text>\n";  
625                                         outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(150 - ((int)lookup[3]->getGroup().length() / 2)) + "\"   y=\"210\">" + lookup[3]->getGroup() + "</text>\n"; 
626                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedAD).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n"; 
627                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBC) + "</text>\n";
628                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n"; 
629                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n"; 
630                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
631                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(305 - ((int)toString(sharedACD).length() / 2)) + "\" y=\"360\">" + toString(sharedACD) + "</text>\n"; 
632                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(440 - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"240\">" + toString(sharedABC) + "</text>\n"; 
633                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedABCD).length() / 2)) + "\"  y=\"320\">" + toString(sharedABCD) + "</text>\n"; 
634                                         
635                                         
636                                                                                 
637                                         outsvg << "<text fill=\"black\" class=\"seri\" x=\"175\" y=\"770\">The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD)) + "</text>\n";
638                                         
639
640                                         outsvg << "</g>\n</svg>\n";
641                                         outsvg.close();
642                                         delete singleCalc;
643                                 }
644                         }
645                 }
646                 
647                 return outputNames;
648                 
649         }
650         catch(exception& e) {
651                 m->errorOut(e, "Venn", "getPic");
652                 exit(1);
653         }
654 }
655
656