#include "heatmap.h"
//**********************************************************************************************************************
-HeatMap::HeatMap(){
+HeatMap::HeatMap(string sort, string scale, string dir){
try {
globaldata = GlobalData::getInstance();
- format = globaldata->getFormat();
- sorted = globaldata->getSorted();
+// format = globaldata->getFormat();
+ sorted = sort;
+ scaler = scale;
+ outputDir = dir;
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the HeatMap class function HeatMap. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "HeatMap", "HeatMap");
exit(1);
}
}
void HeatMap::getPic(RAbundVector* rabund) {
try {
- //get users scaling method
- scaler = globaldata->getScale();
+
float maxRelAbund = 0.0;
if(relAbund > maxRelAbund){ maxRelAbund = relAbund; }
}
- scaler = globaldata->getScale();
vector<string> scaleRelAbund(rabund->size(), "");
}
- string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.bin.svg";
+ string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + rabund->getLabel() + ".heatmap.bin.svg";
openOutputFile(filenamesvg, outsvg);
//svg image
- outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((rabund->getNumBins()*5 + 120)) + "\">\n";
+ outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((rabund->getNumBins()*5 + 120)) + "\">\n";
outsvg << "<g>\n";
//white backround
}
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";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "HeatMap", "getPic");
exit(1);
}
}
if(maxRelAbund[i] > superMaxRelAbund){ superMaxRelAbund = maxRelAbund[i]; }
}
- scaler = globaldata->getScale();
-
scaleRelAbund.resize(lookup.size());
for(int i=0;i<lookup.size();i++){
scaleRelAbund[i].assign(lookup[i]->size(), "");
}
}
- string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.bin.svg";
+ string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
openOutputFile(filenamesvg, outsvg);
//svg image
- outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((lookup[0]->getNumBins()*5 + 120)) + "\">\n";
+ outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((lookup[0]->getNumBins()*5 + 120)) + "\">\n";
outsvg << "<g>\n";
//white backround
}
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";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the HeatMap class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "HeatMap", "getPic");
exit(1);
}
}
//fill lookup
for (int j = 0; j < looktemp.size(); j++) {
//if they are not shared then push to back, if they are not insert in front
- if (count < 2) { lookup[j]->push_back(looktemp[j]->getAbundance(i), i, looktemp[j]->getGroup()); }
+ if (count < 2) { lookup[j]->push_back(looktemp[j]->getAbundance(i), looktemp[j]->getGroup()); }
//they are shared by some
else { lookup[j]->insert(looktemp[j]->getAbundance(i), place[count], looktemp[j]->getGroup()); updatePlace = true; }
}
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function sortSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
- catch(...) {
- cout << "An unknown error has occurred in the HeatMap class function sortSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "HeatMap", "sortSharedVectors");
exit(1);
}
-
}
//**********************************************************************************************************************
}
catch(exception& e) {
- cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+ errorOut(e, "HeatMap", "printLegend");
exit(1);
}
- catch(...) {
- cout << "An unknown error has occurred in the HeatMap class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
- exit(1);
- }
-
}