From c5c7502f435e1413c19e373dab1dfebcaa67588d Mon Sep 17 00:00:00 2001 From: westcott Date: Tue, 14 Apr 2009 12:04:57 +0000 Subject: [PATCH] started shared utilities, updates to venn and heatmap added tree.groups command --- Mothur.xcodeproj/project.pbxproj | 14 +- averagelinkage.cpp | 3 +- bergerparker.cpp | 1 - binsequencecommand.h | 1 + bstick.cpp | 2 +- calculator.h | 1 - cluster.cpp | 1 + cluster.hpp | 2 - collect.cpp | 1 - collect.h | 1 + collectcommand.h | 2 +- collectdisplay.h | 2 +- collectsharedcommand.cpp | 52 +--- collectsharedcommand.h | 3 +- commandfactory.cpp | 3 +- commandfactory.hpp | 2 + commandoptionparser.cpp | 3 +- commandoptionparser.hpp | 2 + database.cpp | 2 +- database.hpp | 2 + deconvolutecommand.h | 1 - engine.cpp | 7 - engine.hpp | 6 + errorchecking.cpp | 9 +- errorchecking.h | 4 +- fastamap.h | 1 - fileoutput.cpp | 133 ++++++++++- fileoutput.h | 48 +++- geom.cpp | 1 - getoturepcommand.h | 2 + globaldata.cpp | 18 +- globaldata.hpp | 9 +- groupmap.h | 1 - heatmap.cpp | 167 +++++++------ heatmap.h | 11 +- heatmapcommand.cpp | 59 +---- heatmapcommand.h | 4 +- helpcommand.cpp | 10 +- inputdata.cpp | 1 - kmer.cpp | 2 +- kmer.hpp | 2 + kmerdb.cpp | 2 +- kmerdb.hpp | 2 + listvector.cpp | 1 - logsd.cpp | 1 - mothur.cpp | 4 + mothur.h | 389 +++++++++++++++++++++++++++++- nameassignment.hpp | 1 - ordervector.cpp | 1 - parsimonycommand.cpp | 98 +------- parsimonycommand.h | 7 +- qstat.cpp | 2 +- rabundvector.cpp | 2 - rabundvector.hpp | 3 + raredisplay.cpp | 7 +- raredisplay.h | 1 + rarefact.cpp | 2 +- rarefact.h | 2 +- rarefactsharedcommand.cpp | 52 +--- rarefactsharedcommand.h | 3 +- readmatrix.cpp | 1 - readmatrix.hpp | 1 + readtree.h | 2 +- sabundvector.cpp | 1 - shared.h | 1 + sharedbdiversity.cpp | 1 - sharedkstest.cpp | 2 - sharedlistvector.cpp | 1 - sharednseqs.h | 3 - sharedordervector.cpp | 1 - sharedordervector.h | 5 +- sharedrabundvector.cpp | 29 ++- sharedrabundvector.h | 1 + sharedsabundvector.cpp | 1 - sharedutilities.cpp | 292 +++++++++++++++++++++++ sharedutilities.h | 39 +++ singlelinkage.cpp | 1 + sparsematrix.cpp | 2 +- sparsematrix.hpp | 1 - summarysharedcommand.cpp | 95 +------- summarysharedcommand.h | 6 +- tree.cpp | 10 +- treecalculator.h | 1 - treegroupscommand.cpp | 292 +++++++++++++++++++++++ treegroupscommand.h | 63 +++++ treemap.cpp | 28 +++ treemap.h | 5 +- treenode.cpp | 5 + treenode.h | 4 +- unifracunweightedcommand.cpp | 98 +------- unifracunweightedcommand.h | 7 +- unifracweightedcommand.cpp | 118 +++------- unifracweightedcommand.h | 13 +- utilities.hpp | 392 ------------------------------- validcalculator.cpp | 38 +++ validcalculator.h | 3 +- validcommands.cpp | 1 + validparameter.cpp | 5 +- validparameter.h | 1 - venn.cpp | 119 ++++------ venn.h | 4 +- venncommand.cpp | 76 +----- venncommand.h | 4 +- 103 files changed, 1740 insertions(+), 1209 deletions(-) create mode 100644 sharedutilities.cpp create mode 100644 sharedutilities.h create mode 100644 treegroupscommand.cpp create mode 100644 treegroupscommand.h delete mode 100644 utilities.hpp diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index b63f108..967e8e4 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 372E12700F26365B0095CF7E /* readotucommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E126F0F26365B0095CF7E /* readotucommand.cpp */; }; 372E12960F263D5A0095CF7E /* readdistcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12950F263D5A0095CF7E /* readdistcommand.cpp */; }; 372E12ED0F264D320095CF7E /* commandfactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 372E12EC0F264D320095CF7E /* commandfactory.cpp */; }; + 3731C1F30F8CFC0A0065A2AD /* treegroupscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3731C1F20F8CFC0A0065A2AD /* treegroupscommand.cpp */; }; 374610780F40645300460C57 /* unifracweightedcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374610770F40645300460C57 /* unifracweightedcommand.cpp */; }; 3746107E0F4064D100460C57 /* weighted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3746107D0F4064D100460C57 /* weighted.cpp */; }; 374610830F40652400460C57 /* unweighted.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 374610820F40652400460C57 /* unweighted.cpp */; }; @@ -39,6 +40,7 @@ 37AFC71F0F445386005F492D /* sharedsobscollectsummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37AFC71E0F445386005F492D /* sharedsobscollectsummary.cpp */; }; 37B28F680F27590100808A62 /* deconvolutecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37B28F670F27590100808A62 /* deconvolutecommand.cpp */; }; 37C1D9730F86506E0059E3F0 /* binsequencecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */; }; + 37C7F3A90F8E90AD00E91C2B /* sharedutilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C7F3A80F8E90AD00E91C2B /* sharedutilities.cpp */; }; 37D928550F21331F001D4494 /* ace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927B80F21331F001D4494 /* ace.cpp */; }; 37D928560F21331F001D4494 /* averagelinkage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BA0F21331F001D4494 /* averagelinkage.cpp */; }; 37D928570F21331F001D4494 /* bootstrap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D927BB0F21331F001D4494 /* bootstrap.cpp */; }; @@ -142,6 +144,8 @@ 372E12940F263D5A0095CF7E /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readdistcommand.h; sourceTree = ""; }; 372E12950F263D5A0095CF7E /* readdistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readdistcommand.cpp; sourceTree = ""; }; 372E12EC0F264D320095CF7E /* commandfactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commandfactory.cpp; sourceTree = ""; }; + 3731C1F10F8CFC0A0065A2AD /* treegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treegroupscommand.h; sourceTree = ""; }; + 3731C1F20F8CFC0A0065A2AD /* treegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treegroupscommand.cpp; sourceTree = ""; }; 374610760F40645300460C57 /* unifracweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unifracweightedcommand.h; sourceTree = ""; }; 374610770F40645300460C57 /* unifracweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unifracweightedcommand.cpp; sourceTree = ""; }; 3746107C0F4064D100460C57 /* weighted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = weighted.h; sourceTree = ""; }; @@ -201,6 +205,8 @@ 37B28F670F27590100808A62 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = ""; }; 37C1D9710F86506E0059E3F0 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binsequencecommand.h; sourceTree = ""; }; 37C1D9720F86506E0059E3F0 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binsequencecommand.cpp; sourceTree = ""; }; + 37C7F3A70F8E90AD00E91C2B /* sharedutilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedutilities.h; sourceTree = ""; }; + 37C7F3A80F8E90AD00E91C2B /* sharedutilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedutilities.cpp; sourceTree = ""; }; 37D927B80F21331F001D4494 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = ""; }; 37D927B90F21331F001D4494 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = ""; }; 37D927BA0F21331F001D4494 /* averagelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = averagelinkage.cpp; sourceTree = ""; }; @@ -334,7 +340,6 @@ 37D928490F21331F001D4494 /* summarydisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarydisplay.h; sourceTree = ""; }; 37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summarysharedcommand.cpp; sourceTree = ""; }; 37D9284B0F21331F001D4494 /* summarysharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarysharedcommand.h; sourceTree = ""; }; - 37D9284C0F21331F001D4494 /* utilities.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utilities.hpp; sourceTree = ""; }; 37D9284D0F21331F001D4494 /* uvest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uvest.cpp; sourceTree = ""; }; 37D9284E0F21331F001D4494 /* uvest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uvest.h; sourceTree = ""; }; 37D9284F0F21331F001D4494 /* validcalculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validcalculator.cpp; sourceTree = ""; }; @@ -449,10 +454,11 @@ 37D9281C0F21331F001D4494 /* sequence.cpp */, 37D928210F21331F001D4494 /* shared.h */, 37D928200F21331F001D4494 /* shared.cpp */, + 37C7F3A70F8E90AD00E91C2B /* sharedutilities.h */, + 37C7F3A80F8E90AD00E91C2B /* sharedutilities.cpp */, 37D928420F21331F001D4494 /* singlelinkage.cpp */, 37D928480F21331F001D4494 /* summarydata.h */, 37D928490F21331F001D4494 /* summarydisplay.h */, - 37D9284C0F21331F001D4494 /* utilities.hpp */, 37519AB30F810FAE00FED5E8 /* venn.h */, 37519AB40F810FAE00FED5E8 /* venn.cpp */, ); @@ -610,6 +616,8 @@ 37D928460F21331F001D4494 /* summarycommand.cpp */, 37D9284B0F21331F001D4494 /* summarysharedcommand.h */, 37D9284A0F21331F001D4494 /* summarysharedcommand.cpp */, + 3731C1F10F8CFC0A0065A2AD /* treegroupscommand.h */, + 3731C1F20F8CFC0A0065A2AD /* treegroupscommand.cpp */, 3746109B0F40657600460C57 /* unifracunweightedcommand.h */, 3746109C0F40657600460C57 /* unifracunweightedcommand.cpp */, 374610760F40645300460C57 /* unifracweightedcommand.h */, @@ -835,6 +843,8 @@ 37519AB50F810FAE00FED5E8 /* venn.cpp in Sources */, 37C1D9730F86506E0059E3F0 /* binsequencecommand.cpp in Sources */, 370B88070F8A4EE4005AB382 /* getoturepcommand.cpp in Sources */, + 3731C1F30F8CFC0A0065A2AD /* treegroupscommand.cpp in Sources */, + 37C7F3A90F8E90AD00E91C2B /* sharedutilities.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/averagelinkage.cpp b/averagelinkage.cpp index ec619ca..54f3803 100644 --- a/averagelinkage.cpp +++ b/averagelinkage.cpp @@ -1,10 +1,11 @@ #ifndef AVERAGE_H #define AVERAGE_H + +#include "mothur.h" #include "cluster.hpp" #include "rabundvector.hpp" #include "sparsematrix.hpp" -#include "mothur.h" /* This class implements the average UPGMA, average neighbor clustering algorithm */ diff --git a/bergerparker.cpp b/bergerparker.cpp index c8c25ea..41e6e9f 100644 --- a/bergerparker.cpp +++ b/bergerparker.cpp @@ -8,7 +8,6 @@ */ #include "bergerparker.h" -#include "calculator.h" /***************************************************************/ diff --git a/binsequencecommand.h b/binsequencecommand.h index 22847dc..25f5216 100644 --- a/binsequencecommand.h +++ b/binsequencecommand.h @@ -9,6 +9,7 @@ * */ +/* The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name. */ #include "command.hpp" #include "inputdata.h" diff --git a/bstick.cpp b/bstick.cpp index 3a0e0e9..0dc67b9 100644 --- a/bstick.cpp +++ b/bstick.cpp @@ -8,7 +8,7 @@ */ #include "bstick.h" -#include "calculator.h" + /***********************************************************************/ double BStick::invSum(int index, double numSpec) diff --git a/calculator.h b/calculator.h index c87d5c7..53e5c5a 100644 --- a/calculator.h +++ b/calculator.h @@ -4,7 +4,6 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" #include "sabundvector.hpp" #include "sharedsabundvector.h" #include "rabundvector.hpp" diff --git a/cluster.cpp b/cluster.cpp index 81360b4..1ccb349 100644 --- a/cluster.cpp +++ b/cluster.cpp @@ -10,6 +10,7 @@ #include "cluster.hpp" #include "rabundvector.hpp" #include "listvector.hpp" +#include "sparsematrix.hpp" /***********************************************************************/ diff --git a/cluster.hpp b/cluster.hpp index 208ccbf..5f01038 100644 --- a/cluster.hpp +++ b/cluster.hpp @@ -4,9 +4,7 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" #include "sparsematrix.hpp" -#include "rabundvector.hpp" class RAbundVector; class ListVector; diff --git a/collect.cpp b/collect.cpp index 7397d24..8043dc1 100644 --- a/collect.cpp +++ b/collect.cpp @@ -9,7 +9,6 @@ #include "collect.h" - /***********************************************************************/ void Collect::getCurve(int increment = 1){ diff --git a/collect.h b/collect.h index aca4ccd..295673e 100644 --- a/collect.h +++ b/collect.h @@ -4,6 +4,7 @@ using namespace std; + #include "collectorscurvedata.h" #include "display.h" #include "ordervector.hpp" diff --git a/collectcommand.h b/collectcommand.h index 9c24339..93b5607 100644 --- a/collectcommand.h +++ b/collectcommand.h @@ -12,7 +12,7 @@ #include "command.hpp" #include "ordervector.hpp" #include "inputdata.h" -//#include "groupmap.h" +#include "groupmap.h" #include "collect.h" #include "display.h" #include "readmatrix.hpp" diff --git a/collectdisplay.h b/collectdisplay.h index fc405df..af97c75 100644 --- a/collectdisplay.h +++ b/collectdisplay.h @@ -6,7 +6,7 @@ #include "calculator.h" #include "fileoutput.h" #include "display.h" -#include + using namespace std; diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index ec35dd6..6c47f2d 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -41,6 +41,7 @@ CollectSharedCommand::CollectSharedCommand(){ fileNameRoot = getRootName(globaldata->inputFileName); format = globaldata->getFormat(); validCalculator = new ValidCalculators(); + util = new SharedUtil(); int i; for (i=0; iEstimators.size(); i++) { @@ -113,6 +114,7 @@ CollectSharedCommand::~CollectSharedCommand(){ delete input; delete cCurve; delete read; + delete util; } //********************************************************************************************************************** @@ -142,7 +144,8 @@ int CollectSharedCommand::execute(){ set orderList; //set users groups - setGroups(); + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "collect"); + util->updateGroupIndex(globaldata->Groups, globaldata->gGroupmap->groupIndex); while(order != NULL){ orderList.insert(order->getLabel()); @@ -193,52 +196,5 @@ int CollectSharedCommand::execute(){ } } - -//********************************************************************************************************************** -void CollectSharedCommand::setGroups() { - try { - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if ((globaldata->Groups.size() == 0) || (globaldata->Groups.size() == 1)) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the CollectSharedCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the CollectSharedCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} /***********************************************************/ diff --git a/collectsharedcommand.h b/collectsharedcommand.h index c5c24b2..8c7aa00 100644 --- a/collectsharedcommand.h +++ b/collectsharedcommand.h @@ -19,6 +19,7 @@ #include "display.h" #include "readmatrix.hpp" #include "validcalculator.h" +#include "sharedutilities.h" /* The collect.shared() command: The collect command generates a collector's curve from the given file representing several groups. @@ -44,6 +45,7 @@ public: private: GlobalData* globaldata; + SharedUtil* util; GroupMap* groupmap; SharedListVector* SharedList; ReadMatrix* read; @@ -54,7 +56,6 @@ private: vector cDisplays; int freq; string format; - void setGroups(); }; diff --git a/commandfactory.cpp b/commandfactory.cpp index 5155095..b4e68e4 100644 --- a/commandfactory.cpp +++ b/commandfactory.cpp @@ -32,10 +32,10 @@ #include "libshuffcommand.h" #include "heatmapcommand.h" #include "venncommand.h" -#include "mothur.h" #include "nocommands.h" #include "binsequencecommand.h" #include "getoturepcommand.h" +#include "treegroupscommand.h" /***********************************************************/ @@ -83,6 +83,7 @@ Command* CommandFactory::getCommand(string commandName){ else if(commandName == "venn") { command = new VennCommand(); } else if(commandName == "bin.seqs") { command = new BinSeqCommand(); } else if(commandName == "get.oturep") { command = new GetOTURepCommand(); } + else if(commandName == "tree.groups") { command = new TreeGroupCommand(); } else { command = new NoCommand(); } return command; diff --git a/commandfactory.hpp b/commandfactory.hpp index 9bbba57..f715b84 100644 --- a/commandfactory.hpp +++ b/commandfactory.hpp @@ -10,6 +10,8 @@ * */ +#include "mothur.h" + class Command; class CommandFactory { diff --git a/commandoptionparser.cpp b/commandoptionparser.cpp index dcfcf43..a46c0a6 100644 --- a/commandoptionparser.cpp +++ b/commandoptionparser.cpp @@ -10,9 +10,10 @@ using namespace std; + #include "globaldata.hpp" #include "commandoptionparser.hpp" -#include "mothur.h" + //********************************************************************************************************************** //This Function parses through the command line and pulls out the command then sends the options to the parseGlobalData diff --git a/commandoptionparser.hpp b/commandoptionparser.hpp index 6a61628..f83f60e 100644 --- a/commandoptionparser.hpp +++ b/commandoptionparser.hpp @@ -1,6 +1,8 @@ #ifndef COMMANDOPTIONPARSER_HPP #define COMMANDOPTIONPARSER_HPP +#include "mothur.h" + //********************************************************************************************************************** class CommandOptionParser { diff --git a/database.cpp b/database.cpp index b661d41..933bed4 100644 --- a/database.cpp +++ b/database.cpp @@ -9,7 +9,7 @@ using namespace std; -#include "mothur.h" + #include "sequence.hpp" #include "database.hpp" diff --git a/database.hpp b/database.hpp index e497fa4..e80bfb5 100644 --- a/database.hpp +++ b/database.hpp @@ -10,6 +10,8 @@ * */ +#include "mothur.h" + class Database { public: Database(string); diff --git a/deconvolutecommand.h b/deconvolutecommand.h index c80bb36..fe5c0db 100644 --- a/deconvolutecommand.h +++ b/deconvolutecommand.h @@ -10,7 +10,6 @@ */ #include "command.hpp" -#include "utilities.hpp" #include "fastamap.h" #include "globaldata.hpp" diff --git a/engine.cpp b/engine.cpp index 5e56479..68a7500 100644 --- a/engine.cpp +++ b/engine.cpp @@ -12,13 +12,6 @@ */ using namespace std; - -#include "utilities.hpp" -#include "globaldata.hpp" -#include "commandoptionparser.hpp" -#include "command.hpp" -#include "commandfactory.hpp" -#include "errorchecking.h" #include "engine.hpp" /***********************************************************************/ diff --git a/engine.hpp b/engine.hpp index c04cd4e..a35b616 100644 --- a/engine.hpp +++ b/engine.hpp @@ -13,6 +13,12 @@ #include "mothur.h" +#include "globaldata.hpp" +#include "commandoptionparser.hpp" +#include "command.hpp" +#include "commandfactory.hpp" +#include "errorchecking.h" + using namespace std; diff --git a/errorchecking.cpp b/errorchecking.cpp index abd2a9f..841cad2 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -111,6 +111,8 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "abund" ) { abund = value; } if (parameter == "random" ) { randomtree = value; } if (parameter == "sorted" ) { sorted = value; } + if (parameter == "scaler" ) { scaler = value; } + } //gets the last parameter and value @@ -144,6 +146,7 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "random" ) { randomtree = value; } if (parameter == "abund" ) { abund = value; } if (parameter == "sorted" ) { sorted = value; } + if (parameter == "scaler" ) { scaler = value; } } } @@ -216,10 +219,10 @@ bool ErrorCheck::checkInput(string input) { if ((globaldata->getListFile() == "") && (globaldata->getRabundFile() == "") && (globaldata->getSabundFile() == "")) { cout << "You must read a list, sabund or rabund before you can use the collect.single, rarefaction.single or summary.single commands." << endl; return false; } } - if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") ){ + if ((commandName == "collect.shared") || (commandName == "rarefaction.shared") || (commandName == "summary.shared") || (commandName == "tree.groups") ){ if (globaldata->getSharedFile() == "") { - if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; } - else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared or summary.shared commands." << endl; return false; } + if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared or tree.groups commands." << endl; return false; } + else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the collect.shared, rarefaction.shared, summary.shared or tree.groups commands." << endl; return false; } } } diff --git a/errorchecking.h b/errorchecking.h index 0d6da74..3ddc65c 100644 --- a/errorchecking.h +++ b/errorchecking.h @@ -13,7 +13,7 @@ #include "globaldata.hpp" #include "validcommands.h" #include "validparameter.h" -#include "utilities.hpp" + class ErrorCheck { public: @@ -34,7 +34,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, sorted; + string precision, method, fileroot, label, line, iters, jumble, freq, single, rarefaction, shared, summary, randomtree, abund, sorted, scaler; string commandName, optionText; bool errorFree; diff --git a/fastamap.h b/fastamap.h index 6dd4cba..355a8df 100644 --- a/fastamap.h +++ b/fastamap.h @@ -13,7 +13,6 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" /* This class represents the fasta file. It reads a fasta file a populates the internal data structure "data". diff --git a/fileoutput.cpp b/fileoutput.cpp index 2f7639f..e6f069d 100644 --- a/fileoutput.cpp +++ b/fileoutput.cpp @@ -85,8 +85,13 @@ void ThreeColumnFile::resetFile(){ outFile.close(); } counter = 1; + remove(inName.c_str()); - rename(outName.c_str(), inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; } + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -101,6 +106,112 @@ void ThreeColumnFile::resetFile(){ /***********************************************************************/ /***********************************************************************/ +ThreeColumnFile2::~ThreeColumnFile2(){ + + inFile.close(); + outFile.close(); + remove(outName.c_str()); +}; + +/***********************************************************************/ + +void ThreeColumnFile2::initFile(string label, vector tags){ + try { + if(counter != 0){ + openOutputFile(outName, outFile); + openInputFile(inName, inFile); + + string inputBuffer; + getline(inFile, inputBuffer); + + outFile << inputBuffer << '\t'; + for(int i = 1; i < tags.size(); i++) { + outFile << label + tags[i] << '\t'; + } + outFile << endl; + } + else{ + openOutputFile(outName, outFile); + for(int i = 0; i < tags.size(); i++) { + outFile << label + tags[i] << '\t'; + } + outFile << endl; + + } + + outFile.setf(ios::fixed, ios::floatfield); + outFile.setf(ios::showpoint); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile class Function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ThreeColumnFile class function initFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/***********************************************************************/ + +void ThreeColumnFile2::output(vector data){ + try { + + if(counter != 0){ + string inputBuffer; + getline(inFile, inputBuffer); + + outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl; + } + else{ + outFile << setprecision(6) << data[0] << setprecision(globaldata->getIters().length()) << '\t' << data[1] << '\t' << data[2] << endl; + + } + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile2 class Function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ThreeColumnFile2 class function output. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +}; + +/***********************************************************************/ + +void ThreeColumnFile2::resetFile(){ + try { + if(counter != 0){ + outFile.close(); + inFile.close(); + } + else{ + outFile.close(); + } + counter = 1; + + remove(inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; } + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ThreeColumnFile2 class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ThreeColumnFile2 class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/***********************************************************************/ +/***********************************************************************/ + SharedThreeColumnFile::~SharedThreeColumnFile(){ inFile.close(); @@ -177,7 +288,11 @@ void SharedThreeColumnFile::resetFile(){ } counter = 1; remove(inName.c_str()); - rename(outName.c_str(), inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; } + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the SharedThreeColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -268,7 +383,11 @@ void OneColumnFile::resetFile(){ } counter = 1; remove(inName.c_str()); - rename(outName.c_str(), inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; } + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -366,8 +485,14 @@ void SharedOneColumnFile::resetFile(){ outFile.close(); } counter = 1; + remove(inName.c_str()); - rename(outName.c_str(), inName.c_str()); + renameOk = rename(outName.c_str(), inName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if ((renameOk != 0)) { cout << "Unable to rename necessary files." << endl; } + + } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the OneColumnFile class Function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; diff --git a/fileoutput.h b/fileoutput.h index b578421..7e9d8d2 100644 --- a/fileoutput.h +++ b/fileoutput.h @@ -2,7 +2,6 @@ #define FILEOUTPUT_H #include "mothur.h" -#include "utilities.hpp" #include "globaldata.hpp" using namespace std; @@ -18,6 +17,12 @@ public: virtual void initFile(string) = 0; virtual void resetFile() = 0; virtual string getFileName() = 0; + virtual void initFile(string, vector) = 0; + virtual void output(vector) = 0; + +protected: + GlobalData* globaldata; + int renameOk; }; @@ -32,6 +37,10 @@ public: void output(int, vector); void resetFile(); string getFileName() { return inName; }; + + void initFile(string, vector) {}; + void output(vector) {}; + private: string inName; string outName; @@ -52,6 +61,10 @@ public: void initFile(string); void resetFile(); string getFileName() { return inName; }; + + void initFile(string, vector) {}; + void output(vector) {}; + private: string outName; @@ -72,6 +85,10 @@ public: void initFile(string); void resetFile(); string getFileName() { return inName; }; + + void initFile(string, vector) {}; + void output(vector) {}; + private: string outName; @@ -93,6 +110,11 @@ public: void output(int, vector); void resetFile(); string getFileName() { return inName; }; + + + void initFile(string, vector) {}; + void output(vector) {}; + private: string inName, groupLabel; string outName; @@ -101,6 +123,30 @@ private: int counter, numGroup; }; +/***********************************************************************/ + +class ThreeColumnFile2 : public FileOutput { + +public: + ThreeColumnFile2(string n) : FileOutput(), inName(n), counter(0), outName(getPathName(n) + ".temp." + getSimpleName(n)) { globaldata = GlobalData::getInstance(); }; + ~ThreeColumnFile2(); + + //to make compatible with parent class + void output(int, vector){}; + void initFile(string){}; + + void initFile(string, vector); + void output(vector); + void resetFile(); + string getFileName() { return inName; }; +private: + string inName; + string outName; + ifstream inFile; + ofstream outFile; + int counter; +}; +/***********************************************************************/ #endif diff --git a/geom.cpp b/geom.cpp index 8b484de..1a7c2bf 100644 --- a/geom.cpp +++ b/geom.cpp @@ -8,7 +8,6 @@ */ #include "geom.h" -#include "calculator.h" /***********************************************************************/ diff --git a/getoturepcommand.h b/getoturepcommand.h index d0343da..4e2b3a0 100644 --- a/getoturepcommand.h +++ b/getoturepcommand.h @@ -8,6 +8,8 @@ * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. * */ + + /* The get.oturep command outputs a .fastarep file for each distance you specify, selecting one OTU representative for each bin. */ #include "command.hpp" #include "globaldata.hpp" diff --git a/globaldata.cpp b/globaldata.cpp index 67c49bd..2c02ca9 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -1,9 +1,6 @@ #include "globaldata.hpp" -#include "sparsematrix.hpp" #include "tree.h" -#include "rabundvector.hpp" -#include "sabundvector.hpp" -#include "listvector.hpp" +#include "sparsematrix.hpp" /*******************************************************/ @@ -76,6 +73,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "step") { step = value; } if (key == "form") { form = value; } if (key == "sorted") { sorted = value; } + if (key == "scaler") { scaler = value; } @@ -131,6 +129,8 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (key == "step") { step = value; } if (key == "form") { form = value; } if (key == "sorted") { sorted = value; } + if (key == "scaler") { scaler = value; } + if (key == "line") {//stores lines to be used in a vector lines.clear(); @@ -140,6 +140,7 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ if (line != "all") { splitAtDash(value, lines); allLines = 0; } else { allLines = 1; } } + if (key == "label") {//stores lines to be used in a vector labels.clear(); lines.clear(); @@ -199,6 +200,13 @@ void GlobalData::parseGlobalData(string commandString, string optionText){ Estimators.clear(); splitAtDash(calc, Estimators); } + if (commandName == "tree.groups") { + if (calc != "") { + Estimators.clear(); + splitAtDash(calc, Estimators); + }else { cout << "You have not specified any calculators." << endl; } + } + //if you have done a read.otu with a groupfile but don't want to use it anymore because you want to do single commands if ((commandName == "collect.single") || (commandName == "rarefaction.single") || (commandName == "summary.single")) { @@ -245,6 +253,7 @@ string GlobalData::getGroups() { return groups; } string GlobalData::getStep() { return step; } string GlobalData::getForm() { return form; } string GlobalData::getSorted() { return sorted; } +string GlobalData::getScaler() { return scaler; } 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;} @@ -296,6 +305,7 @@ void GlobalData::clear() { step = "0.01"; form = "integral"; sorted = "1"; //0 means don't sort, 1 means sort. + scaler = "log2"; } //*******************************************************/ diff --git a/globaldata.hpp b/globaldata.hpp index 0abdd28..3b688b4 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -5,6 +5,11 @@ #include "groupmap.h" #include "treemap.h" +#include "rabundvector.hpp" +#include "sabundvector.hpp" +#include "listvector.hpp" + + using namespace std; class ListVector; @@ -17,6 +22,7 @@ class InputData; class GroupMap; class TreeMap; class SAbundVector; +class RAbundVector; class GlobalData { public: @@ -64,6 +70,7 @@ public: string getStep(); string getForm(); string getSorted(); + string getScaler(); void setListFile(string); void setPhylipFile(string); @@ -90,7 +97,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, sorted; + string cutoff, format, precision, method, fileroot, iters, jumble, freq, calc, abund, step, form, sorted, scaler; static GlobalData* _uniqueInstance; GlobalData( const GlobalData& ); // Disable copy constructor diff --git a/groupmap.h b/groupmap.h index 20048a5..d69699d 100644 --- a/groupmap.h +++ b/groupmap.h @@ -10,7 +10,6 @@ */ #include "mothur.h" -#include "utilities.hpp" /* This class is a representation of the groupfile. It is used by all the shared commands to determine what group a certain sequence belongs to. */ diff --git a/heatmap.cpp b/heatmap.cpp index 4ce6f2c..75a2b87 100644 --- a/heatmap.cpp +++ b/heatmap.cpp @@ -15,6 +15,7 @@ HeatMap::HeatMap(){ globaldata = GlobalData::getInstance(); format = globaldata->getFormat(); sorted = globaldata->getSorted(); + util = new SharedUtil(); } catch(exception& e) { @@ -45,7 +46,7 @@ void HeatMap::getPic(OrderVector* order) { if(it->second.length() == 1) { it->second = "0" + it->second; } } - string filenamesvg = globaldata->inputFileName + ".heatmap." + order->getLabel() + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + order->getLabel() + ".heatmap.svg"; openOutputFile(filenamesvg, outsvg); @@ -86,50 +87,104 @@ void HeatMap::getPic(SharedOrderVector* sharedorder) { colorScale.clear(); //fills vector of sharedsabunds - lookup - getSharedVectors(sharedorder); + util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector. //sort lookup so shared bins are on top if (sorted == "1") { sortSharedVectors(); } - //get maxBin + //get users scaling method + scaler = globaldata->getScaler(); + + int maxbin = 0; for (int i = 0; i < lookup.size(); i++) { for (int j = 0; j < lookup[i]->size(); j++) { - colorScale[lookup[i]->getAbundance(j)] = ""; + //if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0. + //if (scaler == "log10") { + // colorScale[-log((log10(lookup[i]->getAbundance(j)) / (float)lookup[i]->getNumSeqs()))] = ""; + //cout << "abundance = " << lookup[i]->getAbundance(j) << '\t' << " relative adundance = " << (lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs()) << '\t'; + //cout << -log((log10(lookup[i]->getAbundance(j)) / lookup[i]->getNumSeqs())) << endl; + //}else if (scaler == "log2") { + //colorScale[-log((log2(lookup[i]->getAbundance(j)) / (float)lookup[i]->getNumSeqs()))] = ""; //cout << (int)log2(lookup[i]->getAbundance(j)) << endl; + //cout << "abundance = " << lookup[i]->getAbundance(j) << '\t' << " relative adundance = " << lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs() << '\t'; + //cout << -log((log2(lookup[i]->getAbundance(j)) / lookup[i]->getNumSeqs())) << endl; + // }else if (scaler == "linear") { + colorScale[lookup[i]->getAbundance(j)] = ""; + if (maxbin < lookup[i]->getAbundance(j)) { maxbin = lookup[i]->getAbundance(j); } + //cout << "abundance = " << lookup[i]->getAbundance(j) << '\t' << " relative adundance = " << lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs() << '\t'; + //cout << lookup[i]->getAbundance(j) /(float) lookup[i]->getNumSeqs() << endl; + //}else { //if user enters invalid scaler option. + // cout << scaler << " is not a valid scaler option. I will use log10." << endl; + // colorScale[-log(log10(lookup[i]->getAbundance(j) / lookup[i]->getNumSeqs()))] = ""; + //} + //}else { colorScale[0] = "00"; } + } } //get scaler - float scaler = 255 / (float) colorScale.size(); + float scalers = 255 / (float) maxbin; //go through map and give each score a color value for (it = colorScale.begin(); it != colorScale.end(); it++) { - it->second = toHex(int(float(it->first) * scaler)); + it->second = toHex(int(float(it->first) * scalers)); if(it->second.length() == 1) { it->second = "0" + it->second; } +//cout << it->first << " " << it->second << endl; } - string filenamesvg = globaldata->inputFileName + ".heatmap." + sharedorder->getLabel() + "." + groupComb + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".heatmap.svg"; openOutputFile(filenamesvg, outsvg); //svg image - outsvg << "getNumBins()*5 + 15)) + "\">\n"; + outsvg << "getNumBins()*5 + 120)) + "\">\n"; outsvg << "\n"; - int x = 15; - int y = 15; + //white backround + outsvg << "getNumBins()*5 + 120)) + "\"/>"; + outsvg << "Heatmap at distance " + sharedorder->getLabel() + "\n"; + + //column labels + for (int h = 0; h < lookup.size(); h++) { + outsvg << "getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "\n"; + } + + + //output legend and color labels + //go through map and give each score a color value string color; - - for (int i = 0; i <= lookup[0]->getNumBins(); i++) { + int x = 0; + int y = 90 + (lookup[0]->getNumBins()*5); + for (it = colorScale.begin(); it != colorScale.end(); it++) { + color = it->second; + outsvg << "\n"; + outsvg << "" + toString(it->first) + "\n"; + x += 25; + } + + x = 0; + y = 70; + //start at 1 since bin 0 is nothing + for (int i = 1; i <= lookup[0]->getNumBins(); i++) { for (int j = 0; j < lookup.size(); j++) { - - color = colorScale[lookup[j]->getAbundance(i)]; - + + //if (lookup[j]->getAbundance(i) != 0) { //don't want log value of 0. + //if (scaler == "log10") { + // color = colorScale[(int)log10(lookup[j]->getAbundance(i))]; + //}else if (scaler == "log2") { + // color = colorScale[(int)log2(lookup[j]->getAbundance(i))]; + // }else if (scaler == "linear") { + color = colorScale[lookup[j]->getAbundance(i)]; + //}else { color = colorScale[(int)log10(lookup[j]->getAbundance(i))]; } + //}else { color = "OO"; } + + outsvg << "\n"; x += 300; } - x = 15; + x = 0; y += 5; } + outsvg << "\n\n"; outsvg.close(); @@ -146,57 +201,6 @@ void HeatMap::getPic(SharedOrderVector* sharedorder) { exit(1); } } -//********************************************************************************************************************** -void HeatMap::getSharedVectors(SharedOrderVector* order){ - try { - - //delete lookup - for (int j = 0; j < lookup.size(); j++) { - delete lookup[j]; - } - - lookup.clear(); - - groupComb = ""; - - //create and initialize vector of sharedvectors, one for each group - for (int i = 0; i < globaldata->Groups.size(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins()); - temp->setLabel(order->getLabel()); - temp->setGroup(globaldata->Groups[i]); - groupComb += globaldata->Groups[i]; - lookup.push_back(temp); - } - - int numSeqs = order->size(); - //sample all the members - for(int i=0;iget(i); - int abundance; - - //set info for sharedvector in chosens group - for (int j = 0; j < lookup.size(); j++) { - if (chosen.group == lookup[j]->getGroup()) { - abundance = lookup[j]->getAbundance(chosen.bin); - lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); - break; - } - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the HeatMap class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the HeatMap class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} - //********************************************************************************************************************** void HeatMap::sortSharedVectors(){ @@ -206,8 +210,10 @@ void HeatMap::sortSharedVectors(){ //if they are then insert in the front //if not push to back - bool shared; vector looktemp; + map place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2. + map::iterator it; + int count; //create and initialize looktemp as a copy of lookup for (int i = 0; i < lookup.size(); i++) { @@ -227,22 +233,37 @@ void HeatMap::sortSharedVectors(){ //create and initialize lookup to empty vectors for (int i = 0; i < looktemp.size(); i++) { SharedRAbundVector* temp = new SharedRAbundVector(); - lookup.push_back(temp); + temp->setLabel(looktemp[i]->getLabel()); + temp->setGroup(looktemp[i]->getGroup()); + lookup.push_back(temp); + + //initialize place map + place[i] = 0; } + //for each bin for (int i = 0; i < looktemp[0]->size(); i++) { - shared = true; + count = 0; + bool updatePlace = false; //for each group for (int j = 0; j < looktemp.size(); j++) { - if (looktemp[j]->getAbundance(i) == 0) { shared = false; } + if (looktemp[j]->getAbundance(i) != 0) { count++; } } //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 (shared == false) { lookup[j]->push_back(looktemp[j]->getAbundance(i), i, looktemp[j]->getGroup()); } - else { lookup[j]->push_front(looktemp[j]->getAbundance(i), i, looktemp[j]->getGroup()); } + if (count < 2) { lookup[j]->push_back(looktemp[j]->getAbundance(i), i, looktemp[j]->getGroup()); } + //they are shared by some + else { lookup[j]->insert(looktemp[j]->getAbundance(i), place[count], looktemp[j]->getGroup()); updatePlace = true; } + } + + if (updatePlace == true) { + //move place holders below where you entered up to "make space" for you entry + for (it = place.begin(); it!= place.end(); it++) { + if (it->first < count) { it->second++; } + } } } diff --git a/heatmap.h b/heatmap.h index e236ce3..a89500c 100644 --- a/heatmap.h +++ b/heatmap.h @@ -17,6 +17,7 @@ using namespace std; #include "sharedordervector.h" #include "datavector.hpp" #include "globaldata.hpp" +#include "sharedutilities.h" /***********************************************************************/ @@ -24,22 +25,22 @@ class HeatMap { public: HeatMap(); - ~HeatMap(){}; + ~HeatMap(){ delete util; }; void getPic(OrderVector*); void getPic(SharedOrderVector*); private: - void getSharedVectors(SharedOrderVector*); void sortSharedVectors(); GlobalData* globaldata; + SharedUtil* util; vector lookup; RAbundVector rabund; - string format, sorted, groupComb; + string format, sorted, groupComb, scaler; ofstream outsvg; - map colorScale; - map::iterator it; + map colorScale; + map::iterator it; }; diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index 10264c8..82aa12c 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -17,6 +17,7 @@ HeatMapCommand::HeatMapCommand(){ globaldata = GlobalData::getInstance(); heatmap = new HeatMap(); format = globaldata->getFormat(); + util = new SharedUtil(); } catch(exception& e) { @@ -34,6 +35,7 @@ HeatMapCommand::~HeatMapCommand(){ delete input; delete read; delete heatmap; + delete util; } //********************************************************************************************************************** @@ -65,12 +67,14 @@ int HeatMapCommand::execute(){ ordersingle = globaldata->gorder; input = globaldata->ginput; } - + if (format != "list") { - - setGroups(); - + + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "heat"); + globaldata->setGroups(""); + + while(order != NULL){ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){ @@ -96,7 +100,7 @@ int HeatMapCommand::execute(){ } //reset groups parameter - globaldata->Groups.clear(); globaldata->setGroups(""); + globaldata->Groups.clear(); }else{ while(ordersingle != NULL){ @@ -126,50 +130,5 @@ int HeatMapCommand::execute(){ } //********************************************************************************************************************** -void HeatMapCommand::setGroups() { - try { - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if (globaldata->Groups.size() == 0) { - cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the HeatMapCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the HeatMapCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -} -/***********************************************************/ diff --git a/heatmapcommand.h b/heatmapcommand.h index 5eeae26..f75c064 100644 --- a/heatmapcommand.h +++ b/heatmapcommand.h @@ -16,6 +16,7 @@ #include "readmatrix.hpp" #include "sharedlistvector.h" #include "heatmap.h" +#include "sharedutilities.h" class GlobalData; @@ -31,14 +32,13 @@ public: private: GlobalData* globaldata; ReadMatrix* read; + SharedUtil* util; InputData* input; SharedListVector* SharedList; SharedOrderVector* order; OrderVector* ordersingle; HeatMap* heatmap; string format; - - void setGroups(); }; diff --git a/helpcommand.cpp b/helpcommand.cpp index 05aaff0..7ac616f 100644 --- a/helpcommand.cpp +++ b/helpcommand.cpp @@ -194,14 +194,16 @@ int HelpCommand::execute(){ 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, line and label. No parameters are required, but you may not use line and label at the same time." << "\n"; + cout << "The heatmap command parameters are groups, sorted, scaler, 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 exact representation of your input file. " << "\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 scaler 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=0)." << "\n"; + cout << "Example heatmap(groups=A-B-C, line=1-3-5, sorted=0, scaler=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 1 meaning you want the shared otus on top, you may change it to 0 meaning the exact representation of your input file." << "\n"; + cout << "The default value for scaler is log2; your other options are log10 and linear." << "\n"; cout << "The heatmap 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") { @@ -213,6 +215,8 @@ int HelpCommand::execute(){ cout << "Example venn(groups=A-B-C, line=1-3-5, calc=sharedsobs-sharedchao)." << "\n"; cout << "The default value for groups is all the groups in your groupfile up to 4, and all lines in your inputfile will be used." << "\n"; cout << "The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups." << "\n"; + cout << "The default available estimators for calc are sobs, chao and ace if you have only read a list file, and sharedsobs, sharedchao and sharedace if you have read a list and group file or a shared file." << "\n"; + cout << "The only estmiator available four 4 groups is sharedsobs." << "\n"; cout << "The venn command outputs a .svg file for each calculator you specify at each distance you choose." << "\n"; cout << "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups)." << "\n" << "\n"; }else if (globaldata->helpRequest == "bin.seqs") { diff --git a/inputdata.cpp b/inputdata.cpp index 592367a..c8259d9 100644 --- a/inputdata.cpp +++ b/inputdata.cpp @@ -10,7 +10,6 @@ #include "inputdata.h" #include "ordervector.hpp" #include "listvector.hpp" -#include "utilities.hpp" /***********************************************************************/ diff --git a/kmer.cpp b/kmer.cpp index 5f962a6..875cec5 100644 --- a/kmer.cpp +++ b/kmer.cpp @@ -9,7 +9,7 @@ using namespace std; -#include "mothur.h" + #include "kmer.hpp" /**************************************************************************************************/ diff --git a/kmer.hpp b/kmer.hpp index 75ec538..21a18e3 100644 --- a/kmer.hpp +++ b/kmer.hpp @@ -10,6 +10,8 @@ * */ +#include "mothur.h" + /**************************************************************************************************/ class Kmer { diff --git a/kmerdb.cpp b/kmerdb.cpp index a5094f0..ee8168a 100644 --- a/kmerdb.cpp +++ b/kmerdb.cpp @@ -9,7 +9,7 @@ using namespace std; -#include "mothur.h" + #include "sequence.hpp" #include "kmer.hpp" #include "database.hpp" diff --git a/kmerdb.hpp b/kmerdb.hpp index 0088efd..af52789 100644 --- a/kmerdb.hpp +++ b/kmerdb.hpp @@ -10,6 +10,8 @@ * */ +#include "mothur.h" + class KmerDB : public Database { public: diff --git a/listvector.cpp b/listvector.cpp index 9005dc0..205fe60 100644 --- a/listvector.cpp +++ b/listvector.cpp @@ -13,7 +13,6 @@ using namespace std; #include "sabundvector.hpp" #include "rabundvector.hpp" #include "ordervector.hpp" -#include "utilities.hpp" #include "listvector.hpp" diff --git a/logsd.cpp b/logsd.cpp index 94fa459..7b63e5b 100644 --- a/logsd.cpp +++ b/logsd.cpp @@ -8,7 +8,6 @@ */ #include "logsd.h" -#include "calculator.h" /***********************************************************************/ diff --git a/mothur.cpp b/mothur.cpp index 8c55240..c60644d 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -13,6 +13,8 @@ using namespace std; +/**************************************************************************************************/ + GlobalData* GlobalData::_uniqueInstance = 0; int main(int argc, char *argv[]){ @@ -46,3 +48,5 @@ int main(int argc, char *argv[]){ } } +/**************************************************************************************************/ + diff --git a/mothur.h b/mothur.h index e5c3890..36d7b28 100644 --- a/mothur.h +++ b/mothur.h @@ -13,7 +13,7 @@ using namespace std; * */ -/* This file contains all the standard incudes we use in the project. */ +/* This file contains all the standard incudes we use in the project as well as some common utilities. */ //io libraries @@ -40,5 +40,392 @@ using namespace std; #include #include +typedef unsigned long long ull; + + +/***********************************************************************/ + +// snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2 +// works for now, but there should be a way to do it without killing the whole program + +class BadConversion : public runtime_error { +public: + BadConversion(const string& s) : runtime_error(s){ } +}; + +//********************************************************************************************************************** + +template +inline void convert(const string& s, T& x, bool failIfLeftoverChars = true){ + istringstream i(s); + char c; + if (!(i >> x) || (failIfLeftoverChars && i.get(c))) + throw BadConversion(s); +} +//********************************************************************************************************************** + +template +inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){ + istringstream i(s); + char c; + if (!(i >> x) || (failIfLeftoverChars && i.get(c))) + { + cout << "'" << s << "' is unable to be converted into an integer.\n"; + return false; + } + return true; +} + +//********************************************************************************************************************** + +template +string toString(const T&x){ + stringstream output; + output << x; + return output.str(); +} + +//********************************************************************************************************************** + +template +string toHex(const T&x){ + stringstream output; + + output << hex << x; + + return output.str(); +} + +//********************************************************************************************************************** + +template +string toString(const T&x, int i){ + stringstream output; + + output.precision(i); + output << fixed << x; + + return output.str(); +} + + +/***********************************************************************/ + +inline void gobble(istream& f){ + + char d; + while(isspace(d=f.get())) {;} + f.putback(d); + +} + +/***********************************************************************/ + +inline float roundDist(float dist, int precision){ + + return int(dist * precision + 0.5)/float(precision); + +} + +/***********************************************************************/ + +inline int getNumNames(string names){ + + int count = 0; + + if(names != ""){ + count = 1; + for(int i=0;i > binomial(int maxOrder){ + + vector > binomial(maxOrder+1); + + for(int i=0;i<=maxOrder;i++){ + binomial[i].resize(maxOrder+1); + binomial[i][0]=1; + binomial[0][i]=0; + } + binomial[0][0]=1; + + binomial[1][0]=1; + binomial[1][1]=1; + + for(int i=2;i<=maxOrder;i++){ + binomial[1][i]=0; + } + + for(int i=2;i<=maxOrder;i++){ + for(int j=1;j<=maxOrder;j++){ + if(i==j){ binomial[i][j]=1; } + if(j>i) { binomial[i][j]=0; } + else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; } + } + } + + return binomial; +} + +/***********************************************************************/ + +inline string getRootName(string longName){ + + string rootName = longName; + + if(longName.find_last_of(".") != longName.npos){ + int pos = longName.find_last_of('.')+1; + rootName = longName.substr(0, pos); + } + + return rootName; +} +/***********************************************************************/ + +inline string getSimpleName(string longName){ + + string simpleName = longName; + + if(longName.find_last_of("/") != longName.npos){ + int pos = longName.find_last_of('/')+1; + simpleName = longName.substr(pos, longName.length()); + } + + return simpleName; +} + +/***********************************************************************/ + +inline string getPathName(string longName){ + + string rootPathName = longName; + + if(longName.find_last_of("/") != longName.npos){ + int pos = longName.find_last_of('/')+1; + rootPathName = longName.substr(0, pos); + } + + return rootPathName; +} + +/***********************************************************************/ + +inline int openInputFile(string fileName, ifstream& fileHandle){ + + fileHandle.open(fileName.c_str()); + if(!fileHandle) { + cerr << "Error: Could not open " << fileName << endl; + return 1; + } + else { + return 0; + } + +} + +/***********************************************************************/ + +inline int openOutputFile(string fileName, ofstream& fileHandle){ + + fileHandle.open(fileName.c_str(), ios::trunc); + if(!fileHandle) { + cerr << "Error: Could not open " << fileName << endl; + return 1; + } + else { + return 0; + } + +} + +/***********************************************************************/ + +//This function parses the estimator options and puts them in a vector +inline void splitAtDash(string& estim, vector& container) { + try { + string individual; + + while (estim.find_first_of('-') != -1) { + individual = estim.substr(0,estim.find_first_of('-')); + if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string + estim = estim.substr(estim.find_first_of('-')+1, estim.length()); + container.push_back(individual); + } + } + //get last one + container.push_back(estim); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +/***********************************************************************/ +//This function parses the label options and puts them in a set +inline void splitAtDash(string& estim, set& container) { + try { + string individual; + + while (estim.find_first_of('-') != -1) { + individual = estim.substr(0,estim.find_first_of('-')); + if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string + estim = estim.substr(estim.find_first_of('-')+1, estim.length()); + container.insert(individual); + } + } + //get last one + container.insert(estim); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} +/***********************************************************************/ +//This function parses the line options and puts them in a set +inline void splitAtDash(string& estim, set& container) { + try { + string individual; + int lineNum; + + while (estim.find_first_of('-') != -1) { + individual = estim.substr(0,estim.find_first_of('-')); + if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string + estim = estim.substr(estim.find_first_of('-')+1, estim.length()); + convert(individual, lineNum); //convert the string to int + container.insert(lineNum); + } + } + //get last one + convert(estim, lineNum); //convert the string to int + container.insert(lineNum); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} +/***********************************************************************/ +//This function parses the a string and puts peices in a vector +inline void splitAtComma(string& estim, vector& container) { + try { + string individual; + + while (estim.find_first_of(',') != -1) { + individual = estim.substr(0,estim.find_first_of(',')); + if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string + estim = estim.substr(estim.find_first_of(',')+1, estim.length()); + container.push_back(individual); + } + } + //get last one + container.push_back(estim); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/***********************************************************************/ + +//This function splits up the various option parameters +inline void splitAtComma(string& prefix, string& suffix){ + try { + prefix = suffix.substr(0,suffix.find_first_of(',')); + if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string + suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length()); + string space = " "; + while(suffix.at(0) == ' ') + suffix = suffix.substr(1, suffix.length()); + } + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} +/***********************************************************************/ + +//This function separates the key value from the option value i.e. dist=96_... +inline void splitAtEquals(string& key, string& value){ + try { + if(value.find_first_of('=') != -1){ + key = value.substr(0,value.find_first_of('=')); + if ((value.find_first_of('=')+1) <= value.length()) { + value = value.substr(value.find_first_of('=')+1, value.length()); + } + }else{ + key = value; + value = 1; + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} +/**************************************************************************************************/ + +inline bool inUsersGroups(string groupname, vector Groups) { + try { + for (int i = 0; i < Groups.size(); i++) { + if (groupname == Groups[i]) { return true; } + } + return false; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the mothur class Function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the mothur class function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/**************************************************************************************************/ + + #endif diff --git a/nameassignment.hpp b/nameassignment.hpp index 3d21e32..77b772b 100644 --- a/nameassignment.hpp +++ b/nameassignment.hpp @@ -4,7 +4,6 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" #include "listvector.hpp" class NameAssignment : public map { diff --git a/ordervector.cpp b/ordervector.cpp index 333c280..ccbfa66 100644 --- a/ordervector.cpp +++ b/ordervector.cpp @@ -10,7 +10,6 @@ using namespace std; #include "ordervector.hpp" -#include "utilities.hpp" /***********************************************************************/ diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp index 86f8d01..4fa4ec5 100644 --- a/parsimonycommand.cpp +++ b/parsimonycommand.cpp @@ -33,7 +33,17 @@ ParsimonyCommand::ParsimonyCommand() { } //set users groups to analyze - setGroups(); + util = new SharedUtil(); + util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze + util->getCombos(groupComb, globaldata->Groups, numComp); + globaldata->setGroups(""); + + //ABC + if (numComp != 1) { + groupComb.push_back(allGroups); + numComp++; + } + convert(globaldata->getIters(), iters); //how many random trees to generate pars = new Parsimony(tmap); counter = 0; @@ -194,7 +204,7 @@ int ParsimonyCommand::execute() { //reset randomTree parameter to "" globaldata->setRandomTree(""); //reset groups parameter - globaldata->Groups.clear(); globaldata->setGroups(""); + globaldata->Groups.clear(); return 0; @@ -330,90 +340,6 @@ void ParsimonyCommand::getUserInput() { exit(1); } } -/***********************************************************/ - -void ParsimonyCommand::setGroups() { - try { - string allGroups = ""; - numGroups = 0; - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (tmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if (globaldata->Groups.size() == 0) { - cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - allGroups += tmap->namesOfGroups[i] + "-"; - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - }else { - for (int i = 0; i < globaldata->Groups.size(); i++) { - allGroups += globaldata->Groups[i] + "-"; - numGroups++; - } - allGroups = allGroups.substr(0, allGroups.length()-1); - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - allGroups += tmap->namesOfGroups[i] + "-"; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - allGroups += tmap->namesOfGroups[i] + "-"; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - numGroups = 1; - } - - //calculate number of comparsions - numComp = 0; - for (int r=0; rGroups[r]+ "-" +globaldata->Groups[l]); - numComp++; - } - } - - //ABC - if (numComp != 1) { - groupComb.push_back(allGroups); - numComp++; - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the ParsimonyCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the ParsimonyCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} /*****************************************************************/ void ParsimonyCommand::initFile(string label){ diff --git a/parsimonycommand.h b/parsimonycommand.h index e093ceb..dd4e237 100644 --- a/parsimonycommand.h +++ b/parsimonycommand.h @@ -13,6 +13,7 @@ #include "parsimony.h" #include "treemap.h" #include "progress.hpp" +#include "sharedutilities.h" using namespace std; @@ -22,11 +23,12 @@ class ParsimonyCommand : public Command { public: ParsimonyCommand(); - ~ParsimonyCommand() { delete pars; } + ~ParsimonyCommand() { delete pars; delete util; } int execute(); private: GlobalData* globaldata; + SharedUtil* util; vector T; //user trees Tree* randT; //random tree Tree* copyUserTree; @@ -34,7 +36,7 @@ class ParsimonyCommand : public Command { TreeMap* savetmap; Parsimony* pars; vector groupComb; // AB. AC, BC... - string parsFile, parsFileout, sumFile, randomtree; + string parsFile, parsFileout, sumFile, randomtree, allGroups; int iters, numGroups, numComp, counter; vector numEachGroup; //vector containing the number of sequences in each group the users wants for random distrib. vector< vector > userTreeScores; //scores for users trees for each comb. @@ -55,7 +57,6 @@ class ParsimonyCommand : public Command { void printParsimonyFile(); void printUSummaryFile(); void getUserInput(); - void setGroups(); void initFile(string); void output(vector); void resetFile(); diff --git a/qstat.cpp b/qstat.cpp index 591c36a..cac06be 100644 --- a/qstat.cpp +++ b/qstat.cpp @@ -8,7 +8,7 @@ */ #include "qstat.h" -#include "calculator.h" + /***********************************************************************/ diff --git a/rabundvector.cpp b/rabundvector.cpp index 6b0a048..1613f0a 100644 --- a/rabundvector.cpp +++ b/rabundvector.cpp @@ -8,8 +8,6 @@ */ using namespace std; - -#include "utilities.hpp" #include "rabundvector.hpp" #include "sabundvector.hpp" #include "ordervector.hpp" diff --git a/rabundvector.hpp b/rabundvector.hpp index 2a866bc..62520e6 100644 --- a/rabundvector.hpp +++ b/rabundvector.hpp @@ -12,6 +12,9 @@ sabundvector = 2 1 1 0 0 1 ordervector = 1 1 1 1 1 1 2 2 2 3 3 4 5 */ +//class SAbundVector; +//class OrderVector; + class RAbundVector : public DataVector { public: diff --git a/raredisplay.cpp b/raredisplay.cpp index 0b80307..983ed10 100644 --- a/raredisplay.cpp +++ b/raredisplay.cpp @@ -115,7 +115,10 @@ void RareDisplay::reset(){ nIters++; remove(tempInName.c_str()); - rename(tempOutName.c_str(), tempInName.c_str()); + renameOk = rename(tempOutName.c_str(), tempInName.c_str()); + + //checks to make sure user was able to rename and remove successfully + if (renameOk != 0) { cout << "Unable to rename the necessary temp files." << endl; } } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the RareDisplay class Function reset. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -157,7 +160,7 @@ void RareDisplay::close(){ remove(tempInName.c_str()); remove(tempOutName.c_str()); - + nIters = 1; output->resetFile(); } diff --git a/raredisplay.h b/raredisplay.h index 50e2121..ff7de73 100644 --- a/raredisplay.h +++ b/raredisplay.h @@ -31,6 +31,7 @@ private: string tempInName, tempOutName; ifstream tempInFile; ofstream tempOutFile; + int renameOk; }; diff --git a/rarefact.cpp b/rarefact.cpp index c064125..2f5f506 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -8,7 +8,7 @@ */ #include "rarefact.h" -#include "ordervector.hpp" +//#include "ordervector.hpp" /***********************************************************************/ diff --git a/rarefact.h b/rarefact.h index b4a4cfe..fc1e8d1 100644 --- a/rarefact.h +++ b/rarefact.h @@ -6,7 +6,7 @@ using namespace std; #include "rarefactioncurvedata.h" #include "raredisplay.h" #include "ordervector.hpp" - +#include "mothur.h" class Rarefact { diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 6a4fe85..dc71b22 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -20,6 +20,7 @@ RareFactSharedCommand::RareFactSharedCommand(){ fileNameRoot = getRootName(globaldata->inputFileName); format = globaldata->getFormat(); validCalculator = new ValidCalculators(); + util = new SharedUtil(); int i; for (i=0; iEstimators.size(); i++) { @@ -55,6 +56,7 @@ RareFactSharedCommand::~RareFactSharedCommand(){ delete input; delete rCurve; delete read; + delete util; } //********************************************************************************************************************** @@ -83,7 +85,7 @@ int RareFactSharedCommand::execute(){ } //set users groups - setGroups(); + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "rarefact"); while(order != NULL){ @@ -134,51 +136,3 @@ int RareFactSharedCommand::execute(){ //********************************************************************************************************************** - -void RareFactSharedCommand::setGroups() { - try { - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if ((globaldata->Groups.size() == 0) || (globaldata->Groups.size() == 1)) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the RareFactSharedCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the RareFactSharedCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/***********************************************************/ - diff --git a/rarefactsharedcommand.h b/rarefactsharedcommand.h index b5b638f..2f7920e 100644 --- a/rarefactsharedcommand.h +++ b/rarefactsharedcommand.h @@ -17,6 +17,7 @@ #include "display.h" #include "readmatrix.hpp" #include "validcalculator.h" +#include "sharedutilities.h" /* The rarefaction.shared() command: The rarefaction command generates a rarefaction curve from a given file representing several groups. @@ -40,8 +41,8 @@ public: int execute(); private: - void setGroups(); GlobalData* globaldata; + SharedUtil* util; SharedListVector* SharedList; ReadMatrix* read; SharedOrderVector* order; diff --git a/readmatrix.cpp b/readmatrix.cpp index 70774d7..4cf39fa 100644 --- a/readmatrix.cpp +++ b/readmatrix.cpp @@ -9,7 +9,6 @@ using namespace std; -#include "utilities.hpp" #include "sparsematrix.hpp" #include "progress.hpp" #include "listvector.hpp" diff --git a/readmatrix.hpp b/readmatrix.hpp index 4e26881..cfa7731 100644 --- a/readmatrix.hpp +++ b/readmatrix.hpp @@ -10,6 +10,7 @@ * */ +#include "mothur.h" #include "rabundvector.hpp" #include "listvector.hpp" #include "sharedlistvector.h" diff --git a/readtree.h b/readtree.h index 15597ba..3df0e0a 100644 --- a/readtree.h +++ b/readtree.h @@ -11,8 +11,8 @@ using namespace std; +#include "mothur.h" #include "globaldata.hpp" -#include "utilities.hpp" #include "tree.h" #define MAX_LINE 513 diff --git a/sabundvector.cpp b/sabundvector.cpp index b293132..04476c7 100644 --- a/sabundvector.cpp +++ b/sabundvector.cpp @@ -9,7 +9,6 @@ using namespace std; #include "sabundvector.hpp" -#include "utilities.hpp" #include "calculator.h" /***********************************************************************/ diff --git a/shared.h b/shared.h index fd9179e..7445b5a 100644 --- a/shared.h +++ b/shared.h @@ -12,6 +12,7 @@ using namespace std; +#include "mothur.h" #include "sharedrabundvector.h" #include "sharedlistvector.h" #include "globaldata.hpp" diff --git a/sharedbdiversity.cpp b/sharedbdiversity.cpp index d45a11f..3d314c3 100644 --- a/sharedbdiversity.cpp +++ b/sharedbdiversity.cpp @@ -8,7 +8,6 @@ */ #include "sharedbdiversity.h" -#include "calculator.h" /***********************************************************************/ diff --git a/sharedkstest.cpp b/sharedkstest.cpp index 897432d..8daa0eb 100644 --- a/sharedkstest.cpp +++ b/sharedkstest.cpp @@ -8,8 +8,6 @@ */ #include "sharedkstest.h" -#include "calculator.h" -#include /***********************************************************************/ diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp index 00aef79..06c8eff 100644 --- a/sharedlistvector.cpp +++ b/sharedlistvector.cpp @@ -14,7 +14,6 @@ using namespace std; #include "sabundvector.hpp" #include "rabundvector.hpp" #include "ordervector.hpp" -#include "utilities.hpp" #include "sharedlistvector.h" #include "sharedordervector.h" diff --git a/sharednseqs.h b/sharednseqs.h index f2ac5a7..6f38054 100644 --- a/sharednseqs.h +++ b/sharednseqs.h @@ -10,9 +10,6 @@ * */ - - - #include "calculator.h" /***********************************************************************/ diff --git a/sharedordervector.cpp b/sharedordervector.cpp index 2092706..4cc1d18 100644 --- a/sharedordervector.cpp +++ b/sharedordervector.cpp @@ -11,7 +11,6 @@ using namespace std; #include "sharedordervector.h" -#include "utilities.hpp" /***********************************************************************/ diff --git a/sharedordervector.h b/sharedordervector.h index a530ad6..c315c44 100644 --- a/sharedordervector.h +++ b/sharedordervector.h @@ -2,7 +2,7 @@ #define SHAREDORDER_H /* * sharedorder.h - * Dotur + * Mothur * * Created by Sarah Westcott on 12/9/08. * Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved. @@ -34,6 +34,9 @@ struct individual { #include "sharedsabundvector.h" #include "globaldata.hpp" #include "groupmap.h" +//#include "globaldata.hpp" + +class GlobalData; class SharedOrderVector : public DataVector { diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp index 3d6a2de..4683c59 100644 --- a/sharedrabundvector.cpp +++ b/sharedrabundvector.cpp @@ -11,10 +11,8 @@ using namespace std; #include "sharedrabundvector.h" -#include "utilities.hpp" #include "sabundvector.hpp" #include "ordervector.hpp" -#include /***********************************************************************/ @@ -186,6 +184,33 @@ void SharedRAbundVector::push_back(int binSize, int otu, string groupName){ } } +/***********************************************************************/ + +void SharedRAbundVector::insert(int binSize, int otu, string groupName){ + try { + individual newGuy; + newGuy.abundance = binSize; + newGuy.group = groupName; + newGuy.bin = otu; + + data.insert(data.begin()+otu, newGuy); + numBins++; + + if(binSize > maxRank){ + maxRank = binSize; + } + + numSeqs += binSize; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedRAbundVector class Function insert. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedRAbundVector class function insert. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} /***********************************************************************/ diff --git a/sharedrabundvector.h b/sharedrabundvector.h index ab0c26a..5cc92a3 100644 --- a/sharedrabundvector.h +++ b/sharedrabundvector.h @@ -49,6 +49,7 @@ public: int numNZ(); void sortD(); //Sorts the data in descending order. void push_front(int, int, string); //abundance, otu, groupname + void insert(int, int, string); //abundance, otu, groupname void push_back(int, int, string); //abundance, otu, groupname void pop_back(); void resize(int); diff --git a/sharedsabundvector.cpp b/sharedsabundvector.cpp index 7babf1c..3cc80f7 100644 --- a/sharedsabundvector.cpp +++ b/sharedsabundvector.cpp @@ -9,7 +9,6 @@ #include "sharedsabundvector.h" #include "sabundvector.hpp" -#include "utilities.hpp" using namespace std; diff --git a/sharedutilities.cpp b/sharedutilities.cpp new file mode 100644 index 0000000..4e35ff3 --- /dev/null +++ b/sharedutilities.cpp @@ -0,0 +1,292 @@ +/* + * sharedutilities.cpp + * Mothur + * + * Created by Sarah Westcott on 4/9/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "sharedutilities.h" +#include "sharedrabundvector.h" +#include "sharedordervector.h" + +/**************************************************************************************************/ + +void SharedUtil::getSharedVectors(vector Groups, vector& lookup, SharedOrderVector* order) { + try { + + //delete each sharedrabundvector in lookup + for (int j = 0; j < lookup.size(); j++) { + delete lookup[j]; + } + + lookup.clear(); + + //create and initialize vector of sharedvectors, one for each group + for (int i = 0; i < Groups.size(); i++) { + SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins()); + temp->setLabel(order->getLabel()); + temp->setGroup(Groups[i]); + lookup.push_back(temp); + } + + int numSeqs = order->size(); + //sample all the members + for(int i=0;iget(i); + int abundance; + + //set info for sharedvector in chosens group + for (int j = 0; j < lookup.size(); j++) { + if (chosen.group == lookup[j]->getGroup()) { + abundance = lookup[j]->getAbundance(chosen.bin); + lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); + break; + } + } + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/**************************************************************************************************/ +//need to have mode because different commands require different number of valid groups +void SharedUtil::setGroups(vector& userGroups, vector& allGroups, string mode) { + try { + if (userGroups.size() != 0) { + if (userGroups[0] != "all") { + //check that groups are valid + for (int i = 0; i < userGroups.size(); i++) { + if (isValidGroup(userGroups[i], allGroups) != true) { + cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl; + // erase the invalid group from userGroups + userGroups.erase(userGroups.begin()+i); + i--; + } + } + + }else{//user has enter "all" and wants the default groups + userGroups.clear(); + for (int i = 0; i < allGroups.size(); i++) { + userGroups.push_back(allGroups[i]); + } + } + }else { //the user has not entered groups + for (int i = 0; i < allGroups.size(); i++) { + userGroups.push_back(allGroups[i]); + } + } + + if (mode == "venn") { + //if the user only entered invalid groups + if (userGroups.size() == 0) { + if (allGroups.size() > 4) { + cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first four groups in your groupfile." << endl; + for (int i = 0; i < 4; i++) { + userGroups.push_back(allGroups[i]); + } + }else { + cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; + for (int i = 0; i < allGroups.size(); i++) { + userGroups.push_back(allGroups[i]); + } + } + } + + //check to make sure their are only 4 groups + if (userGroups.size() > 4) { + cout << "You may only use up to 4 groups at a time with this command. I will choose the first four and disregard the rest." << endl; + for (int i = 4; i < userGroups.size(); i++) { + userGroups.erase(userGroups.begin()+i); + } + } + }else if (mode == "heat") { + //if the user only entered invalid groups + if (userGroups.size() == 0) { + cout << "When using the groups parameter you must have at least 1 valid groups. I will run the command using all the groups in your groupfile." << endl; + for (int i = 0; i < allGroups.size(); i++) { + userGroups.push_back(allGroups[i]); + } + } + }else if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) { + //if the user only entered invalid groups + if ((userGroups.size() == 0) || (userGroups.size() == 1)) { + cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + for (int i = 0; i < allGroups.size(); i++) { + userGroups.push_back(allGroups[i]); + } + } + } + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +/**************************************************************************************/ +//for parsimony and unifrac commands you set pairwise groups as well as an allgroups in calc +void SharedUtil::setGroups(vector& userGroups, vector& allGroups, string& label, int& numGroups, string mode){ //globaldata->Groups, your tree or group map, allgroups, mode + try { + numGroups = 0; + label = ""; + //if the user has not entered specific groups to analyze then do them all + if (userGroups.size() != 0) { + if (userGroups[0] != "all") { + //check that groups are valid + for (int i = 0; i < userGroups.size(); i++) { + if (isValidGroup(userGroups[i], allGroups) != true) { + cout << userGroups[i] << " is not a valid group, and will be disregarded." << endl; + // erase the invalid group from globaldata->Groups + userGroups.erase(userGroups.begin()+i); + i--; + } + } + }else { //users wants all groups + userGroups.clear(); + for (int i=0; i < allGroups.size(); i++) { + if (allGroups[i] != "xxx") { + userGroups.push_back(allGroups[i]); + label += allGroups[i] + "-"; + } + } + } + }else { //the user has not entered groups + for (int i=0; i < allGroups.size(); i++) { + if (allGroups[i] != "xxx") { + label += allGroups[i] + "-"; + if (mode == "weighted") { + userGroups.push_back(allGroups[i]); + }else { + numGroups = 1; + } + } + } + } + + + if (mode == "weighted") { + //if the user only entered invalid groups + if (userGroups.size() == 0) { + for (int i=0; i < allGroups.size(); i++) { + if (allGroups[i] != "xxx") { + userGroups.push_back(allGroups[i]); + } + } + cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + }else if (userGroups.size() == 1) { + cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; + userGroups.clear(); + for (int i=0; i < allGroups.size(); i++) { + if (allGroups[i] != "xxx") { + userGroups.push_back(allGroups[i]); + } + } + } + numGroups = userGroups.size(); + + }else if ((mode == "unweighted") || (mode == "parsimony")) { + //if the user only entered invalid groups + if ((userGroups.size() == 0) && (numGroups == 0)) { + cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; + for (int i = 0; i < allGroups.size(); i++) { + if (allGroups[i] != "xxx") { + userGroups.push_back(allGroups[i]); + label += allGroups[i] + "-"; + } + } + }else { + for (int i = 0; i < userGroups.size(); i++) { + label += userGroups[i] + "-"; + } + } + + //rip extra - off allgroups + label = label.substr(0, label.length()-1); + + if (numGroups != 1) { numGroups = userGroups.size(); } + + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/**************************************************************************************/ +void SharedUtil::getCombos(vector& groupComb, vector userGroups, int& numComp) { //groupcomb, globaldata->Groups, numcomb + try { + //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3; + numComp = 0; + for (int i=0; i< userGroups.size(); i++) { + numComp += i; + for (int l = i+1; l < userGroups.size(); l++) { + //set group comparison labels + groupComb.push_back(userGroups[i] + "-" + userGroups[l]); + } + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function getCombos. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/**************************************************************************************/ +bool SharedUtil::isValidGroup(string groupname, vector groups) { + try { + for (int i = 0; i < groups.size(); i++) { + if (groupname == groups[i]) { return true; } + } + + return false; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function isValidGroup. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + +/**************************************************************************************/ +void SharedUtil::updateGroupIndex(vector& userGroups, map& index) { + try { + index.clear(); + for (int i = 0; i < userGroups.size(); i++) { + index[userGroups[i]] = i; + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the SharedUtil class Function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the SharedUtil class function updateGroupIndex. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} diff --git a/sharedutilities.h b/sharedutilities.h new file mode 100644 index 0000000..f4e4631 --- /dev/null +++ b/sharedutilities.h @@ -0,0 +1,39 @@ +#ifndef SHAREDUTIL_H +#define SHAREDUTIL_H +/* + * sharedutilities.h + * Mothur + * + * Created by Sarah Westcott on 4/9/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "mothur.h" + +class SharedRAbundVector; +class SharedOrderVector; + +/**************************************************************************************************/ + +class SharedUtil { + public: + SharedUtil() {}; + ~SharedUtil() {}; + + void getSharedVectors(vector, vector&, SharedOrderVector*); + void setGroups(vector&, vector&, string); //globaldata->Groups, your tree or group map, mode + void setGroups(vector&, vector&, string&, int&, string); //globaldata->Groups, your tree or group map, allgroups, numGroups, mode + void getCombos(vector&, vector, int&); //groupcomb, globaldata->Groups, numcomb + void updateGroupIndex(vector&, map&); //globaldata->Groups, groupmap->groupIndex + + private: + + bool isValidGroup(string, vector); +}; + +/**************************************************************************************************/ + + + +#endif \ No newline at end of file diff --git a/singlelinkage.cpp b/singlelinkage.cpp index 1b0aed2..a024453 100644 --- a/singlelinkage.cpp +++ b/singlelinkage.cpp @@ -1,4 +1,5 @@ +#include "mothur.h" #include "cluster.hpp" diff --git a/sparsematrix.cpp b/sparsematrix.cpp index 0b210c6..fc10d27 100644 --- a/sparsematrix.cpp +++ b/sparsematrix.cpp @@ -1,4 +1,4 @@ -#include "utilities.hpp" + #include "sparsematrix.hpp" #include "listvector.hpp" diff --git a/sparsematrix.hpp b/sparsematrix.hpp index bcd7899..d65771e 100644 --- a/sparsematrix.hpp +++ b/sparsematrix.hpp @@ -1,7 +1,6 @@ #ifndef SPARSEMATRIX_H #define SPARSEMATRIX_H -#include "utilities.hpp" #include "mothur.h" diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index 526cd82..bebdf26 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -40,6 +40,7 @@ SummarySharedCommand::SummarySharedCommand(){ openOutputFile(outputFileName, outputFileHandle); format = globaldata->getFormat(); validCalculator = new ValidCalculators(); + util = new SharedUtil(); int i; for (i=0; iEstimators.size(); i++) { @@ -109,6 +110,7 @@ SummarySharedCommand::SummarySharedCommand(){ SummarySharedCommand::~SummarySharedCommand(){ delete input; delete read; + delete util; } //********************************************************************************************************************** @@ -137,7 +139,7 @@ int SummarySharedCommand::execute(){ } //set users groups - setGroups(); + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "summary"); //output estimator names as column headers outputFileHandle << "label" <<'\t' << "comparison" << '\t'; @@ -151,7 +153,7 @@ int SummarySharedCommand::execute(){ if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){ cout << order->getLabel() << '\t' << count << endl; - getSharedVectors(); //fills group vectors from order vector. + util->getSharedVectors(globaldata->Groups, lookup, order); //fills group vectors from order vector. //fills group vectors from order vector. //randomize group order if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); } @@ -159,7 +161,7 @@ int SummarySharedCommand::execute(){ int n = 1; for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare for (int l = n; l < lookup.size(); l++) { - outputFileHandle << order->getLabel() << '\t' << (lookup[k]->getGroup() + lookup[l]->getGroup()) << '\t' << '\t'; //print out label and group + outputFileHandle << order->getLabel() << '\t'; //sort groups to be alphanumeric @@ -210,91 +212,4 @@ int SummarySharedCommand::execute(){ } } -//********************************************************************************************************************** - -void SummarySharedCommand::getSharedVectors(){ -try { - lookup.clear(); - //create and initialize vector of sharedvectors, one for each group - for (int i = 0; i < globaldata->Groups.size(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins()); - temp->setLabel(order->getLabel()); - temp->setGroup(globaldata->Groups[i]); - lookup.push_back(temp); - } - - int numSeqs = order->size(); - //sample all the members - for(int i=0;iget(i); - int abundance; - - //set info for sharedvector in chosens group - for (int j = 0; j < lookup.size(); j++) { - if (chosen.group == lookup[j]->getGroup()) { - abundance = lookup[j]->getAbundance(chosen.bin); - lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); - break; - } - } - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SummarySharedCommand class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} - -//********************************************************************************************************************** -void SummarySharedCommand::setGroups() { - try { - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if ((globaldata->Groups.size() == 0) || (globaldata->Groups.size() == 1)) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the SummarySharedCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} /***********************************************************/ diff --git a/summarysharedcommand.h b/summarysharedcommand.h index 248c1c8..9e4a8c8 100644 --- a/summarysharedcommand.h +++ b/summarysharedcommand.h @@ -17,6 +17,7 @@ #include "readmatrix.hpp" #include "sharedlistvector.h" #include "validcalculator.h" +#include "sharedutilities.h" /*The summary.shared() command The summary.shared command can only be executed after a successful read.shared command. @@ -43,18 +44,15 @@ public: int execute(); private: - void getSharedVectors(); - void setGroups(); - GlobalData* globaldata; ReadMatrix* read; + SharedUtil* util; vector sumCalculators; InputData* input; ValidCalculators* validCalculator; SharedListVector* SharedList; SharedOrderVector* order; vector lookup; - SharedRAbundVector* shared1, shared2; string outputFileName, format; ofstream outputFileHandle; diff --git a/tree.cpp b/tree.cpp index 6aa1b82..f93b933 100644 --- a/tree.cpp +++ b/tree.cpp @@ -511,8 +511,16 @@ void Tree::printBranch(int node) { out << ","; printBranch(tree[node].getRChild()); out << ")"; + //if there is a branch length then print it + if (tree[node].getBranchLength() != -1) { + out << ":" << tree[node].getBranchLength(); + } }else { //you are a leaf - out << tree[node].getGroup() << ":" << tree[node].getBranchLength(); + out << tree[node].getGroup(); + //if there is a branch length then print it + if (tree[node].getBranchLength() != -1) { + out << ":" << tree[node].getBranchLength(); + } } } diff --git a/treecalculator.h b/treecalculator.h index 9ee4774..cfd648e 100644 --- a/treecalculator.h +++ b/treecalculator.h @@ -13,7 +13,6 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" #include "tree.h" /* The tree calculator class is the parent class for tree calculators in mothur. */ diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp new file mode 100644 index 0000000..bdd664a --- /dev/null +++ b/treegroupscommand.cpp @@ -0,0 +1,292 @@ +/* + * treegroupscommand.cpp + * Mothur + * + * Created by Sarah Westcott on 4/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "treegroupscommand.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" + + +//********************************************************************************************************************** + +TreeGroupCommand::TreeGroupCommand(){ + try { + globaldata = GlobalData::getInstance(); + format = globaldata->getFormat(); + validCalculator = new ValidCalculators(); + util = new SharedUtil(); + + int i; + for (i=0; iEstimators.size(); i++) { + if (validCalculator->isValidCalculator("treegroup", globaldata->Estimators[i]) == true) { + if (globaldata->Estimators[i] == "sharedjabund") { + treeCalculators.push_back(new SharedJAbund()); + }else if (globaldata->Estimators[i] == "sharedsorensonabund") { + treeCalculators.push_back(new SharedSorAbund()); + }else if (globaldata->Estimators[i] == "sharedjclass") { + treeCalculators.push_back(new SharedJclass()); + }else if (globaldata->Estimators[i] == "sharedsorclass") { + treeCalculators.push_back(new SharedSorClass()); + }else if (globaldata->Estimators[i] == "sharedjest") { + treeCalculators.push_back(new SharedJest()); + }else if (globaldata->Estimators[i] == "sharedsorest") { + treeCalculators.push_back(new SharedSorEst()); + }else if (globaldata->Estimators[i] == "sharedthetayc") { + treeCalculators.push_back(new SharedThetaYC()); + }else if (globaldata->Estimators[i] == "sharedthetan") { + treeCalculators.push_back(new SharedThetaN()); + }else if (globaldata->Estimators[i] == "sharedmorisitahorn") { + treeCalculators.push_back(new SharedMorHorn()); + } + } + } + + //reset calc for next command + globaldata->setCalc(""); + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function TreeGroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeGroupCommand class function TreeGroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +TreeGroupCommand::~TreeGroupCommand(){ + delete input; + delete read; + delete util; +} + +//********************************************************************************************************************** + +int TreeGroupCommand::execute(){ + try { + int count = 1; + EstOutput data; + + //if the users entered no valid calculators don't execute command + if (treeCalculators.size() == 0) { return 0; } + + if (format == "sharedfile") { + read = new ReadPhilFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + order = input->getSharedOrderVector(); + }else { + //you are using a list and a groupfile + read = new ReadPhilFile(globaldata->inputFileName); + read->read(&*globaldata); + + input = globaldata->ginput; + SharedList = globaldata->gSharedList; + order = SharedList->getSharedOrderVector(); + } + + //set users groups + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "treegroup"); + numGroups = globaldata->Groups.size(); + groupNames = ""; + for (int i = 0; i < numGroups; i++) { groupNames += globaldata->Groups[i]; } + + //clear globaldatas old tree names if any + globaldata->Treenames.clear(); + + //fills globaldatas tree names + globaldata->Treenames = globaldata->Groups; + + //create treemap class from groupmap for tree class to use + tmap = new TreeMap(); + tmap->makeSim(globaldata->gGroupmap); + globaldata->gTreemap = tmap; + + while(order != NULL){ + + if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){ + + cout << order->getLabel() << '\t' << count << endl; + util->getSharedVectors(globaldata->Groups, lookup, order); //fills group vectors from order vector. + + //for each calculator + for(int i = 0 ; i < treeCalculators.size(); i++) { + + //initialize simMatrix + simMatrix.clear(); + simMatrix.resize(numGroups); + for (int m = 0; m < simMatrix.size(); m++) { + for (int j = 0; j < simMatrix.size(); j++) { + simMatrix[m].push_back(0.0); + } + } + + //initialize index + index.clear(); + for (int g = 0; g < numGroups; g++) { index[g] = g; } + + //create a new filename + outputFile = getRootName(globaldata->inputFileName) + treeCalculators[i]->getName() + "." + order->getLabel() + groupNames + ".tre"; + + for (int k = 0; k < lookup.size(); k++) { // pass cdd each set of groups to commpare + for (int l = k; l < lookup.size(); l++) { + if (k != l) { //we dont need to similiarity of a groups to itself + //get estimated similarity between 2 groups + data = treeCalculators[i]->getValues(lookup[k], lookup[l]); //saves the calculator outputs + //save values in similarity matrix + simMatrix[k][l] = data[0]; + simMatrix[l][k] = data[0]; + } + } + } + + //creates tree from similarity matrix and write out file + createTree(); + } + } + + //get next line to process + if (format == "sharedfile") { + order = input->getSharedOrderVector(); + }else { + //you are using a list and a groupfile + SharedList = input->getSharedListVector(); //get new list vector to process + if (SharedList != NULL) { + order = SharedList->getSharedOrderVector(); //gets new order vector with group info. + }else { + break; + } + } + count++; + } + + //reset groups parameter + globaldata->Groups.clear(); globaldata->setGroups(""); + + return 0; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeGroupCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +//********************************************************************************************************************** + +void TreeGroupCommand::createTree(){ + try { + //create tree + t = new Tree(); + + //do merges and create tree structure by setting parents and children + //there are numGroups - 1 merges to do + for (int i = 0; i < (numGroups - 1); i++) { + + float largest = 0.0; + int row, column; + //find largest value in sims matrix by searching lower triangle + for (int j = 1; j < simMatrix.size(); j++) { + for (int k = 0; k < j; k++) { + if (simMatrix[j][k] > largest) { largest = simMatrix[j][k]; row = j; column = k; } + } + } + + //set non-leaf node info and update leaves to know their parents + //non-leaf + t->tree[numGroups + i].setChildren(index[row], index[column]); + + //parents + t->tree[index[row]].setParent(numGroups + i); + t->tree[index[column]].setParent(numGroups + i); + + //blength = distance / 2; + float blength = ((1.0 - largest) / 2); + + //branchlengths + t->tree[index[row]].setBranchLength(blength - t->tree[index[row]].getLengthToLeaves()); + t->tree[index[column]].setBranchLength(blength - t->tree[index[column]].getLengthToLeaves()); + + //set your length to leaves to your childs length plus branchlength + t->tree[numGroups + i].setLengthToLeaves(t->tree[index[row]].getLengthToLeaves() + t->tree[index[row]].getBranchLength()); + + + //update index + index[row] = numGroups+i; + index[column] = numGroups+i; + + //zero out highest value that caused the merge. + simMatrix[row][column] = 0.0; + simMatrix[column][row] = 0.0; + + //merge values in simsMatrix + for (int n = 0; n < simMatrix.size(); n++) { + //row becomes merge of 2 groups + simMatrix[row][n] = (simMatrix[row][n] + simMatrix[column][n]) / 2; + simMatrix[n][row] = simMatrix[row][n]; + //delete column + simMatrix[column][n] = 0.0; + simMatrix[n][column] = 0.0; + } + } + + //assemble tree + t->assembleTree(); + + //print newick file + t->createNewickFile(outputFile); + + //delete tree + delete t; + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeGroupCommand class function createTree. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/***********************************************************/ +void TreeGroupCommand::printSims() { + try { + cout << "simsMatrix" << endl; + for (int m = 0; m < simMatrix.size(); m++) { + for (int n = 0; n < simMatrix.size(); n++) { + cout << simMatrix[m][n] << '\t'; + } + cout << endl; + } + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeGroupCommand class Function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeGroupCommand class function printSims. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/***********************************************************/ + + diff --git a/treegroupscommand.h b/treegroupscommand.h new file mode 100644 index 0000000..4c3b842 --- /dev/null +++ b/treegroupscommand.h @@ -0,0 +1,63 @@ +#ifndef TREEGROUPCOMMAND_H +#define TREEGROUPCOMMAND_H + +/* + * treegroupscommand.h + * Mothur + * + * Created by Sarah Westcott on 4/8/09. + * Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved. + * + */ + +#include "command.hpp" +#include "sharedordervector.h" +#include "sharedlistvector.h" +#include "inputdata.h" +#include "groupmap.h" +#include "readmatrix.hpp" +#include "validcalculator.h" +#include "tree.h" +#include "treemap.h" +#include "sharedutilities.h" + + +/* This command create a tree file for each similarity calculator at distance level, using various calculators to find the similiarity between groups. + The user can select the lines or labels they wish to use as well as the groups they would like included. + They can also use as many or as few calculators as they wish. */ + +class GlobalData; + +class TreeGroupCommand : public Command { + +public: + TreeGroupCommand(); + ~TreeGroupCommand(); + int execute(); + +private: + void createTree(); + void printSims(); + + GlobalData* globaldata; + SharedUtil* util; + ReadMatrix* read; + TreeMap* tmap; + Tree* t; + vector treeCalculators; + vector< vector > simMatrix; + map index; //maps row in simMatrix to vector index in the tree + InputData* input; + ValidCalculators* validCalculator; + SharedListVector* SharedList; + SharedOrderVector* order; + vector lookup; + string format, outputFile, groupNames; + int numGroups; + +}; + + +#endif + + diff --git a/treemap.cpp b/treemap.cpp index fee309c..5880b0c 100644 --- a/treemap.cpp +++ b/treemap.cpp @@ -144,3 +144,31 @@ void TreeMap::print(ostream& output){ } /************************************************************/ +void TreeMap::makeSim(GroupMap* groupmap) { + try { + //set names of groups + namesOfGroups = groupmap->namesOfGroups; + + //set names of seqs to names of groups + namesOfSeqs = groupmap->namesOfGroups; + + // make map where key and value are both the group name since that what the tree.groups command wants + for (int i = 0; i < namesOfGroups.size(); i++) { + treemap[namesOfGroups[i]].groupname = namesOfGroups[i]; + seqsPerGroup[namesOfGroups[i]] = 1; + } + + numGroups = namesOfGroups.size(); + + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the TreeMap class Function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the TreeMap class function make. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} +/************************************************************/ + diff --git a/treemap.h b/treemap.h index 941ca9a..1229973 100644 --- a/treemap.h +++ b/treemap.h @@ -10,7 +10,7 @@ */ #include "mothur.h" -#include "utilities.hpp" +#include "groupmap.h" /* This class is used by the read.tree command to build the tree container. */ @@ -19,7 +19,7 @@ struct GroupIndex { int vectorIndex; }; - +class GroupMap; class TreeMap { public: @@ -38,6 +38,7 @@ public: map seqsPerGroup; //groupname, number of seqs in that group. map treemap; //sequence name and void print(ostream&); + void makeSim(GroupMap*); //takes groupmap info and fills treemap for use by tree.groups command. private: diff --git a/treenode.cpp b/treenode.cpp index cf7192e..59fb630 100644 --- a/treenode.cpp +++ b/treenode.cpp @@ -18,6 +18,7 @@ Node::Node() { parent = -1; lchild = -1; rchild = -1; + length2leaf = 0.0; } /****************************************************************/ @@ -27,6 +28,8 @@ void Node::setGroup(string groups) { group =groups; } /****************************************************************/ void Node::setBranchLength(float l) { branchLength = l; } /****************************************************************/ +void Node::setLengthToLeaves(float l) { length2leaf = l; } +/****************************************************************/ void Node::setParent(int p) { parent = p; } /****************************************************************/ void Node::setIndex(int i) { vectorIndex = i; } @@ -39,6 +42,8 @@ string Node::getGroup() { return group; } /****************************************************************/ float Node::getBranchLength() { return branchLength; } /****************************************************************/ +float Node::getLengthToLeaves() { return length2leaf; } +/****************************************************************/ int Node::getParent() { return parent; } /****************************************************************/ int Node::getLChild() { return lchild; } diff --git a/treenode.h b/treenode.h index a83bbca..58d967d 100644 --- a/treenode.h +++ b/treenode.h @@ -28,10 +28,12 @@ class Node { void setParent(int); void setChildren(int, int); //leftchild, rightchild void setIndex(int); + void setLengthToLeaves(float); string getName(); string getGroup(); float getBranchLength(); + float getLengthToLeaves(); int getParent(); int getLChild(); int getRChild(); @@ -51,7 +53,7 @@ class Node { private: string name; string group; - float branchLength; + float branchLength, length2leaf; int parent; int lchild; int rchild; diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 2b93df7..9d17063 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -19,7 +19,18 @@ UnifracUnweightedCommand::UnifracUnweightedCommand() { sumFile = globaldata->getTreeFile() + ".uwsummary"; openOutputFile(sumFile, outSum); - setGroups(); //sets users groups to analyze + util = new SharedUtil(); + util->setGroups(globaldata->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze + util->getCombos(groupComb, globaldata->Groups, numComp); + globaldata->setGroups(""); + + //ABC + if (numComp != 1) { + groupComb.push_back(allGroups); + numComp++; + } + + convert(globaldata->getIters(), iters); //how many random trees to generate unweighted = new Unweighted(tmap); @@ -114,7 +125,7 @@ int UnifracUnweightedCommand::execute() { UWScoreSig.clear(); } //reset groups parameter - globaldata->Groups.clear(); globaldata->setGroups(""); + globaldata->Groups.clear(); outSum.close(); return 0; @@ -189,89 +200,6 @@ void UnifracUnweightedCommand::printUWSummaryFile() { exit(1); } } -/***********************************************************/ - -void UnifracUnweightedCommand::setGroups() { - try { - string allGroups = ""; - numGroups = 0; - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (tmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if (globaldata->Groups.size() == 0) { - cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - allGroups += tmap->namesOfGroups[i] + "-"; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - }else { - for (int i = 0; i < globaldata->Groups.size(); i++) { - allGroups += globaldata->Groups[i] + "-"; - numGroups++; - } - allGroups = allGroups.substr(0, allGroups.length()-1); - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - allGroups += tmap->namesOfGroups[i] + "-"; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < tmap->namesOfGroups.size(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - allGroups += tmap->namesOfGroups[i] + "-"; - } - } - allGroups = allGroups.substr(0, allGroups.length()-1); - numGroups = 1; - } - - //calculate number of comparsions - numComp = 0; - for (int r=0; rGroups[r]+ "-" + globaldata->Groups[l]); - numComp++; - } - } - - //ABC - if (numComp != 1) { - groupComb.push_back(allGroups); - numComp++; - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the UnifracUnweightedCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the UnifracUnweightedCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} /*****************************************************************/ void UnifracUnweightedCommand::initFile(string label){ diff --git a/unifracunweightedcommand.h b/unifracunweightedcommand.h index 3c250db..3bd9a0d 100644 --- a/unifracunweightedcommand.h +++ b/unifracunweightedcommand.h @@ -13,6 +13,7 @@ #include "command.hpp" #include "unweighted.h" #include "treemap.h" +#include "sharedutilities.h" using namespace std; @@ -23,15 +24,16 @@ class UnifracUnweightedCommand : public Command { public: UnifracUnweightedCommand(); - ~UnifracUnweightedCommand() { delete unweighted; } + ~UnifracUnweightedCommand() { delete unweighted; delete util; } int execute(); private: GlobalData* globaldata; + SharedUtil* util; vector T; //user trees TreeMap* tmap; Unweighted* unweighted; - string sumFile, unweightedFile, unweightedFileout; + string sumFile, unweightedFile, unweightedFileout, allGroups; vector groupComb; // AB. AC, BC... int iters, numGroups, numComp, counter; EstOutput userData; //unweighted score info for user tree @@ -49,7 +51,6 @@ class UnifracUnweightedCommand : public Command { void printUWSummaryFile(); void printUnweightedFile(); - void setGroups(); void initFile(string); void output(vector); void resetFile(); diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index c2584ea..5f7b4ad 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -19,7 +19,12 @@ UnifracWeightedCommand::UnifracWeightedCommand() { sumFile = globaldata->getTreeFile() + ".wsummary"; openOutputFile(sumFile, outSum); - setGroups(); //sets the groups the user wants to analyze + util = new SharedUtil(); + string s; //to make work with setgroups + util->setGroups(globaldata->Groups, tmap->namesOfGroups, s, numGroups, "weighted"); //sets the groups the user wants to analyze + util->getCombos(groupComb, globaldata->Groups, numComp); + globaldata->setGroups(""); + convert(globaldata->getIters(), iters); //how many random trees to generate weighted = new Weighted(tmap); @@ -51,8 +56,9 @@ int UnifracWeightedCommand::execute() { counter = 0; rScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC... uScores.resize(numComp); //data[0] = weightedscore AB, data[1] = weightedscore AC... - weightedFile = globaldata->getTreeFile() + toString(i+1) + ".weighted"; - weightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".weighted"; + //weightedFile = globaldata->getTreeFile() + toString(i+1) + ".weighted"; + //weightedFileout = globaldata->getTreeFile() + "temp." + toString(i+1) + ".weighted"; + output = new ThreeColumnFile2(globaldata->getTreeFile() + toString(i+1) + ".weighted"); userData = weighted->getValues(T[i]); //userData[0] = weightedscore @@ -109,6 +115,8 @@ int UnifracWeightedCommand::execute() { calculateFreqsCumuls(); printWeightedFile(); + delete output; + //clear data rScores.clear(); uScores.clear(); @@ -142,21 +150,23 @@ int UnifracWeightedCommand::execute() { void UnifracWeightedCommand::printWeightedFile() { try { vector data; + vector tags; + tags.push_back("Score"); tags.push_back("RandFreq"); tags.push_back("RandCumul"); for(int a = 0; a < numComp; a++) { - initFile(groupComb[a]); + output->initFile(groupComb[a], tags); //print each line for (it = validScores.begin(); it != validScores.end(); it++) { data.push_back(it->first); data.push_back(rScoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); - output(data); + output->output(data); data.clear(); } - resetFile(); + output->resetFile(); } - out.close(); - inFile.close(); - remove(weightedFileout.c_str()); + //out.close(); + //inFile.close(); + //remove(weightedFileout.c_str()); } catch(exception& e) { @@ -224,80 +234,6 @@ int UnifracWeightedCommand::findIndex(float score, int index) { } } -/***********************************************************/ -void UnifracWeightedCommand::setGroups() { - try { - numGroups = 0; - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() == 0) { - for (int i=0; i < tmap->getNumGroups(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - } - } - }else { - if (globaldata->getGroups() != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (tmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase (globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if (globaldata->Groups.size() == 0) { - for (int i=0; i < tmap->getNumGroups(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - } - } - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; - }else if (globaldata->Groups.size() == 1) { - cout << "When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile." << endl; - globaldata->Groups.clear(); - for (int i=0; i < tmap->getNumGroups(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - } - } - }else { numGroups = globaldata->Groups.size(); } - }else { //users wants all groups - globaldata->Groups.clear(); - globaldata->setGroups(""); - for (int i=0; i < tmap->getNumGroups(); i++) { - if (tmap->namesOfGroups[i] != "xxx") { - globaldata->Groups.push_back(tmap->namesOfGroups[i]); - numGroups++; - } - } - } - } - - //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3; - numComp = 0; - for (int i=0; iGroups[i] + "-" + globaldata->Groups[l]); - } - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the UnifracWeightedCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the UnifracWeightedCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -} - /***********************************************************/ void UnifracWeightedCommand::calculateFreqsCumuls() { @@ -348,7 +284,7 @@ void UnifracWeightedCommand::calculateFreqsCumuls() { } -/*****************************************************************/ +/***************************************************************** void UnifracWeightedCommand::initFile(string label){ try { @@ -378,7 +314,7 @@ void UnifracWeightedCommand::initFile(string label){ } } -/***********************************************************************/ +/*********************************************************************** void UnifracWeightedCommand::output(vector data){ try { @@ -404,7 +340,7 @@ void UnifracWeightedCommand::output(vector data){ } }; -/***********************************************************************/ +/*********************************************************************** void UnifracWeightedCommand::resetFile(){ try { @@ -427,6 +363,14 @@ void UnifracWeightedCommand::resetFile(){ catch(...) { cout << "An unknown error has occurred in the UnifracWeightedCommand class function resetFile. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; exit(1); - } + } + + + } +*/ + + + + diff --git a/unifracweightedcommand.h b/unifracweightedcommand.h index ea2c418..751343b 100644 --- a/unifracweightedcommand.h +++ b/unifracweightedcommand.h @@ -14,6 +14,8 @@ #include "weighted.h" #include "treemap.h" #include "progress.hpp" +#include "sharedutilities.h" +#include "fileoutput.h" using namespace std; @@ -23,11 +25,13 @@ class UnifracWeightedCommand : public Command { public: UnifracWeightedCommand(); - ~UnifracWeightedCommand() { delete weighted; } + ~UnifracWeightedCommand() { delete weighted; delete util; } int execute(); private: GlobalData* globaldata; + SharedUtil* util; + FileOutput* output; vector T; //user trees vector utreeScores; //user tree unweighted scores vector WScoreSig; //tree weighted score signifigance when compared to random trees - percentage of random trees with that score or lower. @@ -54,11 +58,10 @@ class UnifracWeightedCommand : public Command { void printWeightedFile(); //void removeValidScoresDuplicates(); int findIndex(float, int); - void setGroups(); void calculateFreqsCumuls(); - void initFile(string); - void output(vector); - void resetFile(); + //void initFile(string); + //void output(vector); + //void resetFile(); }; diff --git a/utilities.hpp b/utilities.hpp deleted file mode 100644 index eea96bf..0000000 --- a/utilities.hpp +++ /dev/null @@ -1,392 +0,0 @@ -#ifndef UTILITIES_H -#define UTILITIES_H - -using namespace std; - -#include "mothur.h" -#include "treemap.h" - -typedef unsigned long long ull; - -/***********************************************************************/ - -// snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2 -// works for now, but there should be a way to do it without killing the whole program - -class BadConversion : public runtime_error { -public: - BadConversion(const string& s) : runtime_error(s){ } -}; - -//********************************************************************************************************************** - -template -inline void convert(const string& s, T& x, bool failIfLeftoverChars = true){ - istringstream i(s); - char c; - if (!(i >> x) || (failIfLeftoverChars && i.get(c))) - throw BadConversion(s); -} -//********************************************************************************************************************** - -template -inline bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){ - istringstream i(s); - char c; - if (!(i >> x) || (failIfLeftoverChars && i.get(c))) - { - cout << "'" << s << "' is unable to be converted into an integer.\n"; - return false; - } - return true; -} - -//********************************************************************************************************************** - -template -string toString(const T&x){ - stringstream output; - output << x; - return output.str(); -} - -//********************************************************************************************************************** - -template -string toHex(const T&x){ - stringstream output; - - output << hex << x; - - return output.str(); -} - -//********************************************************************************************************************** - -template -string toString(const T&x, int i){ - stringstream output; - - output.precision(i); - output << fixed << x; - - return output.str(); -} - - -/***********************************************************************/ - -inline void gobble(istream& f){ - - char d; - while(isspace(d=f.get())) {;} - f.putback(d); - -} - -/***********************************************************************/ - -inline float roundDist(float dist, int precision){ - - return int(dist * precision + 0.5)/float(precision); - -} - -/***********************************************************************/ - -inline int getNumNames(string names){ - - int count = 0; - - if(names != ""){ - count = 1; - for(int i=0;i > binomial(int maxOrder){ - - vector > binomial(maxOrder+1); - - for(int i=0;i<=maxOrder;i++){ - binomial[i].resize(maxOrder+1); - binomial[i][0]=1; - binomial[0][i]=0; - } - binomial[0][0]=1; - - binomial[1][0]=1; - binomial[1][1]=1; - - for(int i=2;i<=maxOrder;i++){ - binomial[1][i]=0; - } - - for(int i=2;i<=maxOrder;i++){ - for(int j=1;j<=maxOrder;j++){ - if(i==j){ binomial[i][j]=1; } - if(j>i) { binomial[i][j]=0; } - else { binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j]; } - } - } - - return binomial; -} - -/***********************************************************************/ - -inline string getRootName(string longName){ - - string rootName = longName; - - if(longName.find_last_of(".") != longName.npos){ - int pos = longName.find_last_of('.')+1; - rootName = longName.substr(0, pos); - } - - return rootName; -} -/***********************************************************************/ - -inline string getSimpleName(string longName){ - - string simpleName = longName; - - if(longName.find_last_of("/") != longName.npos){ - int pos = longName.find_last_of('/')+1; - simpleName = longName.substr(pos, longName.length()); - } - - return simpleName; -} - -/***********************************************************************/ - -inline string getPathName(string longName){ - - string rootPathName = longName; - - if(longName.find_last_of("/") != longName.npos){ - int pos = longName.find_last_of('/')+1; - rootPathName = longName.substr(0, pos); - } - - return rootPathName; -} - -/***********************************************************************/ - -inline int openInputFile(string fileName, ifstream& fileHandle){ - - fileHandle.open(fileName.c_str()); - if(!fileHandle) { - cerr << "Error: Could not open " << fileName << endl; - return 1; - } - else { - return 0; - } - -} - -/***********************************************************************/ - -inline int openOutputFile(string fileName, ofstream& fileHandle){ - - fileHandle.open(fileName.c_str(), ios::trunc); - if(!fileHandle) { - cerr << "Error: Could not open " << fileName << endl; - return 1; - } - else { - return 0; - } - -} - -/***********************************************************************/ - -//This function parses the estimator options and puts them in a vector -inline void splitAtDash(string& estim, vector& container) { - try { - string individual; - - while (estim.find_first_of('-') != -1) { - individual = estim.substr(0,estim.find_first_of('-')); - if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string - estim = estim.substr(estim.find_first_of('-')+1, estim.length()); - container.push_back(individual); - } - } - //get last one - container.push_back(estim); - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} - -/***********************************************************************/ -//This function parses the label options and puts them in a set -inline void splitAtDash(string& estim, set& container) { - try { - string individual; - - while (estim.find_first_of('-') != -1) { - individual = estim.substr(0,estim.find_first_of('-')); - if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string - estim = estim.substr(estim.find_first_of('-')+1, estim.length()); - container.insert(individual); - } - } - //get last one - container.insert(estim); - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/***********************************************************************/ -//This function parses the line options and puts them in a set -inline void splitAtDash(string& estim, set& container) { - try { - string individual; - int lineNum; - - while (estim.find_first_of('-') != -1) { - individual = estim.substr(0,estim.find_first_of('-')); - if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string - estim = estim.substr(estim.find_first_of('-')+1, estim.length()); - convert(individual, lineNum); //convert the string to int - container.insert(lineNum); - } - } - //get last one - convert(estim, lineNum); //convert the string to int - container.insert(lineNum); - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtDash. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/***********************************************************************/ -//This function parses the a string and puts peices in a vector -inline void splitAtComma(string& estim, vector& container) { - try { - string individual; - - while (estim.find_first_of(',') != -1) { - individual = estim.substr(0,estim.find_first_of(',')); - if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string - estim = estim.substr(estim.find_first_of(',')+1, estim.length()); - container.push_back(individual); - } - } - //get last one - container.push_back(estim); - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -} -/***********************************************************************/ - -//This function splits up the various option parameters -inline void splitAtComma(string& prefix, string& suffix){ - try { - prefix = suffix.substr(0,suffix.find_first_of(',')); - if ((suffix.find_first_of(',')+2) <= suffix.length()) { //checks to make sure you don't have comma at end of string - suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length()); - string space = " "; - while(suffix.at(0) == ' ') - suffix = suffix.substr(1, suffix.length()); - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtComma. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/***********************************************************************/ - -//This function separates the key value from the option value i.e. dist=96_... -inline void splitAtEquals(string& key, string& value){ - try { - if(value.find_first_of('=') != -1){ - key = value.substr(0,value.find_first_of('=')); - if ((value.find_first_of('=')+1) <= value.length()) { - value = value.substr(value.find_first_of('=')+1, value.length()); - } - }else{ - key = value; - value = 1; - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function splitAtEquals. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/**************************************************************************************************/ - -inline bool inUsersGroups(string groupname, vector Groups) { - try { - for (int i = 0; i < Groups.size(); i++) { - if (groupname == Groups[i]) { return true; } - } - return false; - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the utilities class Function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the utilities class function inUsersGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -} - -#endif diff --git a/validcalculator.cpp b/validcalculator.cpp index a875900..90257c7 100644 --- a/validcalculator.cpp +++ b/validcalculator.cpp @@ -20,6 +20,7 @@ ValidCalculators::ValidCalculators() { initialSharedSummary(); initialVennSingle(); initialVennShared(); + initialTreeGroups(); } 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"; @@ -132,6 +133,18 @@ bool ValidCalculators::isValidCalculator(string parameter, string calculator) { } cout << endl; return false; } + }else if (parameter == "treegroup") { + //is it valid + if ((treegroup.find(calculator)) != (treegroup.end())) { + return true; + }else { + cout << calculator << " is not a valid estimator for the tree.groups command in shared mode and will be disregarded. Valid estimators are "; + for (it = treegroup.begin(); it != treegroup.end(); it++) { + cout << it->first << ", "; + } + cout << endl; + return false; } + //not a valid parameter }else { return false; } @@ -359,6 +372,31 @@ void ValidCalculators::initialVennShared() { } /********************************************************************/ +void ValidCalculators::initialTreeGroups() { + try { + treegroup["sharedjabund"] = "sharedjabund"; + treegroup["sharedsorensonabund"] = "sharedsorensonabund"; + treegroup["sharedjclass"] = "sharedjclass"; + treegroup["sharedsorclass"] = "sharedsorclass"; + treegroup["sharedjest"] = "sharedjest"; + treegroup["sharedsorest"] = "sharedsorest"; + treegroup["sharedthetayc"] = "sharedthetayc"; + treegroup["sharedthetan"] = "sharedthetan"; + treegroup["sharedmorisitahorn"] = "sharedmorisitahorn"; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the ValidCalculator class Function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the ValidCalculator class function initialTreeGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + + +/********************************************************************/ + diff --git a/validcalculator.h b/validcalculator.h index 1c39d49..6cf3792 100644 --- a/validcalculator.h +++ b/validcalculator.h @@ -33,6 +33,7 @@ class ValidCalculators { map sharedsummary; map vennsingle; map vennshared; + map treegroup; map::iterator it; void initialSingle(); @@ -43,7 +44,7 @@ class ValidCalculators { void initialSharedSummary(); void initialVennSingle(); void initialVennShared(); - + void initialTreeGroups(); }; #endif diff --git a/validcommands.cpp b/validcommands.cpp index fed10ca..bc9f62c 100644 --- a/validcommands.cpp +++ b/validcommands.cpp @@ -31,6 +31,7 @@ ValidCommands::ValidCommands() { commands["unifrac.weighted"] = "unifrac.weighted"; commands["unifrac.unweighted"] = "unifrac.unweighted"; commands["libshuff"] = "libshuff"; + commands["tree.groups"] = "tree.groups"; commands["heatmap"] = "heatmap"; commands["venn"] = "venn"; commands["get.group"] = "get.group"; diff --git a/validparameter.cpp b/validparameter.cpp index f4780a7..41ea7cf 100644 --- a/validparameter.cpp +++ b/validparameter.cpp @@ -283,7 +283,7 @@ void ValidParameters::initCommandParameters() { string unifracUnweightedArray[] = {"groups","iters"}; commandParameters["unifrac.unweighted"] = addParameters(unifracUnweightedArray, sizeof(unifracUnweightedArray)/sizeof(string)); - string heatmapArray[] = {"groups","line","label","sorted"}; + string heatmapArray[] = {"groups","line","label","sorted","scaler"}; commandParameters["heatmap"] = addParameters(heatmapArray, sizeof(heatmapArray)/sizeof(string)); string vennArray[] = {"groups","line","label","calc"}; @@ -295,6 +295,9 @@ void ValidParameters::initCommandParameters() { string getOTURepArray[] = {"fasta","list","line","label","name"}; commandParameters["get.oturep"] = addParameters(getOTURepArray, sizeof(getOTURepArray)/sizeof(string)); + string treeGroupsArray[] = {"line","label","calc","groups"}; + commandParameters["tree.groups"] = addParameters(treeGroupsArray, sizeof(treeGroupsArray)/sizeof(string)); + string quitArray[] = {}; commandParameters["quit"] = addParameters(quitArray, sizeof(quitArray)/sizeof(string)); diff --git a/validparameter.h b/validparameter.h index 61b1c5b..30ba461 100644 --- a/validparameter.h +++ b/validparameter.h @@ -12,7 +12,6 @@ using namespace std; #include "mothur.h" -#include "utilities.hpp" //This class contains a list of all valid parameters in Mothur. //It has a function which will tell you if your parameter is valid. diff --git a/venn.cpp b/venn.cpp index 6da78bb..9b3d760 100644 --- a/venn.cpp +++ b/venn.cpp @@ -18,6 +18,7 @@ Venn::Venn(){ try { globaldata = GlobalData::getInstance(); format = globaldata->getFormat(); + util = new SharedUtil(); } catch(exception& e) { cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function Venn. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; @@ -72,7 +73,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { try { //fills vector of sharedsabunds - lookup - getSharedVectors(sharedorder); + util->getSharedVectors(globaldata->Groups, lookup, sharedorder); //fills group vectors from order vector. /******************* 1 Group **************************/ if (lookup.size() == 1) { @@ -82,7 +83,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { //make a file for each calculator for(int i=0;iinputFileName + ".venn." + sharedorder->getLabel() + vCalcs[i]->getName() + "." + groupComb + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); //in essence you want to run it like a single @@ -106,6 +107,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << ""; outsvg << "Venn Diagram at distance " + sharedorder->getLabel() + "\n"; outsvg << ""; + outsvg << "getGroup().length() / 2)) + "\" y=\"165\">" + lookup[0]->getGroup() + "\n"; outsvg << "" + toString(data[0]) + "\n"; if (data.size() == 3) { @@ -129,7 +131,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { //make a file for each calculator for(int i=0;iinputFileName + ".venn." + sharedorder->getLabel() + vCalcs[i]->getName() + "." + groupComb + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); //get estimates for sharedAB @@ -165,11 +167,22 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << ""; outsvg << "" + toString(numA[0] - shared[0]) + "\n"; outsvg << "" + toString(numB[0] - shared[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"175\">" + lookup[0]->getGroup() + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"175\">" + lookup[1]->getGroup() + "\n"; outsvg << "" + toString(shared[0]) + "\n"; - outsvg << "The number of species in group " + globaldata->Groups[0] + " is " + toString(numA[0]) + "\n"; - outsvg << "The number of species in group " + globaldata->Groups[1] + " is " + toString(numB[0]) + "\n"; + outsvg << "The number of species in group " + globaldata->Groups[0] + " is " + toString(numA[0]); + if (numA.size() == 3) { + outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; + }else { outsvg << "\n"; } + + outsvg << "The number of species in group " + globaldata->Groups[1] + " is " + toString(numB[0]); + if (numB.size() == 3) { + outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "\n"; + }else { outsvg << "\n"; } + outsvg << "The number of sepecies shared between groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString(shared[0]) + "\n"; outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))) + "\n"; + outsvg << "The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0])) + "\n"; //close file outsvg << "\n\n"; @@ -190,7 +203,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { //make a file for each calculator for(int i=0;iinputFileName + ".venn." + sharedorder->getLabel() + vCalcs[i]->getName() + "." + groupComb + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn." + vCalcs[i]->getName() + ".svg"; openOutputFile(filenamesvg, outsvg); //get estimates for sharedAB, sharedAC and sharedBC @@ -275,11 +288,14 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << ""; //place labels within overlaps - outsvg << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; + outsvg << "" + toString(numA[0]-sharedAwithBC[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[0]->getGroup() + "\n"; outsvg << "" + toString(sharedAB[0] - sharedABC) + "\n"; - outsvg << "" + toString(numB[0]-sharedBwithAC[0]) + "\n"; + outsvg << "" + toString(numB[0]-sharedBwithAC[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"150\">" + lookup[1]->getGroup() + "\n"; outsvg << "" + toString(sharedAC[0] - sharedABC) + "\n"; - outsvg << "" + toString(numC[0]-sharedCwithAB[0]) + "\n"; + outsvg << "" + toString(numC[0]-sharedCwithAB[0]) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"410\">" + lookup[2]->getGroup() + "\n"; outsvg << "" + toString(sharedBC[0] - sharedABC) + "\n"; outsvg << "" + toString(sharedABC) + "\n"; @@ -289,10 +305,22 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << "The number of sepecies shared between groups " + globaldata->Groups[0] + " and combined groups " + globaldata->Groups[1] + globaldata->Groups[2] + " is " + toString(sharedAwithBC[0]) + "\n"; outsvg << "The number of sepecies shared between groups " + globaldata->Groups[1] + " and combined groups " + globaldata->Groups[0] + globaldata->Groups[2] + " is " + toString(sharedBwithAC[0]) + "\n"; outsvg << "The number of sepecies shared between groups " + globaldata->Groups[2] + " and combined groups " + globaldata->Groups[0] + globaldata->Groups[1] + " is " + toString(sharedCwithAB[0]) + "\n"; - outsvg << "The number of species in group " + globaldata->Groups[0] + " is " + toString(numA[0]) + "\n"; - outsvg << "The number of species in group " + globaldata->Groups[1] + " is " + toString(numB[0]) + "\n"; - outsvg << "The number of species in group " + globaldata->Groups[2] + " is " + toString(numC[0]) + "\n"; - outsvg << "The total number of species in all groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "\n"; + outsvg << "The number of species in group " + globaldata->Groups[0] + " is " + toString(numA[0]); + if (numA.size() == 3) { + outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]) + "\n"; + }else { outsvg << "\n"; } + + outsvg << "The number of species in group " + globaldata->Groups[1] + " is " + toString(numB[0]); + if (numB.size() == 3) { + outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]) + "\n"; + }else { outsvg << "\n"; } + + outsvg << "The number of species in group " + globaldata->Groups[2] + " is " + toString(numC[0]); + if (numC.size() == 3) { + outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]) + "\n"; + }else { outsvg << "\n"; } + + outsvg << "The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "\n"; //close file outsvg << "\n\n"; @@ -335,7 +363,7 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { if ((lookup[0]->getAbundance(i) != 0) && (lookup[1]->getAbundance(i) != 0) && (lookup[2]->getAbundance(i) != 0) && (lookup[3]->getAbundance(i) != 0)) { sharedABCD++; } } - string filenamesvg = globaldata->inputFileName + ".venn." + sharedorder->getLabel() + "." + groupComb + ".svg"; + string filenamesvg = getRootName(globaldata->inputFileName) + sharedorder->getLabel() + ".venn.SharedSobs.svg"; openOutputFile(filenamesvg, outsvg); //image window @@ -353,13 +381,17 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { //A = red, B = green, C = blue, D = yellow //place labels within overlaps - outsvg << "" + toString(numA) + "\n"; + outsvg << "" + toString(numA) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"90\">" + lookup[0]->getGroup() + "\n"; outsvg << "" + toString(sharedAB) + "\n"; outsvg << "" + toString(numB) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"90\">" + lookup[1]->getGroup() + "\n"; outsvg << "" + toString(sharedAC) + "\n"; outsvg << "" + toString(numC) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[2]->getGroup() + "\n"; outsvg << "" + toString(sharedBC) + "\n"; - outsvg << "" + toString(numD) + "\n"; + outsvg << "" + toString(numD) + "\n"; + outsvg << "getGroup().length() / 2)) + "\" y=\"210\">" + lookup[3]->getGroup() + "\n"; outsvg << "" + toString(sharedAD) + "\n"; outsvg << "" + toString(sharedBD) + "\n"; outsvg << "" + toString(sharedCD) + "\n"; @@ -368,8 +400,8 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg << "" + toString(sharedACD) + "\n"; outsvg << "" + toString(sharedABC) + "\n"; outsvg << "" + toString(sharedABCD) + "\n"; + outsvg << "The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD)) + "\n"; - //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[1] + " is " + toString(((sharedAB + sharedABD + sharedABC + sharedABCD) / (float)(numA + numB + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[2] + " is " + toString(((sharedAC + sharedACD + sharedABC + sharedABCD) / (float)(numA + numC + sharedAB + sharedAC + sharedAD + sharedBC + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[0] + " and " + globaldata->Groups[3] + " is " + toString(((sharedAD + sharedACD + sharedABD + sharedABCD) / (float)(numA + numD + sharedAB + sharedAC + sharedAD + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; //outsvg << "Percentage of species that are shared in groups " + globaldata->Groups[1] + " and " + globaldata->Groups[2] + " is " + toString(((sharedBC + sharedABC + sharedBCD + sharedABCD) / (float)(numB + numC + sharedAB + sharedAC + sharedCD + sharedBD + sharedBC + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD))) + "\n"; @@ -385,10 +417,6 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { outsvg.close(); } - - - - } catch(exception& e) { @@ -400,54 +428,5 @@ void Venn::getPic(SharedOrderVector* sharedorder, vector vCalcs) { exit(1); } } -//********************************************************************************************************************** -void Venn::getSharedVectors(SharedOrderVector* order){ - try { - - //delete lookup - for (int j = 0; j < lookup.size(); j++) { - delete lookup[j]; - } - - lookup.clear(); - - groupComb = ""; - - //create and initialize vector of sharedvectors, one for each group - for (int i = 0; i < globaldata->Groups.size(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins()); - temp->setLabel(order->getLabel()); - temp->setGroup(globaldata->Groups[i]); - groupComb += globaldata->Groups[i]; - lookup.push_back(temp); - } - - int numSeqs = order->size(); - //sample all the members - for(int i=0;iget(i); - int abundance; - - //set info for sharedvector in chosens group - for (int j = 0; j < lookup.size(); j++) { - if (chosen.group == lookup[j]->getGroup()) { - abundance = lookup[j]->getAbundance(chosen.bin); - lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); - break; - } - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Venn class Function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Venn class function getSharedVectors. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } -} diff --git a/venn.h b/venn.h index ceb52fd..398f20b 100644 --- a/venn.h +++ b/venn.h @@ -18,6 +18,7 @@ using namespace std; #include "datavector.hpp" #include "globaldata.hpp" #include "calculator.h" +#include "sharedutilities.h" /***********************************************************************/ @@ -31,8 +32,7 @@ class Venn { void getPic(SharedOrderVector*, vector); private: - void getSharedVectors(SharedOrderVector*); - + SharedUtil* util; SAbundVector* sabund; GlobalData* globaldata; vector lookup; diff --git a/venncommand.cpp b/venncommand.cpp index 5628481..e305f22 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -11,7 +11,7 @@ #include "ace.h" #include "sobs.h" #include "chao1.h" -#include "jackknife.h" +//#include "jackknife.h" #include "sharedsobscollectsummary.h" #include "sharedchao1.h" #include "sharedace.h" @@ -24,6 +24,7 @@ VennCommand::VennCommand(){ globaldata = GlobalData::getInstance(); format = globaldata->getFormat(); validCalculator = new ValidCalculators(); + util = new SharedUtil(); int i; @@ -39,8 +40,8 @@ VennCommand::VennCommand(){ if(abund < 5) abund = 10; vennCalculators.push_back(new Ace(abund)); - }else if (globaldata->Estimators[i] == "jack") { - vennCalculators.push_back(new Jackknife()); + //}else if (globaldata->Estimators[i] == "jack") { + //vennCalculators.push_back(new Jackknife()); } } } @@ -80,6 +81,7 @@ VennCommand::~VennCommand(){ delete input; delete read; delete venn; + delete util; } //********************************************************************************************************************** @@ -118,7 +120,8 @@ int VennCommand::execute(){ if (format != "list") { - setGroups(); + util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "venn"); + globaldata->setGroups(""); while(order != NULL){ @@ -145,7 +148,7 @@ int VennCommand::execute(){ } //reset groups parameter - globaldata->Groups.clear(); globaldata->setGroups(""); + globaldata->Groups.clear(); }else{ while(ordersingle != NULL){ @@ -175,67 +178,4 @@ int VennCommand::execute(){ } //********************************************************************************************************************** -void VennCommand::setGroups() { - try { - //if the user has not entered specific groups to analyze then do them all - if (globaldata->Groups.size() != 0) { - if (globaldata->Groups[0] != "all") { - //check that groups are valid - for (int i = 0; i < globaldata->Groups.size(); i++) { - if (globaldata->gGroupmap->isValidGroup(globaldata->Groups[i]) != true) { - cout << globaldata->Groups[i] << " is not a valid group, and will be disregarded." << endl; - // erase the invalid group from globaldata->Groups - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - //if the user only entered invalid groups - if (globaldata->Groups.size() == 0) { - if (globaldata->gGroupmap->namesOfGroups.size() > 4) { - cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using the first four groups in your groupfile." << endl; - for (int i = 0; i < 4; i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - }else { - cout << "When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile." << endl; - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - } - }else{//user has enter "all" and wants the default groups - globaldata->Groups.clear(); - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - globaldata->setGroups(""); - } - }else { - for (int i = 0; i < globaldata->gGroupmap->namesOfGroups.size(); i++) { - globaldata->Groups.push_back(globaldata->gGroupmap->namesOfGroups[i]); - } - } - - - //check to make sure their are only 3 groups - if (globaldata->Groups.size() > 4) { - cout << "You may only use up to 4 groups at a time with this command. I will choose the first four and disregard the rest." << endl; - for (int i = 4; i < globaldata->Groups.size(); i++) { - globaldata->Groups.erase(globaldata->Groups.begin()+i); - } - } - - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the VennCommand class Function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the VennCommand class function setGroups. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - -} -/***********************************************************/ diff --git a/venncommand.h b/venncommand.h index d91aaef..30ff74e 100644 --- a/venncommand.h +++ b/venncommand.h @@ -15,6 +15,7 @@ #include "sharedlistvector.h" #include "venn.h" #include "validcalculator.h" +#include "sharedutilities.h" class GlobalData; @@ -30,6 +31,7 @@ public: private: GlobalData* globaldata; ReadMatrix* read; + SharedUtil* util; InputData* input; SharedListVector* SharedList; SharedOrderVector* order; @@ -39,8 +41,6 @@ private: vector vennCalculators; ValidCalculators* validCalculator; int abund; - - void setGroups(); }; -- 2.39.2