From 2c5f6dfaab750da109bb7bc7e51b005d135c2d77 Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 21 Apr 2009 12:51:54 +0000 Subject: [PATCH] fixed bug in venn command which caused error when user used more than one distance level. --- sharedchao1.h | 2 +- venn.cpp | 50 +++++++++++++++++++++++--------------------------- venn.h | 1 + 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/sharedchao1.h b/sharedchao1.h index bba4342..7cca63a 100644 --- a/sharedchao1.h +++ b/sharedchao1.h @@ -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*); }; diff --git a/venn.cpp b/venn.cpp index bcc4751..3c0d797 100644 --- a/venn.cpp +++ b/venn.cpp @@ -88,17 +88,14 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector 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 data = vCalcs[i]->getValues(sabund); + vector data = singleCalc->getValues(sabund); //svg image outsvg << "\n"; @@ -117,6 +114,8 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << "\n\n"; outsvg.close(); + delete singleCalc; + } /******************* 2 Groups **************************/ @@ -139,22 +138,18 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector 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 numA = vCalcs[i]->getValues(sabundA); + vector numA = singleCalc->getValues(sabundA); //get estimates for numB - vector numB = vCalcs[i]->getValues(sabundB); - cout << numA[0] << '\t' << numB[0] << '\t' << shared[0] << endl; + vector numB = singleCalc->getValues(sabundB); //image window outsvg << "\n"; @@ -189,6 +184,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg.close(); delete sabundA; delete sabundB; + delete singleCalc; } /******************* 3 Groups **************************/ @@ -237,28 +233,25 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { } vector 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 numA = vCalcs[i]->getValues(sabundA); + vector numA = singleCalc->getValues(sabundA); //get estimates for numB - vector numB = vCalcs[i]->getValues(sabundB); + vector numB = singleCalc->getValues(sabundB); //get estimates for numC - vector numC = vCalcs[i]->getValues(sabundC); + vector numC = singleCalc->getValues(sabundC); //find possible sharedABC values float sharedABC1, sharedABC2, sharedABC3, sharedABC; @@ -287,7 +280,9 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << ""; outsvg << ""; outsvg << ""; - +//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 << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "\n"; @@ -326,6 +321,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { //close file outsvg << "\n\n"; outsvg.close(); + delete singleCalc; } /******************* 4 Groups **************************/ diff --git a/venn.h b/venn.h index ae73dc2..748723e 100644 --- a/venn.h +++ b/venn.h @@ -35,6 +35,7 @@ class Venn { SharedUtil* util; SAbundVector* sabund; GlobalData* globaldata; + Calculator* singleCalc; vector lookup; string format, groupComb; ofstream outsvg; -- 2.39.2