X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=heatmap.cpp;h=2bd020e0c3cf8337c0671c1db515954e51177dd0;hb=96b36196d49a3d1f6bc49a26a9d2aa2da7ff876e;hp=4bb9385cdfdd23960481556afe31e0d485e9a7ec;hpb=cdcf99b7760701e6869ca8e4e6e91c8e8c4ae186;p=mothur.git diff --git a/heatmap.cpp b/heatmap.cpp index 4bb9385..2bd020e 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -10,18 +10,16 @@ #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); } } @@ -30,8 +28,7 @@ HeatMap::HeatMap(){ void HeatMap::getPic(RAbundVector* rabund) { try { - //get users scaling method - scaler = globaldata->getScale(); + float maxRelAbund = 0.0; @@ -40,7 +37,6 @@ void HeatMap::getPic(RAbundVector* rabund) { if(relAbund > maxRelAbund){ maxRelAbund = relAbund; } } - scaler = globaldata->getScale(); vector scaleRelAbund(rabund->size(), ""); @@ -62,11 +58,11 @@ void HeatMap::getPic(RAbundVector* rabund) { } - string filenamesvg = getRootName(globaldata->inputFileName) + rabund->getLabel() + ".heatmap.svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + rabund->getLabel() + ".heatmap.bin.svg"; openOutputFile(filenamesvg, outsvg); //svg image - outsvg << "getNumBins()*5 + 120)) + "\">\n"; + outsvg << "getNumBins()*5 + 120)) + "\">\n"; outsvg << "\n"; //white backround @@ -92,11 +88,7 @@ void HeatMap::getPic(RAbundVector* rabund) { } 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); } } @@ -106,7 +98,7 @@ void HeatMap::getPic(RAbundVector* rabund) { void HeatMap::getPic(vector lookup) { try { //sort lookup so shared bins are on top - if (sorted == "T") { sortSharedVectors(lookup); } + if (isTrue(sorted) == true) { sortSharedVectors(lookup); } vector > scaleRelAbund; vector maxRelAbund(lookup.size(), 0.0); @@ -121,8 +113,6 @@ void HeatMap::getPic(vector lookup) { if(maxRelAbund[i] > superMaxRelAbund){ superMaxRelAbund = maxRelAbund[i]; } } - scaler = globaldata->getScale(); - scaleRelAbund.resize(lookup.size()); for(int i=0;isize(), ""); @@ -144,11 +134,11 @@ void HeatMap::getPic(vector lookup) { } } - string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + ".heatmap.svg"; + string filenamesvg = outputDir + getRootName(getSimpleName(globaldata->inputFileName)) + lookup[0]->getLabel() + ".heatmap.bin.svg"; openOutputFile(filenamesvg, outsvg); //svg image - outsvg << "getNumBins()*5 + 120)) + "\">\n"; + outsvg << "getNumBins()*5 + 120)) + "\">\n"; outsvg << "\n"; //white backround @@ -182,11 +172,7 @@ void HeatMap::getPic(vector lookup) { } 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); } } @@ -246,7 +232,7 @@ void HeatMap::sortSharedVectors(vector& lookup){ //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; } } @@ -266,14 +252,9 @@ void HeatMap::sortSharedVectors(vector& lookup){ } 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); } - } //********************************************************************************************************************** @@ -301,7 +282,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); @@ -312,14 +292,9 @@ void HeatMap::printLegend(int y, float maxbin) { } 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); - } - }