]> git.donarmstrong.com Git - mothur.git/blobdiff - heatmap.cpp
added heatmap.sim command and changed heatmap to heatmap.bin
[mothur.git] / heatmap.cpp
index 0b1a80e6e9dca67a794653ce171d1b4011287b4a..8a1837ae8365106d24c587dd94a64ccb56a37b70 100644 (file)
@@ -62,7 +62,7 @@ void HeatMap::getPic(RAbundVector* rabund) {
                }
                
                
-               string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.svg";
+               string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.bin.svg";
                openOutputFile(filenamesvg, outsvg);
                
                //svg image
@@ -105,9 +105,8 @@ void HeatMap::getPic(RAbundVector* rabund) {
 
 void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
        try {
-               
                //sort lookup so shared bins are on top
-               if (sorted == "T") {  sortSharedVectors(lookup);  }
+               if (isTrue(sorted) == true) {  sortSharedVectors(lookup);  }
                
                vector<vector<string> > scaleRelAbund;
                vector<float> maxRelAbund(lookup.size(), 0.0);          
@@ -141,11 +140,11 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                                                scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund / log10(maxRelAbund[i]))))  + "0000"; 
                                        } 
                                }else { scaleRelAbund[i][j] = "FFFFFF";  }
-                               
+
                        }
                }
-               
-               string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.svg";
+
+               string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.bin.svg";
                openOutputFile(filenamesvg, outsvg);
                
                //svg image
@@ -180,7 +179,7 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                
                outsvg << "</g>\n</svg>\n";
                outsvg.close();
-               
+
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -217,8 +216,11 @@ void HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                        looktemp.push_back(temp);
                }
                
-               //clear out lookup to create sorted lookup
-               lookup.clear();
+               //clear out lookup to create sorted lookup -- Sarah look at - this is causing segmentation faults
+               for (int j = 0; j < lookup.size(); j++) {
+//                     delete lookup[j];
+               }
+               lookup.clear();  //doesn't this do the job?
                
                //create and initialize lookup to empty vectors
                for (int i = 0; i < looktemp.size(); i++) { 
@@ -257,9 +259,9 @@ void HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
                        }
                }
                
-               //delete looktemp
+               //delete looktemp -- Sarah look at - this is causing segmentation faults
                for (int j = 0; j < looktemp.size(); j++) {
-                       delete looktemp[j];
+//                     delete looktemp[j];
                }
                
        }
@@ -299,7 +301,6 @@ void HeatMap::printLegend(int y, float maxbin) {
                        else if(scaler== "log2")        {       label = maxbin * log2(51*i) / log2(255);        }
                        else if(scaler== "linear")      {       label = maxbin * 51 * i / 255;                          }
                        else                                            {       label = maxbin * log10(51*i) / log10(255);      }
-                       file://localhost/Users/westcott/Desktop/c.amazon.fn.0.19.rep.fasta
                        label = int(label * 1000 + 0.5);
                        label /= 1000.0;
                        string text = toString(label, 3);