]> git.donarmstrong.com Git - mothur.git/commitdiff
added heatmap.sim command and changed heatmap to heatmap.bin
authorwestcott <westcott>
Mon, 8 Jun 2009 16:14:18 +0000 (16:14 +0000)
committerwestcott <westcott>
Mon, 8 Jun 2009 16:14:18 +0000 (16:14 +0000)
15 files changed:
Mothur.xcodeproj/project.pbxproj
commandfactory.cpp
errorchecking.cpp
globaldata.cpp
heatmap.cpp
heatmapsim.cpp [new file with mode: 0644]
heatmapsim.h [new file with mode: 0644]
heatmapsimcommand.cpp [new file with mode: 0644]
heatmapsimcommand.h [new file with mode: 0644]
helpcommand.cpp
readotu.cpp
validcalculator.cpp
validcalculator.h
validcommands.cpp
validparameter.cpp

index f6eeacb79539bb1f1eebe7a8bf0c2fb7e92a3e74..3f1cd9953b270c8f686650a0936d384f31f75885 100644 (file)
@@ -56,6 +56,8 @@
                375AA13A0F9E433D008EF9B8 /* readotu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1350F9E433D008EF9B8 /* readotu.cpp */; };
                375AA13B0F9E433D008EF9B8 /* readphylip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 375AA1370F9E433D008EF9B8 /* readphylip.cpp */; };
                377326650FAF16E0007ABB8B /* concensuscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 377326630FAF16E0007ABB8B /* concensuscommand.cpp */; };
+               378598660FDD497000EF9D03 /* heatmapsimcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */; };
+               378598740FDD4C1500EF9D03 /* heatmapsim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378598730FDD4C1500EF9D03 /* heatmapsim.cpp */; };
                378C1B030FB0644E004D63F5 /* filterseqscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */; };
                378C1B040FB0644E004D63F5 /* goodscoverage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AF00FB0644D004D63F5 /* goodscoverage.cpp */; };
                378C1B0A0FB0644E004D63F5 /* sequencedb.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378C1AFD0FB0644D004D63F5 /* sequencedb.cpp */; };
                375AA1380F9E433D008EF9B8 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylip.h; sourceTree = SOURCE_ROOT; };
                377326630FAF16E0007ABB8B /* concensuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = concensuscommand.cpp; sourceTree = SOURCE_ROOT; };
                377326640FAF16E0007ABB8B /* concensuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concensuscommand.h; sourceTree = SOURCE_ROOT; };
+               378598640FDD497000EF9D03 /* heatmapsimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsimcommand.h; sourceTree = "<group>"; };
+               378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsimcommand.cpp; sourceTree = "<group>"; };
+               378598720FDD4C1500EF9D03 /* heatmapsim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsim.h; sourceTree = "<group>"; };
+               378598730FDD4C1500EF9D03 /* heatmapsim.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsim.cpp; sourceTree = "<group>"; };
                378C1AEE0FB0644D004D63F5 /* filterseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filterseqscommand.cpp; sourceTree = SOURCE_ROOT; };
                378C1AEF0FB0644D004D63F5 /* filterseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filterseqscommand.h; sourceTree = SOURCE_ROOT; };
                378C1AF00FB0644D004D63F5 /* goodscoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = goodscoverage.cpp; sourceTree = SOURCE_ROOT; };
                                373C68BA0FC1C1A600137ACD /* gotohoverlap.cpp */,
                                375873ED0F7D646F0040F377 /* heatmap.h */,
                                375873EE0F7D646F0040F377 /* heatmap.cpp */,
