]> git.donarmstrong.com Git - mothur.git/commitdiff
fixed bug in venn command which caused error when user used more than one distance...
authorwestcott <westcott>
Tue, 21 Apr 2009 12:51:54 +0000 (12:51 +0000)
committerwestcott <westcott>
Tue, 21 Apr 2009 12:51:54 +0000 (12:51 +0000)
sharedchao1.h
venn.cpp
venn.h

index bba43424276ff52bd2492a2ae4118b6638cab96e..7cca63a8fb48bb9ac9a45757d95436562deff455 100644 (file)
@@ -20,7 +20,7 @@ It is a child of the calculator class. */
 class SharedChao1 : public Calculator  {
        
 public: 
-       SharedChao1() : Calculator("SharedChao", 3) {};
+       SharedChao1() : Calculator("sharedchao", 3) {};
        EstOutput getValues(SAbundVector*) {return data;};
        EstOutput getValues(SharedRAbundVector*, SharedRAbundVector*);
 };
index bcc475171fe7b35ee8697a5adb7a29af8033f3c5..3c0d797b4a246246af19a664b032017745e9f546 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -88,17 +88,14 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                        
                                //in essence you want to run it like a single 
                                if (vCalcs[i]->getName() == "sharedsobs") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Sobs();
+                                       singleCalc = new Sobs();
                                }else if (vCalcs[i]->getName() == "sharedchao") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Chao1();
+                                       singleCalc = new Chao1();
                                }else if (vCalcs[i]->getName() == "sharedace") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Ace(10);
+                                       singleCalc = new Ace(10);
                                }
                                
-                               vector<double> data = vCalcs[i]->getValues(sabund);
+                               vector<double> data = singleCalc->getValues(sabund);
                        
                                //svg image
                                outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
@@ -117,6 +114,8 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                        
                                outsvg << "</g>\n</svg>\n";
                                outsvg.close();
+                               delete singleCalc;
+                               
                        }
                        
                /******************* 2 Groups **************************/       
@@ -139,22 +138,18 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                                
                                //in essence you want to run it like a single 
                                if (vCalcs[i]->getName() == "sharedsobs") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Sobs();
+                                       singleCalc = new Sobs();
                                }else if (vCalcs[i]->getName() == "sharedchao") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Chao1();
+                                       singleCalc = new Chao1();
                                }else if (vCalcs[i]->getName() == "sharedace") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Ace(10);
+                                       singleCalc = new Ace(10);
                                }
                                
                                //get estimates for numA
-                               vector<double> numA = vCalcs[i]->getValues(sabundA);
+                               vector<double> numA = singleCalc->getValues(sabundA);
 
                                //get estimates for numB
-                               vector<double> numB = vCalcs[i]->getValues(sabundB);
-                               cout << numA[0] << '\t' << numB[0] << '\t' << shared[0] << endl;                                
+                               vector<double> numB = singleCalc->getValues(sabundB);
                                                
                                //image window
                                outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
@@ -189,6 +184,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                                outsvg.close();
                                delete sabundA;
                                delete sabundB;
+                               delete singleCalc;
                        }
                        
                /******************* 3 Groups **************************/
@@ -237,28 +233,25 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                                }
                                
                                vector<double> sharedCwithAB = vCalcs[i]->getValues(lookup[2], merge);
-                               
+                               delete merge;
                                
                                //in essence you want to run it like a single 
                                if (vCalcs[i]->getName() == "sharedsobs") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Sobs();
+                                       singleCalc = new Sobs();
                                }else if (vCalcs[i]->getName() == "sharedchao") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Chao1();
+                                       singleCalc = new Chao1();
                                }else if (vCalcs[i]->getName() == "sharedace") {
-                                       delete vCalcs[i];
-                                       vCalcs[i] = new Ace(10);
+                                       singleCalc = new Ace(10);
                                }
                                
                                //get estimates for numA
-                               vector<double> numA = vCalcs[i]->getValues(sabundA);
+                               vector<double> numA = singleCalc->getValues(sabundA);
                        
                                //get estimates for numB
-                               vector<double> numB = vCalcs[i]->getValues(sabundB);
+                               vector<double> numB = singleCalc->getValues(sabundB);
                                
                                //get estimates for numC
-                               vector<double> numC = vCalcs[i]->getValues(sabundC);
+                               vector<double> numC = singleCalc->getValues(sabundC);
                                
                                //find possible sharedABC values
                                float sharedABC1, sharedABC2, sharedABC3, sharedABC;
@@ -287,7 +280,9 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                                outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"230\" cy=\"200\" r=\"150\"/>"; 
                                outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"455\" cy=\"200\" r=\"150\"/>"; 
                                outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"343\" cy=\"400\" r=\"150\"/>"; 
-                       
+//cout << "numA = " << numA[0] << " numB = " << numB[0]        << " numC = " << numC[0] << endl;
+//cout << "sharedAB = " << sharedAB[0] << " sharedAC = " << sharedAC[0] << " sharedBC = " << sharedBC[0] << endl;
+//cout << "sharedAwithBC = " << sharedAwithBC[0]       << " sharedBwithAC = " << sharedBwithAC[0] << " sharedCwithAB = " << sharedCwithAB[0] << endl;  
                                //place labels within overlaps
                                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"; 
                                outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(200 - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "</text>\n";  
@@ -326,6 +321,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector<Calculator*> vCalcs) {
                                //close file
                                outsvg << "</g>\n</svg>\n";
                                outsvg.close();
+                               delete singleCalc;
                        }
                        
                /******************* 4 Groups **************************/
diff --git a/venn.h b/venn.h
index ae73dc235bdb266d1d833131012bc293bbe795f5..748723e85dd068722d09179dab76ee1dd2968390 100644 (file)
--- a/venn.h
+++ b/venn.h
@@ -35,6 +35,7 @@ class Venn {
                SharedUtil* util;
                SAbundVector* sabund;
                GlobalData* globaldata;
+               Calculator* singleCalc;
                vector<SharedRAbundVector*> lookup;
                string format, groupComb;
                ofstream outsvg;