]> git.donarmstrong.com Git - mothur.git/blob - venn.cpp
added cluster.fragments command as well as the nseqs parameter to the venn command
[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 "nseqs.h"
15 #include "sharedchao1.h"
16 #include "sharedsobscollectsummary.h"
17
18
19 //**********************************************************************************************************************
20 Venn::Venn(string o, bool n) : outputDir(o), nseqs(n) {
21         try {
22                 globaldata = GlobalData::getInstance();
23                 m = MothurOut::getInstance();
24
25         }
26         catch(exception& e) {
27                 m->errorOut(e, "Venn", "Venn");
28                 exit(1);
29         }
30 }
31 //**********************************************************************************************************************
32 vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
33         try {
34                 
35                 vector<string> outputNames;
36                 
37                 for(int i=0;i<vCalcs.size();i++){
38                         string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
39                         outputNames.push_back(filenamesvg);
40                         m->openOutputFile(filenamesvg, outsvg);
41                         
42                         if (m->control_pressed) { outsvg.close(); return outputNames; }
43
44                         vector<double> data = vCalcs[i]->getValues(sabund);
45                         
46                         int width = 1500;
47                         int height = 1500;
48                         
49                         //svg image
50                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \" >\n";
51                         outsvg << "<g>\n";
52                                 
53                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
54                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
55                         outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" +  toString(int(0.50 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
56                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString((width / 2) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(data[0]) + "</text>\n";  
57                         
58                         if (data.size() == 3) { 
59                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.60 * height)) +  "\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
60                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.645 * height)) +  "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
61                         }
62                         
63                         if (nseqs) {
64                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.70 * height)) +  "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
65                         }
66                         
67                         outsvg << "</g>\n</svg>\n";
68                         outsvg.close();
69                 }
70                 
71                 return outputNames;
72         }
73         catch(exception& e) {
74                 m->errorOut(e, "Venn", "getPic");
75                 exit(1);
76         }
77 }
78 //**********************************************************************************************************************
79 vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
80         try {
81                 
82                 vector<SharedRAbundVector*> subset;
83                 vector<string> outputNames;
84                 
85                 int width = 1500;
86                 int height = 1500;
87                 
88                 /******************* 1 Group **************************/
89                 if (lookup.size() == 1) {
90                                         
91                         SAbundVector s;
92                         s = lookup[0]->getSAbundVector();  SAbundVector* sabund = &s;
93                         
94                         //make a file for each calculator
95                         for(int i=0;i<vCalcs.size();i++){
96                                 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
97                                 outputNames.push_back(filenamesvg);
98                                 m->openOutputFile(filenamesvg, outsvg);
99                                 
100                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
101                                 
102                                 //in essence you want to run it like a single 
103                                 if (vCalcs[i]->getName() == "sharedsobs") {
104                                         singleCalc = new Sobs();
105                                 }else if (vCalcs[i]->getName() == "sharedchao") {
106                                         singleCalc = new Chao1();
107                                 }else if (vCalcs[i]->getName() == "sharedace") {
108                                         singleCalc = new Ace(10);
109                                 }
110                                 
111                                 vector<double> data = singleCalc->getValues(sabund);
112                         
113                                 //svg image
114                                 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \">\n";
115                                 outsvg << "<g>\n";
116                                 
117                                 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
118                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
119                                 outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" +  toString(int(0.50 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
120                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.50 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.24 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";
121                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.50 * width) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(data[0]) + "</text>\n";  
122                         
123                                 if (data.size() == 3) { 
124                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.60 * height)) +  "\" >The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
125                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.645 * height)) +  "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
126                                 }
127                                 
128                                 if (nseqs) {
129                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.70 * height)) +  "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
130                                 }
131                                 
132                                 outsvg << "</g>\n</svg>\n";
133                                 outsvg.close();
134                                 delete singleCalc;
135                                 
136                         }
137                 /******************* 2 Groups **************************/       
138                 
139                 }else if (lookup.size() == 2) {
140                         //get sabund vector pointers so you can use the single calculators
141                         //one for each group
142                         SAbundVector sA, sB;
143                         SAbundVector* sabundA; SAbundVector* sabundB;
144                         sabundA = new SAbundVector(lookup[0]->getSAbundVector());//  sabundA = &sA;
145                         sabundB = new SAbundVector(lookup[1]->getSAbundVector());//  sabundB = &sB;
146                         
147                         subset.clear();
148                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
149                         
150                         //make a file for each calculator
151                         for(int i=0;i<vCalcs.size();i++){
152                                 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
153
154                                 outputNames.push_back(filenamesvg);
155                                 m->openOutputFile(filenamesvg, outsvg);
156                                 
157                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
158                                 
159                                 //get estimates for sharedAB
160                                 vector<double> shared = vCalcs[i]->getValues(subset);
161                                 
162                                 //in essence you want to run it like a single 
163                                 if (vCalcs[i]->getName() == "sharedsobs") {
164                                         singleCalc = new Sobs();
165                                 }else if (vCalcs[i]->getName() == "sharedchao") {
166                                         singleCalc = new Chao1();
167                                 }//else if (vCalcs[i]->getName() == "sharedace") {
168                                         //singleCalc = new Ace(10);
169                                 //}
170                                 
171                                 int sharedVal, numSeqsA, numSeqsB;
172                                 if (nseqs) {
173                                         NSeqs* nseqsCalc = new NSeqs();
174                                         vector<double> data = nseqsCalc->getValues(lookup);
175                                         
176                                         sharedVal = data[0] + data[1];
177                                         numSeqsA = sabundA->getNumSeqs();
178                                         numSeqsB = sabundB->getNumSeqs();
179                                         
180                                         delete nseqsCalc;
181                                 }
182                                 
183                                 
184                                 //get estimates for numA
185                                 vector<double> numA = singleCalc->getValues(sabundA);
186
187                                 //get estimates for numB
188                                 vector<double> numB = singleCalc->getValues(sabundB);
189                                                 
190                                 //image window
191                                 outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \" >\n";
192                                 outsvg << "<g>\n";
193
194                                 //draw circles
195                                 outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
196                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
197                                 outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.36 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
198                                 outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.62 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
199                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(numA[0] - shared[0]) + "</text>\n";
200                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(numB[0] - shared[0]) + "</text>\n"; 
201                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.25 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";
202                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.25 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n"; 
203                                 outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(shared[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(shared[0]) + "</text>\n";  
204                                 outsvg << "<text fill=\"black\" class=\"seri\"   font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.66 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
205                                 if (numA.size() == 3) { 
206                                         outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
207                                 }
208                                 if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
209                                 outsvg << "</text>\n";
210                 
211                                 outsvg << "<text fill=\"black\" class=\"seri\"   font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.69 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
212                                 if (numB.size() == 3) { 
213                                         outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
214                                 }
215                                 if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
216                                 outsvg << "</text>\n";
217
218                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.72 * height)) +  "\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]);
219                                 if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal);  }  
220                                 outsvg << "</text>\n";
221                                 
222                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">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";
223                                 outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.78 * height)) +  "\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0]))+ "</text>\n";;
224                                 
225                                 
226                                 //close file
227                                 outsvg << "</g>\n</svg>\n";
228                                 outsvg.close();
229                                 delete singleCalc;
230                         }
231                 /******************* 3 Groups **************************/
232                                                 
233                 }else if (lookup.size() == 3) {
234                         
235                         height = 1600;
236                         int windowSize = height;
237         
238                         
239                         //get sabund vector pointers so you can use the single calculators
240                         //one for each group
241                         SAbundVector sA, sB, sC;
242                         SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
243                         sA = lookup[0]->getSAbundVector();  sabundA = &sA;
244                         sB = lookup[1]->getSAbundVector();  sabundB = &sB;
245                         sC = lookup[2]->getSAbundVector();  sabundC = &sC;
246                 
247                         //make a file for each calculator
248                         for(int i=0;i<vCalcs.size();i++){
249                         
250                                 string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
251
252                                 outputNames.push_back(filenamesvg);
253                                 m->openOutputFile(filenamesvg, outsvg);
254                                 
255                                 if (m->control_pressed) { outsvg.close(); return outputNames; }
256                                 
257                                 int sharedVal, sharedABVal, sharedACVal, sharedBCVal, numSeqsA, numSeqsB, numSeqsC;
258                                 
259                                 if (nseqs) {
260                                         NSeqs* nseqsCalc = new NSeqs();
261                                         vector<double> sharedData = nseqsCalc->getValues(lookup);
262                                                 
263                                         vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
264                                         vector<double> sharedAB = nseqsCalc->getValues(mysubset);
265                                                 
266                                         mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
267                                         vector<double> sharedAC = nseqsCalc->getValues(mysubset);
268                                                 
269                                         mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
270                                         vector<double> sharedBC = nseqsCalc->getValues(mysubset);
271                                                 
272                                         sharedVal = sharedData[0] + sharedData[1] + sharedData[2];
273                                         sharedABVal = sharedAB[0] + sharedAB[1];
274                                         sharedACVal = sharedAC[0] + sharedAC[1];
275                                         sharedBCVal = sharedBC[0] + sharedBC[1];
276                                         numSeqsA = sabundA->getNumSeqs();
277                                         numSeqsB = sabundB->getNumSeqs();
278                                         numSeqsC = sabundC->getNumSeqs();
279
280                                         delete nseqsCalc;
281                                 }
282
283                                 
284                                 if (vCalcs[i]->getName() == "sharedace") {
285                                 
286                                         singleCalc = new Ace(10);
287                                         
288                                         //get estimates for numA
289                                         vector<double> numA = singleCalc->getValues(sabundA);
290                         
291                                         //get estimates for numB
292                                         vector<double> numB = singleCalc->getValues(sabundB);
293                                 
294                                         //get estimates for numC
295                                         vector<double> numC = singleCalc->getValues(sabundC);
296
297
298                                         //get estimates for sharedAB, sharedAC and sharedBC
299                                         subset.clear();
300                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
301                                         vector<double> sharedAB = vCalcs[i]->getValues(subset);
302                                         
303                                         subset.clear();
304                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
305                                         vector<double> sharedAC = vCalcs[i]->getValues(subset);
306                                         
307                                         subset.clear();
308                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
309                                         vector<double> sharedBC = vCalcs[i]->getValues(subset);
310                                         
311                                         vector<double> sharedAwithBC;
312                                         vector<double> sharedBwithAC;
313                                         vector<double> sharedCwithAB;
314                                         
315                                         //find possible sharedABC values
316                                         float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
317
318                                         if (vCalcs[i]->getMultiple() == false) {
319                                                 //merge BC and estimate with shared with A
320                                                 SharedRAbundVector* merge = new SharedRAbundVector();
321                                                 for (int j = 0; j < lookup[1]->size(); j++) {
322                                                         merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
323                                                 }
324                                         
325                                                 subset.clear();
326                                                 subset.push_back(lookup[0]); subset.push_back(merge);
327                                                 sharedAwithBC = vCalcs[i]->getValues(subset);
328                                 
329                                                 delete merge;
330                                                 //merge AC and estimate with shared with B
331                                                 merge = new SharedRAbundVector();
332                                                 for (int j = 0; j < lookup[0]->size(); j++) {
333                                                         merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
334                                                 }
335                                         
336                                                 subset.clear();
337                                                 subset.push_back(merge); subset.push_back(lookup[1]);
338                                                 sharedBwithAC = vCalcs[i]->getValues(subset);
339                                 
340                                                 delete merge;
341                                                 //merge AB and estimate with shared with C
342                                                 merge = new SharedRAbundVector();
343                                                 for (int j = 0; j < lookup[0]->size(); j++) {
344                                                         merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
345                                                 }
346                                         
347                                                 subset.clear();
348                                                 subset.push_back(lookup[2]); subset.push_back(merge);
349                                                 sharedCwithAB = vCalcs[i]->getValues(subset);
350                                                 delete merge;
351                                         
352                                                 sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
353                                                 sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
354                                                 sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
355          
356                                                 //if any of the possible m's are - throw them out
357                                                 if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
358                                                 if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
359                                                 if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
360                         
361                                                 //sharedABC is the minimum of the 3 possibilities
362                                                 if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
363                                                 else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
364                                                 else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }    
365                                         }else{
366                                                 vector<double> data = vCalcs[i]->getValues(lookup);
367                                                 sharedABC = data[0];
368                                                 sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
369                                                 sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
370                                                 sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
371                                         }
372                                         
373                                         //image window
374                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
375                                         outsvg << "<g>\n";
376
377                                         //draw circles
378                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
379                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.44 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
380                                         outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.33 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
381                                         outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.65 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
382                                         outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.5 * width)) +  "\" cy=\"" +  toString(int(0.5 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
383
384                                         //place labels within overlaps
385                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.33 * width) - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n"; 
386                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.33 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
387                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";  
388                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
389                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n";  
390                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";  
391                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\"  x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\"   y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n"; 
392                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\"  x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.52 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n"; 
393                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.58 * width) - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";  
394                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.34 * height)) +  "\">" + toString(sharedABC) + "</text>\n"; 
395                                 
396                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]);
397                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
398                                         outsvg << "</text>\n";
399                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]);
400                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
401                                         outsvg << "</text>\n";
402                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]);
403                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
404                                         outsvg << "</text>\n";
405                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">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";
406                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.925 * height)) +  "\">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";
407                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.95 * height)) +  "\">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";
408                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
409                                         if (numA.size() == 3) { 
410                                                 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
411                                         } 
412                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
413                                         outsvg << "</text>\n";
414                         
415                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
416                                         if (numB.size() == 3) { 
417                                                 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
418                                         }
419                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
420                                         outsvg << "</text>\n";
421                                         
422                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">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]);
425                                         }
426                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC);  }  
427                                         outsvg << "</text>\n";
428
429                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.80 * height)) +  "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
430                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.975 * height)) +  "\">The total shared richness is " + toString(sharedABC);
431                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal);  }  
432                                         outsvg << "</text>\n";
433                                         
434                                         delete singleCalc;
435                                         
436                                 }else { //sharedchao and sharedsobs are multigroup
437                                         
438                                         vector<SharedRAbundVector*> subset;
439
440                                         //get estimates for numA
441                                         subset.push_back(lookup[0]);
442                                         vector<double> numA = vCalcs[i]->getValues(subset);
443                         
444                                         //get estimates for numB
445                                         subset.clear();
446                                         subset.push_back(lookup[1]);
447                                         vector<double> numB = vCalcs[i]->getValues(subset);
448                                 
449                                         //get estimates for numC
450                                         subset.clear();
451                                         subset.push_back(lookup[2]);
452                                         vector<double> numC = vCalcs[i]->getValues(subset);
453
454                                         subset.clear();
455                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
456                                         vector<double> sharedab =  vCalcs[i]->getValues(subset);
457                                         
458                                         subset.clear(); 
459                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
460                                         vector<double> sharedac =  vCalcs[i]->getValues(subset);
461                                         
462                                         subset.clear(); 
463                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
464                                         vector<double> sharedbc =  vCalcs[i]->getValues(subset);
465                                         
466                                         subset.clear(); 
467                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
468                                         vector<double> sharedabc =  vCalcs[i]->getValues(subset);
469                                         
470                                         //image window
471                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
472                                         outsvg << "<g>\n";
473
474                                         //draw circles
475                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
476                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
477                                         outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.33 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
478                                         outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.65 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
479                                         outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.5 * width)) +  "\" cy=\"" +  toString(int(0.5 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
480
481                                         //place labels within overlaps
482                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]).length() / 2)) + "\" y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "</text>\n"; 
483                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
484                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedab[0] - sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(sharedab[0] - sharedabc[0]) + "</text>\n";  
485                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.68 * width) - ((int)toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
486                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.68 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n";  
487                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedac[0] - sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedac[0] - sharedabc[0]) + "</text>\n";  
488                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\"  x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"   y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "</text>\n"; 
489                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\"  x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.51 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n"; 
490                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.59 * width) - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";  
491                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.35 * height)) +  "\">" + toString(sharedabc[0]) + "</text>\n"; 
492                                 
493                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]);
494                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
495                                         outsvg << "</text>\n";
496                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]);
497                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
498                                         outsvg << "</text>\n";
499                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]);
500                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
501                                         outsvg << "</text>\n";
502                                         
503                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
504                                         if (numA.size() == 3) { 
505                                                 outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
506                                         }
507                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
508                                         outsvg << "</text>\n";
509                         
510                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
511                                         if (numB.size() == 3) { 
512                                                 outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
513                                         }
514                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
515                                         outsvg << "</text>\n";
516                                                                                 
517                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
518                                         if (numC.size() == 3) { 
519                                                 outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
520                                         }
521                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC);  }  
522                                         outsvg << "</text>\n";
523
524                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.8 * height)) +  "\">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";
525                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">The total shared richness is " + toString(sharedabc[0]);
526                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal);  }  
527                                         outsvg << "</text>\n";
528
529                                 }
530                                                                 
531                                 //close file
532                                 outsvg << "</g>\n</svg>\n";
533                                 outsvg.close();
534                                 
535
536                         }
537                         
538                 /******************* 4 Groups **************************/
539                 
540                 }else if (lookup.size() == 4) {
541                         
542                         height = 1600;
543                         
544                         int windowSize = height;
545                 
546                         //calc the shared otu
547                         float sharedABCD = 0;
548                         float numA = 0; float numB = 0; float numC = 0; float numD = 0;
549                         float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
550                         float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
551                         vector<double> data;
552                         //get sabund vector pointers so you can use the single calculators
553                         //one for each group
554                         SAbundVector sA, sB, sC, sD;
555                         SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
556                         sA = lookup[0]->getSAbundVector();  sabundA = &sA;
557                         sB = lookup[1]->getSAbundVector();  sabundB = &sB;
558                         sC = lookup[2]->getSAbundVector();  sabundC = &sC;
559                         sD = lookup[3]->getSAbundVector();  sabundD = &sD;
560                         
561                         //A = red, B = green, C = blue, D = yellow
562                         
563                         //make a file for each calculator
564                         for(int i=0;i<vCalcs.size();i++){
565                                 
566                                 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(); }
567                                 else{
568                                         string filenamesvg = outputDir + m->getRootName(m->getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
569                                         outputNames.push_back(filenamesvg);
570                                         m->openOutputFile(filenamesvg, outsvg);
571
572                                         if (m->control_pressed) { outsvg.close(); return outputNames; }
573                                         
574                                         //in essence you want to run it like a single 
575                                         if (vCalcs[i]->getName() == "sharedsobs") {
576                                                 singleCalc = new Sobs();
577                                         }else if (vCalcs[i]->getName() == "sharedchao") {
578                                                 singleCalc = new Chao1();
579                                         }
580                                 
581                                         //get estimates for numA
582                                         data = singleCalc->getValues(sabundA);
583                                         numA = data[0];
584         //cout << "num a = " << numA << endl;   
585                         
586                                         //get estimates for numB
587                                         data = singleCalc->getValues(sabundB);
588                                         numB = data[0];
589         //cout << "num b = " << numB << endl;                           
590                                         //get estimates for numC
591                                         data = singleCalc->getValues(sabundC);
592                                         numC = data[0];
593         //cout << "num c = " << numC << endl;                           
594                                         //get estimates for numD
595                                         data = singleCalc->getValues(sabundD);
596                                         numD = data[0];
597 //cout << "num d = " << numD << endl;   
598
599                                         //get estimates for pairs
600                                         subset.clear();
601                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]);
602                                         data = vCalcs[i]->getValues(subset);
603                                         sharedAB = data[0];
604         //cout << "num ab = " << sharedAB << endl;                      
605                                         subset.clear();
606                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]);
607                                         data = vCalcs[i]->getValues(subset);
608                                         sharedAC = data[0];
609         //cout << "num ac = " << sharedAC << endl;                              
610                                         subset.clear();
611                                         subset.push_back(lookup[0]); subset.push_back(lookup[3]);
612                                         data = vCalcs[i]->getValues(subset);
613                                         sharedAD = data[0];
614         //cout << "num ad = " << sharedAD << endl;                      
615                                         subset.clear();
616                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]);
617                                         data = vCalcs[i]->getValues(subset);
618                                         sharedBC = data[0];
619         //cout << "num bc = " << sharedBC << endl;                              
620                                         subset.clear();
621                                         subset.push_back(lookup[1]); subset.push_back(lookup[3]);
622                                         data = vCalcs[i]->getValues(subset);
623                                         sharedBD = data[0];
624                 //cout << "num bd = " << sharedBD << endl;                                              
625                                         subset.clear();
626                                         subset.push_back(lookup[2]); subset.push_back(lookup[3]);
627                                         data = vCalcs[i]->getValues(subset);
628                                         sharedCD = data[0];
629                                                 
630         //cout << "num cd = " << sharedCD << endl;                              
631                                         //get estimates for combos of 3
632                                         subset.clear();
633                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
634                                         data = vCalcs[i]->getValues(subset);
635                                         sharedABC = data[0];
636                 //cout << "num abc = " << sharedABC << endl;                                    
637                                         subset.clear();
638                                         subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
639                                         data = vCalcs[i]->getValues(subset);
640                                         sharedACD = data[0];
641                         //cout << "num acd = " << sharedACD << endl;    
642                                         subset.clear();
643                                         subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
644                                         data = vCalcs[i]->getValues(subset);
645                                         sharedBCD = data[0];
646                 //cout << "num bcd = " << sharedBCD << endl;            
647                                         subset.clear();
648                                         subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
649                                         data = vCalcs[i]->getValues(subset);
650                                         sharedABD = data[0];
651 //cout << "num abd = " << sharedABD << endl;
652                                         //get estimate for all four
653                                         data = vCalcs[i]->getValues(lookup);
654                                         sharedABCD = data[0];
655                 //cout << "num abcd = " << sharedABCD << endl << endl;  
656                                         int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
657                                                                                                 
658                                         if (nseqs) {
659                                                 NSeqs* nseqsCalc = new NSeqs();
660                                                 vector<double> sharedData = nseqsCalc->getValues(lookup);
661                                                 
662                                                 vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
663                                                 vector<double> sharedAB = nseqsCalc->getValues(mysubset);
664                                                 
665                                                 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
666                                                 vector<double> sharedAC = nseqsCalc->getValues(mysubset);
667                                                 
668                                                 mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[3]);
669                                                 vector<double> sharedAD = nseqsCalc->getValues(mysubset);
670                                                 
671                                                 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
672                                                 vector<double> sharedBC = nseqsCalc->getValues(mysubset);
673                                                 
674                                                 mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
675                                                 vector<double> sharedBD = nseqsCalc->getValues(mysubset);
676                                                 
677                                                 mysubset.clear(); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
678                                                 vector<double> sharedCD = nseqsCalc->getValues(mysubset);
679                                                 
680                                                 mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
681                                                 vector<double> sharedABC = nseqsCalc->getValues(mysubset);
682                                                 
683                                                 mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
684                                                 vector<double> sharedABD = nseqsCalc->getValues(mysubset);
685
686                                                 mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
687                                                 vector<double> sharedACD = nseqsCalc->getValues(mysubset);
688
689                                                 mysubset.clear(); mysubset.push_back(lookup[1]);  mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
690                                                 vector<double> sharedBCD = nseqsCalc->getValues(mysubset);
691                                                 
692                                                 sharedVal = sharedData[0] + sharedData[1] + sharedData[2] + sharedData[3];
693                                                 sharedABCVal = sharedABC[0] + sharedABC[1] + sharedABC[2];
694                                                 sharedABDVal = sharedABD[0] + sharedABD[1] + sharedABD[2];
695                                                 sharedACDVal = sharedACD[0] + sharedACD[1] + sharedACD[2];
696                                                 sharedBCDVal = sharedBCD[0] + sharedBCD[1] + sharedBCD[2];
697                                                 sharedABVal = sharedAB[0] + sharedAB[1];
698                                                 sharedACVal = sharedAC[0] + sharedAC[1];
699                                                 sharedADVal = sharedAD[0] + sharedAD[1];
700                                                 sharedBCVal = sharedBC[0] + sharedBC[1];
701                                                 sharedBDVal = sharedBD[0] + sharedBD[1];
702                                                 sharedCDVal = sharedCD[0] + sharedCD[1];
703                                                 numSeqsA = sabundA->getNumSeqs(); 
704                                                 numSeqsB = sabundB->getNumSeqs(); 
705                                                 numSeqsC = sabundC->getNumSeqs(); 
706                                                 numSeqsD = sabundD->getNumSeqs(); 
707                                                 
708                                                 delete nseqsCalc;
709                                         }
710
711                                                 
712                                         //image window
713                                         outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
714                                         outsvg << "<g>\n";
715                                         outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(windowSize) +  "\"/>"; 
716                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\" >Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
717
718                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\"  y=\"" +  toString(int(0.625 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA); 
719                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
720                                         outsvg << "</text>\n";
721                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.65 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB);
722                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
723                                         outsvg << "</text>\n";
724                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.675 * height)) +  "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC);
725                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC);  }  
726                                         outsvg << "</text>\n";
727                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.7 * height)) +  "\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD);
728                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsD);  }  
729                                         outsvg << "</text>\n";
730                                         
731                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB);
732                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
733                                         outsvg << "</text>\n";
734                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC);
735                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
736                                         outsvg << "</text>\n";
737                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD);
738                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedADVal);  }  
739                                         outsvg << "</text>\n";
740                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.8 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC);
741                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
742                                         outsvg << "</text>\n";
743                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD);
744                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBDVal);  }  
745                                         outsvg << "</text>\n";
746                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD);
747                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedCDVal);  }  
748                                         outsvg << "</text>\n";
749                                         
750                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC);
751                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABCVal);  }  
752                                         outsvg << "</text>\n";
753                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD);
754                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABDVal);  }  
755                                         outsvg << "</text>\n";
756                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.925 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD);
757                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACDVal);  }  
758                                         outsvg << "</text>\n";
759                                         outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.95 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD);
760                                         if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCDVal);  }  
761                                         outsvg << "</text>\n";
762                                                                         
763                                         //make adjustments
764                                         sharedABC = sharedABC - sharedABCD;
765                         //cout << "num abc = " << sharedABC << endl;            
766                                         sharedABD = sharedABD - sharedABCD;
767                                 //cout << "num abd = " << sharedABD << endl;
768                                         sharedACD = sharedACD - sharedABCD;
769                                 //cout << "num acd = " << sharedACD << endl;
770                                         sharedBCD = sharedBCD - sharedABCD;
771                                 //cout << "num bcd = " << sharedBCD << endl;
772                                         
773                                         sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD;  //cout << "num ab = " << sharedAB << endl;
774                                         sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD;  //cout << "num ac = " << sharedAC << endl;
775                                         sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD;  //cout << "num ad = " << sharedAD << endl;                           
776                                         sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD;  //cout << "num bc = " << sharedBC << endl;
777                                         sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl; 
778                                         sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD;  //cout << "num cd = " << sharedCD << endl;
779                                         
780                                         numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
781                         //cout << "num a = " << numA << endl;           
782                                         numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
783                         //cout << "num b = " << numB << endl;           
784                                         numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
785                         //cout << "num c = " << numC << endl;           
786                                         numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
787                         //cout << "num d = " << numD << endl;           
788                                         
789                                         //draw circles
790                                         outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 " +  toString(int(0.51 * width)) +  " " +  toString(int(0.27 * height)) +  ") \" cx=\"" +  toString(int(0.51 * width)) +  "\" cy=\"" +  toString(int(0.27 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n "; 
791                                         outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 " +  toString(int(0.51 * width)) +  " " +  toString(int(0.27 * height)) +  ") \" cx=\"" +  toString(int(0.51 * width)) +  "\" cy=\"" +  toString(int(0.27 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
792                                         outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 " +  toString(int(0.63 * width)) +  " " +  toString(int(0.36 * height)) +  ") \" cx=\"" +  toString(int(0.63 * width)) +  "\" cy=\"" +  toString(int(0.36 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
793                                         outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 " +  toString(int(0.36 * width)) +  " " +  toString(int(0.36 * height)) +  ") \" cx=\"" +  toString(int(0.36 * width)) +  "\" cy=\"" +  toString(int(0.36 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
794                         
795                                         //A = red, B = green, C = blue, D = yellow
796                         
797                                         //place labels within overlaps
798                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.66 * width) - ((int)toString(numA).length() / 2)) + "\" y=\"" +  toString(int(0.14 * height)) +  "\">" + toString(numA)  + "</text>\n"; 
799                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.66 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.11 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
800                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB).length() / 2)) + "\"  y=\"" +  toString(int(0.2 * height)) +  "\">" + toString(sharedAB) + "</text>\n";  
801                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.36 * width) - ((int)toString(numB).length() / 2)) + "\"  y=\"" +  toString(int(0.14 * height)) +  "\">" + toString(numB)  + "</text>\n";  
802                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.36 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.11 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n"; 
803                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.7 * width) - ((int)toString(sharedAC).length() / 2)) + "\"  y=\"" +  toString(int(0.24 * height)) +  "\">" + toString(sharedAC) + "</text>\n";  
804                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\"  x=\"" + toString(int(0.785 * width) - ((int)toString(numC).length() / 2)) + "\"   y=\"" +  toString(int(0.29 * height)) +  "\">" + toString(numC) + "</text>\n";  
805                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\"  x=\"" + toString(int(0.785 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.26 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n";
806                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.31 * width) - ((int)toString(sharedBD).length() / 2)) + "\" y=\"" +  toString(int(0.24 * height)) +  "\">" + toString(sharedBD) + "</text>\n";  
807                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\"  x=\"" + toString(int(0.22 * width) - ((int)toString(numD).length() / 2)) + "\"   y=\"" +  toString(int(0.29 * height)) +  "\">" + toString(numD) + "</text>\n";  
808                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\"  x=\"" + toString(int(0.22 * width) - ((int)lookup[3]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.26 * height)) +  "\">" + lookup[3]->getGroup() + "</text>\n"; 
809                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.34 * width) - ((int)toString(sharedAD).length() / 2)) + "\" y=\"" +  toString(int(0.41 * height)) +  "\">" + toString(sharedAD) + "</text>\n"; 
810                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.675 * width) - ((int)toString(sharedBC).length() / 2)) + "\" y=\"" +  toString(int(0.41 * height)) +  "\">" + toString(sharedBC) + "</text>\n";
811                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedCD).length() / 2)) + "\" y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(sharedCD) + "</text>\n"; 
812                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.39 * width) - ((int)toString(sharedABD).length() / 2)) + "\" y=\"" +  toString(int(0.3 * height)) +  "\">" + toString(sharedABD) + "</text>\n"; 
813                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.57 * width) - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"" +  toString(int(0.45 * height)) +  "\">" + toString(sharedBCD) + "</text>\n";
814                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.435 * width) - ((int)toString(sharedACD).length() / 2)) + "\" y=\"" +  toString(int(0.45 * height)) +  "\">" + toString(sharedACD) + "</text>\n"; 
815                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.63 * width) - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.3 * height)) +  "\">" + toString(sharedABC) + "</text>\n"; 
816                                         outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"24\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABCD).length() / 2)) + "\"  y=\"" +  toString(int(0.4 * height)) +  "\">" + toString(sharedABCD) + "</text>\n"; 
817                                         
818                                         outsvg << "<text fill=\"black\"  class=\"seri\" font-size=\"24\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.975 * height)) +  "\">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));
819                                         if (nseqs) {  outsvg << ", and the number of squences in the otus shared by all groups is " + toString(sharedVal);  }  
820                                         outsvg << "</text>\n";
821                                         
822                                         outsvg << "</g>\n</svg>\n";
823                                         outsvg.close();
824                                         delete singleCalc;
825                                 }
826                         }
827                 }
828                 
829                 return outputNames;
830                 
831         }
832         catch(exception& e) {
833                 m->errorOut(e, "Venn", "getPic");
834                 exit(1);
835         }
836 }
837
838