+                               378598720FDD4C1500EF9D03 /* heatmapsim.h */,
+                               378598730FDD4C1500EF9D03 /* heatmapsim.cpp */,
                                37D927E60F21331F001D4494 /* inputdata.h */,
                                37D927E50F21331F001D4494 /* inputdata.cpp */,
                                7E412F420F8D213C00381DD0 /* libshuff.h */,
                37D928A90F2133E5001D4494 /* commands */ = {
                        isa = PBXGroup;
                        children = (
-                               7E09C5340FDA7F65002ECAE5 /* trimseqscommand.h */,
-                               7E09C5350FDA7F65002ECAE5 /* trimseqscommand.cpp */,
-                               7E09C5120FDA79C5002ECAE5 /* reversecommand.h */,
-                               7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */,
                                37D927CD0F21331F001D4494 /* command.hpp */,
                                378DC5CD0FBDE1C8003B8607 /* aligncommand.h */,
                                378DC5CE0FBDE1C8003B8607 /* aligncommand.cpp */,
                                3749271C0FD58C840031C06B /* getsabundcommand.cpp */,
                                375873F10F7D64800040F377 /* heatmapcommand.h */,
                                375873F00F7D64800040F377 /* heatmapcommand.cpp */,
+                               378598640FDD497000EF9D03 /* heatmapsimcommand.h */,
+                               378598650FDD497000EF9D03 /* heatmapsimcommand.cpp */,
                                37D927E40F21331F001D4494 /* helpcommand.h */,
                                37D927E30F21331F001D4494 /* helpcommand.cpp */,
                                375873F40F7D648F0040F377 /* libshuffcommand.h */,
                                372E126F0F26365B0095CF7E /* readotucommand.cpp */,
                                37E5F4900F2A3DA800F8D827 /* readtreecommand.h */,
                                37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */,
+                               7E09C5120FDA79C5002ECAE5 /* reversecommand.h */,
+                               7E09C5130FDA79C5002ECAE5 /* reversecommand.cpp */,
                                371B30B30FD7EE67000414CA /* screenseqscommand.h */,
                                371B30B20FD7EE67000414CA /* screenseqscommand.cpp */,
                                3799A94E0FD6A58C00E33EDE /* seqsummarycommand.cpp */,
                                37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */,
                                211C38370F961E1F00FEE541 /* treegroupscommand.h */,
                                211C38360F961E1F00FEE541 /* treegroupscommand.cpp */,
+                               7E09C5340FDA7F65002ECAE5 /* trimseqscommand.h */,
+                               7E09C5350FDA7F65002ECAE5 /* trimseqscommand.cpp */,
                                3746109B0F40657600460C57 /* unifracunweightedcommand.h */,
                                3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */,
                                374610760F40645300460C57 /* unifracweightedcommand.h */,
                                371B30B40FD7EE67000414CA /* screenseqscommand.cpp in Sources */,
                                7E09C5140FDA79C5002ECAE5 /* reversecommand.cpp in Sources */,
                                7E09C5360FDA7F65002ECAE5 /* trimseqscommand.cpp in Sources */,
+                               378598660FDD497000EF9D03 /* heatmapsimcommand.cpp in Sources */,
+                               378598740FDD4C1500EF9D03 /* heatmapsim.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 8056227c3bce48545f7422502a4a7cbda163201f..8488e65b1f140184c9c183268ffc53662cf00fb8 100644 (file)
@@ -31,6 +31,7 @@
 #include "unifracweightedcommand.h"
 #include "libshuffcommand.h"
 #include "heatmapcommand.h"
+#include "heatmapsimcommand.h"
 #include "filterseqscommand.h"
 #include "mothur.h"
 #include "venncommand.h"
@@ -93,7 +94,8 @@ Command* CommandFactory::getCommand(string commandName){
                else if(commandName == "get.sabund")            {   command = new GetSAbundCommand();                   }
                else if(commandName == "get.rabund")            {   command = new GetRAbundCommand();                   }
                else if(commandName == "libshuff")              {   command = new LibShuffCommand();                    }
-               else if(commandName == "heatmap")                               {   command = new HeatMapCommand();                             }
+               else if(commandName == "heatmap.bin")                   {   command = new HeatMapCommand();                             }
+               else if(commandName == "heatmap.sim")                   {   command = new HeatMapSimCommand();                  }
                else if(commandName == "filter.seqs")                   {   command = new FilterSeqsCommand();          }
                else if(commandName == "venn")                                  {   command = new VennCommand();                                }
                else if(commandName == "bin.seqs")                              {   command = new BinSeqCommand();                              }
index db16ef377cd67eb9cc5e086bcb1afcd7be31bc40..e77c1663f25d41ba9a20cd22152c7f946a207b95 100644 (file)
@@ -270,9 +270,9 @@ bool ErrorCheck::checkInput(string input) {
                        }
                }
                
-               if ((commandName == "heatmap") || (commandName == "venn")) { 
+               if ((commandName == "heatmap.bin") || (commandName == "venn") || (commandName == "heatmap.sim")) { 
                        if ((globaldata->getListFile() == "") && (globaldata->getSharedFile() == "")) {
-                                cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap or venn commands." << endl; return false; 
+                                cout << "You must read a list, or a list and a group, or a shared before you can use the heatmap.bin, heatmap.sim or venn commands." << endl; return false; 
                        }
                }
                
index a3dc757cba2e9adf6aecc051f3a03d9875b92026..d24f4b9eb8171a462b09b9f1fecceee533f99708 100644 (file)
@@ -260,7 +260,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){
                        Estimators.clear();
                        splitAtDash(calc, Estimators); 
                }
-               if((commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared")) {
+               if((commandName == "tree.shared") || (commandName == "bootstrap.shared") || (commandName == "dist.shared") || (commandName == "heatmap.sim")) {
                        if((calc == "default") || (calc == "")) { 
                                calc = "jclass-thetayc";
                        }
index 3aceef1613205f41925e810ac35c979f225168db..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
@@ -144,7 +144,7 @@ void HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
                        }
                }
 
-               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
diff --git a/heatmapsim.cpp b/heatmapsim.cpp
new file mode 100644 (file)
index 0000000..33588e6
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ *  heatmapsim.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 6/8/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "heatmapsim.h"
+#include "sharedjabund.h"
+#include "sharedsorabund.h"
+#include "sharedjclass.h"
+#include "sharedsorclass.h"
+#include "sharedjest.h"
+#include "sharedsorest.h"
+#include "sharedthetayc.h"
+#include "sharedthetan.h"
+#include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
+
+//**********************************************************************************************************************
+HeatMapSim::HeatMapSim(){
+       try {
+               globaldata = GlobalData::getInstance();
+       }
+       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";
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void HeatMapSim::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> calcs) {
+       try {
+               EstOutput data;
+               vector<double> sims;
+                               
+               //make file for each calculator selected
+               for (int m = 0; m < calcs.size(); m++) {
+                       
+                       string filenamesvg = getRootName(globaldata->inputFileName) + lookup[0]->getLabel() + calcs[m]->getName() + ".heatmap.sim.svg";
+                       openOutputFile(filenamesvg, outsvg);
+                       
+                       //svg image
+                       outsvg << "<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString((lookup.size() * 150) + 160) + " " + toString((lookup.size() * 150) + 160)  + "\">\n";
+                       outsvg << "<g>\n";
+               
+                       //white backround
+                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString((lookup.size() * 150) + 160) + "\" height=\"" + toString((lookup.size() * 150) + 160)  + "\"/>"; 
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((lookup.size() * 75) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
+               
+                       //column labels
+                       for (int h = 0; h < lookup.size(); h++) {
+                               outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(((150 * (h+1)) ) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n"; 
+                               outsvg << "<text fill=\"black\" class=\"seri\" y=\"" + toString(((150 * (h+1)) ) - ((int)lookup[h]->getGroup().length() / 2)) + "\" x=\"50\">" + lookup[h]->getGroup() + "</text>\n";
+                       }
+                       
+                       sims.clear();
+                       double biggest = -1;
+                       float scaler;
+
+                       //get sim for each comparison and save them so you can find the relative similairity
+                       for(int i = 0; i < (lookup.size()-1); i++){
+                               for(int j = (i+1); j < lookup.size(); j++){
+                                       
+                                               vector<SharedRAbundVector*> subset;
+                                               subset.push_back(lookup[i]);  subset.push_back(lookup[j]); 
+                                       
+                                               //get similairity between groups
+                                               data = calcs[m]->getValues(subset);
+                                               sims.push_back(data[0]);
+                                       
+                                               //save biggest similairity to set relative sim
+                                               if (data[0] > biggest) { biggest = data[0]; }
+                               }
+                       }
+                       
+                       //map biggest similairity found to red
+                       scaler = 255.0 / biggest;
+                       
+                       int count = 0;
+                       //output similairites to file
+                       for(int i = 0; i < (lookup.size()-1); i++){
+                               for(int j = (i+1); j < lookup.size(); j++){
+                               
+                                               //find relative color
+                                               int color = scaler * sims[count];                                       
+                                               //draw box
+                                               outsvg << "<rect fill=\"rgb(" + toString(color) + ",0,0)\" stroke=\"rgb(" + toString(color) + ",0,0)\" x=\"" + toString((i*150)+80) + "\" y=\"" + toString((j*150)+75) + "\" width=\"150\" height=\"150\"/>\n";
+                                               count++;
+                               }
+                       }
+                       
+                       int y = ((lookup.size() * 150) + 120);
+                       printLegend(y, biggest);
+               
+                       outsvg << "</g>\n</svg>\n";
+                       outsvg.close();
+
+               }
+               
+               
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the HeatMapSim class function getPic. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+}
+//**********************************************************************************************************************
+
+void HeatMapSim::printLegend(int y, float maxSim) {
+       try {
+               
+               //output legend and color labels
+               //go through map and give each score a color value
+               string color;
+               int x = 10;
+               
+               //prints legend
+               for (int i = 1; i < 255; i++) {
+                       color = toHex(int((float)(i)));
+                       outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"1\" height=\"10\"/>\n";
+                       x += 1;
+               }
+               
+               float scaler = maxSim / 5.0;
+               
+               //prints legend labels
+               x = 10;
+               for (int i = 1; i<=5; i++) {
+                       float label = scaler*i;
+                       label = int(label * 1000 + 0.5);
+                       label /= 1000.0;
+                       string text = toString(label, 3);
+                       
+                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y-3) + "\">" + text + "</text>\n";
+                       x += 60;
+               }
+       }
+       
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSim class Function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the HeatMapSim class function printLegend. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       
+}
+
+//**********************************************************************************************************************
+
+
+
+
diff --git a/heatmapsim.h b/heatmapsim.h
new file mode 100644 (file)
index 0000000..c3ec2a7
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef HEATMAPSIM_H
+#define HEATMAPSIM_H
+/*
+ *  heatmapsim.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 6/8/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+
+#include "sharedrabundvector.h"
+#include "datavector.hpp"
+#include "globaldata.hpp"
+#include "calculator.h"
+
+/***********************************************************************/
+
+class HeatMapSim {
+       
+       public:
+               HeatMapSim();
+               ~HeatMapSim(){};
+       
+               void getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
+
+       private:
+               void printLegend(int, float);
+
+               GlobalData* globaldata;
+               string format, groupComb;
+               ofstream outsvg;
+                       
+};
+
+/***********************************************************************/
+
+#endif
+
diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp
new file mode 100644 (file)
index 0000000..dc3db89
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ *  heatmapsimcommand.cpp
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 6/8/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "heatmapsimcommand.h"
+#include "sharedjabund.h"
+#include "sharedsorabund.h"
+#include "sharedjclass.h"
+#include "sharedsorclass.h"
+#include "sharedjest.h"
+#include "sharedsorest.h"
+#include "sharedthetayc.h"
+#include "sharedthetan.h"
+#include "sharedmorisitahorn.h"
+#include "sharedbraycurtis.h"
+
+
+//**********************************************************************************************************************
+
+HeatMapSimCommand::HeatMapSimCommand(){
+       try {
+               globaldata = GlobalData::getInstance();
+               validCalculator = new ValidCalculators();
+               heatmap = new HeatMapSim();
+                       
+               int i;
+               for (i=0; i<globaldata->Estimators.size(); i++) {
+                       if (validCalculator->isValidCalculator("heat", globaldata->Estimators[i]) == true) { 
+                               if (globaldata->Estimators[i] == "jabund") {    
+                                       heatCalculators.push_back(new JAbund());
+                               }else if (globaldata->Estimators[i] == "sorabund") { 
+                                       heatCalculators.push_back(new SorAbund());
+                               }else if (globaldata->Estimators[i] == "jclass") { 
+                                       heatCalculators.push_back(new Jclass());
+                               }else if (globaldata->Estimators[i] == "sorclass") { 
+                                       heatCalculators.push_back(new SorClass());
+                               }else if (globaldata->Estimators[i] == "jest") { 
+                                       heatCalculators.push_back(new Jest());
+                               }else if (globaldata->Estimators[i] == "sorest") { 
+                                       heatCalculators.push_back(new SorEst());
+                               }else if (globaldata->Estimators[i] == "thetayc") { 
+                                       heatCalculators.push_back(new ThetaYC());
+                               }else if (globaldata->Estimators[i] == "thetan") { 
+                                       heatCalculators.push_back(new ThetaN());
+                               }else if (globaldata->Estimators[i] == "morisitahorn") { 
+                                       heatCalculators.push_back(new MorHorn());
+                               }else if (globaldata->Estimators[i] == "braycurtis") { 
+                                       heatCalculators.push_back(new BrayCurtis());
+                               }
+                       }
+               }
+               
+               //reset calc for next command
+               globaldata->setCalc("");
+
+
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the HeatMapSimCommand class function HeatMapSimCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+//**********************************************************************************************************************
+
+HeatMapSimCommand::~HeatMapSimCommand(){
+       delete input;
+       delete read;
+       delete heatmap;
+}
+
+//**********************************************************************************************************************
+
+int HeatMapSimCommand::execute(){
+       try {
+               int count = 1;  
+               
+               //if the users entered no valid calculators don't execute command
+               if (heatCalculators.size() == 0) { cout << "No valid calculators." << endl; return 0; }
+               
+               //you have groups
+               read = new ReadOTUFile(globaldata->inputFileName);      
+               read->read(&*globaldata); 
+                       
+               input = globaldata->ginput;
+               lookup = input->getSharedRAbundVectors();
+               vector<SharedRAbundVector*> lastLookup = lookup;
+               
+               if (lookup.size() < 2) { cout << "You have not provided enough valid groups.  I cannot run the command." << endl; return 0;}
+                               
+               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
+               set<string> processedLabels;
+               set<string> userLabels = globaldata->labels;
+               set<int> userLines = globaldata->lines;
+
+               
+               //as long as you are not at the end of the file or done wih the lines you want
+               while((lookup[0] != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
+               
+                       if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(lookup[0]->getLabel()) == 1){                   
+       
+                               cout << lookup[0]->getLabel() << '\t' << count << endl;
+                               heatmap->getPic(lookup, heatCalculators);
+                                       
+                               processedLabels.insert(lookup[0]->getLabel());
+                               userLabels.erase(lookup[0]->getLabel());
+                               userLines.erase(count);
+                       }
+                               
+                       if ((anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLookup[0]->getLabel()) != 1)) {
+                               cout << lastLookup[0]->getLabel() << '\t' << count << endl;
+                               heatmap->getPic(lastLookup, heatCalculators);
+                                       
+                               processedLabels.insert(lastLookup[0]->getLabel());
+                               userLabels.erase(lastLookup[0]->getLabel());
+                       }
+                               
+                       //prevent memory leak
+                       if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  } }
+                       lastLookup = lookup;                    
+
+                       //get next line to process
+                       lookup = input->getSharedRAbundVectors();                               
+                       count++;
+               }
+                       
+               //output error messages about any remaining user labels
+               set<string>::iterator it;
+               bool needToRun = false;
+               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
+                       cout << "Your file does not include the label "<< *it; 
+                       if (processedLabels.count(lastLookup[0]->getLabel()) != 1) {
+                               cout << ". I will use " << lastLookup[0]->getLabel() << "." << endl;
+                               needToRun = true;
+                       }else {
+                               cout << ". Please refer to " << lastLookup[0]->getLabel() << "." << endl;
+                       }
+               }
+               
+               //run last line if you need to
+               if (needToRun == true)  {
+                       cout << lastLookup[0]->getLabel() << '\t' << count << endl;
+                       heatmap->getPic(lastLookup, heatCalculators);
+               }
+               
+               for (int i = 0; i < lastLookup.size(); i++) {  delete lastLookup[i];  }
+                       
+               //reset groups parameter
+               globaldata->Groups.clear();  
+               globaldata->setGroups("");
+               
+               return 0;
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the HeatMapSimCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the HeatMapSimCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }               
+}
+
+//**********************************************************************************************************************
diff --git a/heatmapsimcommand.h b/heatmapsimcommand.h
new file mode 100644 (file)
index 0000000..33696a3
--- /dev/null
@@ -0,0 +1,40 @@
+#ifndef HEATMAPSIMCOMMAND_H
+#define HEATMAPSIMCOMMAND_H
+
+/*
+ *  heatmapsimcommand.h
+ *  Mothur
+ *
+ *  Created by Sarah Westcott on 6/8/09.
+ *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
+ *
+ */
+
+#include "command.hpp"
+#include "inputdata.h"
+#include "readotu.h"
+#include "validcalculator.h"
+#include "heatmapsim.h"
+
+class GlobalData;
+
+class HeatMapSimCommand : public Command {
+
+public:
+       HeatMapSimCommand();
+       ~HeatMapSimCommand();
+       int execute();
+       
+private:
+       GlobalData* globaldata;
+       ReadOTUFile* read;
+       InputData* input;
+       vector<SharedRAbundVector*> lookup;
+       vector<Calculator*> heatCalculators;
+       ValidCalculators* validCalculator;
+       HeatMapSim* heatmap;
+
+};
+
+#endif
+
index a572e7616f6263a43c48c0ce2d8a7fe87db0d644..00cd8ddf5a0b089f39f3a8d5d987d59ab204b333 100644 (file)
@@ -227,19 +227,19 @@ int HelpCommand::execute(){
                cout << "The default value for groups is all the groups in your groupfile, iters is 10000, cutoff is 1.0, form is integral and step is 0.01." << "\n";
                cout << "The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual." << "\n";
                cout << "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters)." << "\n" << "\n";
-       }else if (globaldata->helpRequest == "heatmap") { 
-               cout << "The heatmap command can only be executed after a successful read.otu command." << "\n";
-               cout << "The heatmap command parameters are groups, sorted, scale, line and label.  No parameters are required, but you may not use line and label at the same time." << "\n";
+       }else if (globaldata->helpRequest == "heatmap.bin") { 
+               cout << "The heatmap.bin command can only be executed after a successful read.otu command." << "\n";
+               cout << "The heatmap.bin command parameters are groups, sorted, scale, line and label.  No parameters are required, but you may not use line and label at the same time." << "\n";
                cout << "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap." << "\n";
                cout << "The sorted parameter allows you to choose to see the file with the shared otus at the top or the otus in the order they appear in your input file. " << "\n";
                cout << "The scale parameter allows you to choose the range of color your bin information will be displayed with." << "\n";
                cout << "The group names are separated by dashes. The line and label allow you to select what distance levels you would like a heatmap created for, and are also separated by dashes." << "\n";
-               cout << "The heatmap command should be in the following format: heatmap(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n";
-               cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n";
+               cout << "The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, line=yourLines, label=yourLabels)." << "\n";
+               cout << "Example heatmap.bin(groups=A-B-C, line=1-3-5, sorted=F, scale=log10)." << "\n";
                cout << "The default value for groups is all the groups in your groupfile, and all lines in your inputfile will be used." << "\n";
                cout << "The default value for sorted is T meaning you want the shared otus on top, you may change it to F meaning the exact representation of your input file." << "\n";
                cout << "The default value for scale is log10; your other options are log2 and linear." << "\n";
-               cout << "The heatmap command outputs a .svg file for each line or label you specify." << "\n";
+               cout << "The heatmap.bin command outputs a .svg file for each line or label you specify." << "\n";
                cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n";
        }else if (globaldata->helpRequest == "venn") { 
                cout << "The venn command can only be executed after a successful read.otu command." << "\n";
index 971ed31ae005e15b3ec0785a9728311ef6ca12f8..455641a8f52b7cb24c0b5e74d19ff83c27ed6667 100644 (file)
@@ -43,7 +43,7 @@ void ReadOTUFile::read(GlobalData* globaldata){
                        sabund = inputSabund->getSAbundVector(); 
                        globaldata->sabund = sabund; //saving to be used by summary command.
                        rabund = inputRabund->getRAbundVector(); 
-                       globaldata->rabund = rabund; //saving to be used by heatmap command.
+                       globaldata->rabund = rabund; //saving to be used by heatmap.bin command.
                        list = inputList->getListVector();
                        globaldata->gListVector = list;
                }else if (globaldata->getFormat() == "shared") {
index 25efa1f2fc784f2fca37e3a478fc2740507df8ab..c0e5eed7d014f96c2ebb4b39ea8aa6e1c793b8e6 100644 (file)
@@ -24,6 +24,7 @@ ValidCalculators::ValidCalculators() {
                 initialBoot();
                 initialDistance();
                 initialMatrix();
+                initialHeat();
        }
        catch(exception& e) {
                cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function ValidCalculator. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
@@ -158,6 +159,17 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
                                }
                                cout << endl;
                                return false; }
+               }else if (parameter == "heat") {
+                       //is it valid
+                       if ((heat.find(calculator)) != (heat.end())) {
+                               return true;
+                       }else { 
+                               cout << calculator << " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ";
+                               for (it = heat.begin(); it != heat.end(); it++) {
+                                       cout << it->first << ", ";
+                               }
+                               cout << endl;
+                               return false; }
                }else if (parameter == "boot") {
                        //is it valid
                        if ((boot.find(calculator)) != (boot.end())) {
@@ -442,6 +454,30 @@ void ValidCalculators::initialTreeGroups() {
                exit(1);
        }       
 }
+/********************************************************************/
+void ValidCalculators::initialHeat() {
+       try {   
+               heat["jabund"]                          = "jabund";
+               heat["sorabund"]                        = "sorabund";
+               heat["jclass"]                          = "jclass";
+               heat["sorclass"]                        = "sorclass";
+               heat["jest"]                            = "jest";
+               heat["sorest"]                          = "sorest";
+               heat["thetayc"]                         = "thetayc";
+               heat["thetan"]                          = "thetan";
+               heat["morisitahorn"]            = "morisitahorn";
+               heat["braycurtis"]                      = "braycurtis";
+       }
+       catch(exception& e) {
+               cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }
+       catch(...) {
+               cout << "An unknown error has occurred in the ValidCalculator class function initialHeat. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
+               exit(1);
+       }       
+}
+
 /********************************************************************/
 void ValidCalculators::initialMatrix() {
        try {   
index ff93c58ccc980684ae52f48b08cac9d380cf7a88..320f9822662f842faecec103ef29ba75495e77af 100644 (file)
@@ -35,6 +35,7 @@ class ValidCalculators {
                map<string, string> vennshared;
                map<string, string> treegroup;
                map<string, string> matrix;
+               map<string, string> heat;
                map<string, string> boot;
                map<string, string> distance;
                map<string, string>::iterator it;
@@ -51,6 +52,7 @@ class ValidCalculators {
                void initialMatrix();
                void initialBoot();
                void initialDistance();
+               void initialHeat();
 };
 
 #endif
index 936e706071aaa2dea1cd775e62c9e9ce264b41e8..e5f93a91e125798f556c8769cbe51af9ae0e3e65 100644 (file)
@@ -34,7 +34,8 @@ ValidCommands::ValidCommands() {
                commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
                commands["libshuff"]                    = "libshuff";
                commands["tree.shared"]                 = "tree.shared";
-               commands["heatmap"]                             = "heatmap";
+               commands["heatmap.bin"]                 = "heatmap.bin";
+               commands["heatmap.sim"]                 = "heatmap.sim";
                commands["venn"]                                = "venn";
                commands["get.group"]           = "get.group";
                commands["get.label"]           = "get.label";
index ae5fc3ff8590d0f9291aec0618dfd08d3d989605..d6fde63045c51d56449b14701dde04974503fb82 100644 (file)
@@ -271,7 +271,10 @@ void ValidParameters::initCommandParameters() {
                commandParameters["unifrac.unweighted"] = addParameters(unifracUnweightedArray, sizeof(unifracUnweightedArray)/sizeof(string));
 
                string heatmapArray[] =  {"groups","line","label","sorted","scale"};
-               commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
+               commandParameters["heatmap.bin"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string));
+               
+               string heatmapSimArray[] =  {"groups","line","label"};
+               commandParameters["heatmap.sim"] = addParameters(heatmapSimArray, sizeof(heatmapSimArray)/sizeof(string));
                
                string filterseqsArray[] =  {"fasta", "trump", "soft", "hard", "vertical"};
                commandParameters["filter.seqs"] = addParameters(filterseqsArray, sizeof(filterseqsArray)/sizeof(string));