]> git.donarmstrong.com Git - mothur.git/blobdiff - heatmap.cpp
added weightedlinkage.cpp
[mothur.git] / heatmap.cpp
index 2bd020e0c3cf8337c0671c1db515954e51177dd0..3dca535b8600e38f29cf87160ab5a487282280d5 100644 (file)
 HeatMap::HeatMap(string sort, string scale, string dir){
        try {
                globaldata = GlobalData::getInstance();
+               m = MothurOut::getInstance();
 //             format = globaldata->getFormat();
                sorted = sort;
                scaler = scale;
                outputDir = dir;
        }
        catch(exception& e) {
-               errorOut(e, "HeatMap", "HeatMap");
+               m->errorOut(e, "HeatMap", "HeatMap");
                exit(1);
        }
 }
 
 //**********************************************************************************************************************
 
-void HeatMap::getPic(RAbundVector* rabund) {
+string HeatMap::getPic(RAbundVector* rabund) {
        try {
                
                
@@ -43,6 +44,8 @@ void HeatMap::getPic(RAbundVector* rabund) {
                for(int i=0;i<rabund->size();i++){
                        float relAbund = rabund->get(i) / (float)rabund->getNumSeqs();
                        
+                       if (m->control_pressed) { return "control"; }
+                       
                        if (rabund->get(i) != 0) { //don't want log value of 0.
                                if (scaler == "log10") {
                                        scaleRelAbund[i] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund))) + "0000";  
@@ -77,6 +80,7 @@ void HeatMap::getPic(RAbundVector* rabund) {
                
                y = 70;
                for (int i = 0; i < scaleRelAbund.size(); i++) {
+                       if (m->control_pressed) { outsvg.close(); return "control"; }
                        
                        outsvg << "<rect fill=\"#" + scaleRelAbund[i] + "\" stroke=\"#" + scaleRelAbund[i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
                        y += 5;
@@ -85,17 +89,17 @@ void HeatMap::getPic(RAbundVector* rabund) {
                outsvg << "</g>\n</svg>\n";
                outsvg.close();
                
-               
+               return filenamesvg;
        }
        catch(exception& e) {
-               errorOut(e, "HeatMap", "getPic");
+               m->errorOut(e, "HeatMap", "getPic");
                exit(1);
        }
 }
 
 //**********************************************************************************************************************
 
-void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
+string HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
        try {
                //sort lookup so shared bins are on top
                if (isTrue(sorted) == true) {  sortSharedVectors(lookup);  }
@@ -117,6 +121,7 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                for(int i=0;i<lookup.size();i++){
                        scaleRelAbund[i].assign(lookup[i]->size(), "");
                        for(int j=0;j<lookup[i]->size();j++){
+                               if (m->control_pressed) {  return "control"; }
                                float relAbund = lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs();
                                
                                if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0.
@@ -159,6 +164,7 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                y = 70;
                for (int i = 0; i < scaleRelAbund[0].size(); i++) {
                        for (int j = 0; j < scaleRelAbund.size(); j++) {
+                               if (m->control_pressed) { outsvg.close(); return "control"; }
                                
                                outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
                                x += 300;
@@ -169,10 +175,12 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                
                outsvg << "</g>\n</svg>\n";
                outsvg.close();
+               
+               return filenamesvg;
 
        }
        catch(exception& e) {
-               errorOut(e, "HeatMap", "getPic");
+               m->errorOut(e, "HeatMap", "getPic");
                exit(1);
        }
 }
@@ -252,7 +260,7 @@ void HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                
        }
        catch(exception& e) {
-               errorOut(e, "HeatMap", "sortSharedVectors");
+               m->errorOut(e, "HeatMap", "sortSharedVectors");
                exit(1);
        }
 }
@@ -292,7 +300,7 @@ void HeatMap::printLegend(int y, float maxbin) {
        }
        
        catch(exception& e) {
-               errorOut(e, "HeatMap", "printLegend");
+               m->errorOut(e, "HeatMap", "printLegend");
                exit(1);
        }
 }