]> git.donarmstrong.com Git - mothur.git/blobdiff - venn.cpp
made changes to concensus to find a better tree. also fixed minor bug in venn with...
[mothur.git] / venn.cpp
index 921c125040d6950aeb773c995b1c0f2cca5d5d60..217dd3594081703b6cf7a28857cd553b62bcfaec 100644 (file)
--- a/venn.cpp
+++ b/venn.cpp
@@ -22,11 +22,7 @@ Venn::Venn(){
 
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "Venn");
                exit(1);
        }
 }
@@ -59,11 +55,7 @@ void Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
                }
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "getPic");
                exit(1);
        }
 }
@@ -305,9 +297,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, 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";  
@@ -374,7 +364,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                        //make a file for each calculator
                        for(int i=0;i<vCalcs.size();i++){
                                
-                               if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { cout << vCalcs[i]->getName() << " is not a valid calculator with four groups.  It will be disregarded. " << endl; }
+                               if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups.  It will be disregarded. "); mothurOutEndLine(); }
                                else{
                                        string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg";
                                        openOutputFile(filenamesvg, outsvg);
@@ -390,78 +380,105 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        //get estimates for numA
                                        data = singleCalc->getValues(sabundA);
                                        numA = data[0];
+       //cout << "num a = " << numA << endl;   
                        
                                        //get estimates for numB
                                        data = singleCalc->getValues(sabundB);
                                        numB = data[0];
-                               
+       //cout << "num b = " << numB << endl;                           
                                        //get estimates for numC
                                        data = singleCalc->getValues(sabundC);
                                        numC = data[0];
-                               
+       //cout << "num c = " << numC << endl;                           
                                        //get estimates for numD
                                        data = singleCalc->getValues(sabundD);
                                        numD = data[0];
-
+//cout << "num d = " << numD << endl;  
 
                                        //get estimates for pairs
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[1]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedAB = data[0];
-                               
+       //cout << "num ab = " << sharedAB << endl;                      
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[2]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedAC = data[0];
-                               
+       //cout << "num ac = " << sharedAC << endl;                              
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedAD = data[0];
-                               
+       //cout << "num ad = " << sharedAD << endl;                      
                                        subset.clear();
                                        subset.push_back(lookup[1]); subset.push_back(lookup[2]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedBC = data[0];
-                               
+       //cout << "num bc = " << sharedBC << endl;                              
                                        subset.clear();
                                        subset.push_back(lookup[1]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedBD = data[0];
-                               
+               //cout << "num bd = " << sharedBD << endl;                                              
                                        subset.clear();
                                        subset.push_back(lookup[2]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedCD = data[0];
-                               
-                               
+                                               
+       //cout << "num cd = " << sharedCD << endl;                              
                                        //get estimates for combos of 3
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedABC = data[0];
-                               
+               //cout << "num abc = " << sharedABC << endl;                                    
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedACD = data[0];
-                               
+                       //cout << "num acd = " << sharedACD << endl;    
                                        subset.clear();
                                        subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedBCD = data[0];
-                               
+               //cout << "num bcd = " << sharedBCD << endl;            
                                        subset.clear();
                                        subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
                                        data = vCalcs[i]->getValues(subset);
                                        sharedABD = data[0];
-
+//cout << "num abd = " << sharedABD << endl;
                                        //get estimate for all four
                                        data = vCalcs[i]->getValues(lookup);
                                        sharedABCD = data[0];
-
-               
+               //cout << "num abcd = " << sharedABCD << endl << endl;                  
+                                       //make adjustments
+                                       sharedABC = sharedABC - sharedABCD;
+                       //cout << "num abc = " << sharedABC << endl;            
+                                       sharedABD = sharedABD - sharedABCD;
+                               //cout << "num abd = " << sharedABD << endl;
+                                       sharedACD = sharedACD - sharedABCD;
+                               //cout << "num acd = " << sharedACD << endl;
+                                       sharedBCD = sharedBCD - sharedABCD;
+                               //cout << "num bcd = " << sharedBCD << endl;
+                                       
+                                       sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD; // cout << "num ab = " << sharedAB << endl;
+                                       sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD; // cout << "num ac = " << sharedAC << endl;
+                                       sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD; // cout << "num ad = " << sharedAD << endl;
+                                       
+                                       sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD; // cout << "num bc = " << sharedBC << endl;
+                                       sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl; 
+                                       sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD; // cout << "num cd = " << sharedCD << endl;
+                                       
+                                       numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
+                       //cout << "num a = " << numA << endl;           
+                                       numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
+                       //cout << "num b = " << numB << endl;           
+                                       numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
+                       //cout << "num c = " << numC << endl;           
+                                       numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
+                       //cout << "num d = " << numD << endl;           
+                                       
                                        //image window
                                        outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 700 700\" >\n";
                                        outsvg << "<g>\n";
@@ -488,8 +505,8 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(215 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"190\">" + toString(sharedBC) + "</text>\n";  
                                        outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(150 - ((int)toString(numD).length() / 2)) + "\"   y=\"230\">" + toString(numD) + "</text>\n";  
                                        outsvg << "<text fill=\"black\" class=\"seri\"  x=\"" + toString(150 - ((int)lookup[3]->getGroup().length() / 2)) + "\"   y=\"210\">" + lookup[3]->getGroup() + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBC).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(240 - ((int)toString(sharedAD).length() / 2)) + "\" y=\"325\">" + toString(sharedAD) + "</text>\n"; 
+                                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(470 - ((int)toString(sharedBD).length() / 2)) + "\" y=\"325\">" + toString(sharedBD) + "</text>\n";
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(350 - ((int)toString(sharedCD).length() / 2)) + "\" y=\"430\">" + toString(sharedCD) + "</text>\n"; 
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(275 - ((int)toString(sharedABD).length() / 2)) + "\" y=\"240\">" + toString(sharedABD) + "</text>\n"; 
                                        outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(400 - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"360\">" + toString(sharedBCD) + "</text>\n";
@@ -507,11 +524,7 @@ void Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs
                
        }
        catch(exception& e) {
-               cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
-               exit(1);
-       }
-       catch(...) {
-               cout << "An unknown error has occurred in the Venn class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               errorOut(e, "Venn", "getPic");
                exit(1);
        }
 }