From 69180c6a4fd3c9ad48974b402d398efe61a58fa7 Mon Sep 17 00:00:00 2001 From: westcott Date: Mon, 30 Mar 2009 13:58:26 +0000 Subject: [PATCH] made sorting optional but sort by default, in case the user wants to see the heatmap representation of their inputfile. --- errorchecking.cpp | 2 ++ errorchecking.h | 2 +- globaldata.cpp | 7 ++++++- globaldata.hpp | 3 ++- heatmap.cpp | 3 ++- heatmap.h | 3 +-- validparameter.cpp | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/errorchecking.cpp b/errorchecking.cpp index 59095f7..a057e5d 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -110,6 +110,7 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "label" ) { label = value; } if (parameter == "abund" ) { abund = value; } if (parameter == "random" ) { randomtree = value; } + if (parameter == "sorted" ) { sorted = value; } } //gets the last parameter and value @@ -142,6 +143,7 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "label" ) { label = value; } if (parameter == "random" ) { randomtree = value; } if (parameter == "abund" ) { abund = value; } + if (parameter == "sorted" ) { sorted = value; } } } diff --git a/errorchecking.h b/errorchecking.h index 4c9fe86..42188c0 100644 --- a/errorchecking.h +++ b/errorchecking.h @@ -33,7 +33,7 @@ class ErrorCheck { void clear(); void refresh(); string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, cutoff, format; - string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund; + string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted; string commandName, optionText; bool errorFree; diff --git a/globaldata.cpp b/globaldata.cpp index 2848860..64a7c93 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -74,6 +74,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "calc") { calc = value; } if (key == "step") { step = value; } if (key == "form") { form = value; } + if (key == "sorted") { sorted = value; } @@ -125,9 +126,10 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "fileroot" ) { fileroot = value; } if (key == "abund" ) { abund = value; } if (key == "random" ) { randomtree = value; } - if (key == "calc") { calc = value; } + if (key == "calc") { calc = value; } if (key == "step") { step = value; } if (key == "form") { form = value; } + if (key == "sorted") { sorted = value; } if (key == "line") {//stores lines to be used in a vector lines.clear(); @@ -233,6 +235,7 @@ string GlobalData::getRandomTree() { return randomtree; } string GlobalData::getGroups() { return groups; } string GlobalData::getStep() { return step; } string GlobalData::getForm() { return form; } +string GlobalData::getSorted() { return sorted; } void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;} void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;} void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;} @@ -283,6 +286,7 @@ void GlobalData::clear() { abund = "10"; step = "0.01"; form = "integral"; + sorted = "1"; //0 means don't sort, 1 means sort. } //*******************************************************/ @@ -294,6 +298,7 @@ void GlobalData::reset() { iters = "1000"; groups = ""; jumble = "1"; //0 means don't jumble, 1 means jumble. + sorted = "1"; //0 means don't sort, 1 means sort. randomtree = ""; //"" means user will enter some user trees, "outputfile" means they just want the random tree distribution to be outputted to outputfile. freq = "100"; method = "furthest"; diff --git a/globaldata.hpp b/globaldata.hpp index 16bc8d3..f74619e 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -62,6 +62,7 @@ public: string getGroups(); string getStep(); string getForm(); + string getSorted(); void setListFile(string); void setPhylipFile(string); @@ -82,7 +83,7 @@ public: private: string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, orderfile, fastafile, treefile, sharedfile, line, label, randomtree, groups; - string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form; + string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted; static GlobalData* _uniqueInstance; GlobalData( const GlobalData& ); // Disable copy constructor diff --git a/heatmap.cpp b/heatmap.cpp index 86786e7..4ce6f2c 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -14,6 +14,7 @@ HeatMap::HeatMap(){ try { globaldata = GlobalData::getInstance(); format = globaldata->getFormat(); + sorted = globaldata->getSorted(); } catch(exception& e) { @@ -88,7 +89,7 @@ void HeatMap::getPic(SharedOrderVector* sharedorder) { getSharedVectors(sharedorder); //sort lookup so shared bins are on top - sortSharedVectors(); + if (sorted == "1") { sortSharedVectors(); } //get maxBin for (int i = 0; i < lookup.size(); i++) { diff --git a/heatmap.h b/heatmap.h index c26684e..e236ce3 100644 --- a/heatmap.h +++ b/heatmap.h @@ -36,11 +36,10 @@ class HeatMap { GlobalData* globaldata; vector lookup; RAbundVector rabund; - string format; + string format, sorted, groupComb; ofstream outsvg; map colorScale; map::iterator it; - string groupComb; }; diff --git a/validparameter.cpp b/validparameter.cpp index 6af6c15..51fefd8 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -277,7 +277,7 @@ void ValidParameters::initCommandParameters() { string unifracUnweightedArray[] = {"group","iters"}; commandParameters["unifrac.unweighted"] = addParameters(unifracUnweightedArray, sizeof(unifracUnweightedArray)/sizeof(string)); - string heatmapArray[] = {"group","line","label"}; + string heatmapArray[] = {"group","line","label","sorted"}; commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string)); string quitArray[] = {}; -- 2.39.2