From 38029939675c5bf5e449eac90f801b35064b3a36 Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Fri, 14 Dec 2012 07:37:55 -0500 Subject: [PATCH] added kruskwalliscommand to Xcode project and fixed parameter issues. --- Mothur.xcodeproj/project.pbxproj | 6 +++++ kruskalwalliscommand.cpp | 41 +++++++++++++++----------------- kruskalwalliscommand.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index b689e03..0c8c2dd 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ A73DDBBA13C4A0D1006AAE38 /* clearmemorycommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */; }; A73DDC3813C4BF64006AAE38 /* mothurmetastats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */; }; A741FAD215D1688E0067BCC5 /* sequencecountparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A741FAD115D1688E0067BCC5 /* sequencecountparser.cpp */; }; + A7496D2E167B531B00CC7D7C /* kruskalwalliscommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7496D2C167B531B00CC7D7C /* kruskalwalliscommand.cpp */; }; A74A9A9F148E881E00AB5E3E /* spline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74A9A9E148E881E00AB5E3E /* spline.cpp */; }; A74D36B8137DAFAA00332B0C /* chimerauchimecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74D36B7137DAFAA00332B0C /* chimerauchimecommand.cpp */; }; A74D59A4159A1E2000043046 /* counttable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A74D59A3159A1E2000043046 /* counttable.cpp */; }; @@ -442,6 +443,8 @@ A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurmetastats.cpp; sourceTree = ""; }; A741FAD115D1688E0067BCC5 /* sequencecountparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sequencecountparser.cpp; sourceTree = ""; }; A741FAD415D168A00067BCC5 /* sequencecountparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sequencecountparser.h; sourceTree = ""; }; + A7496D2C167B531B00CC7D7C /* kruskalwalliscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kruskalwalliscommand.cpp; sourceTree = ""; }; + A7496D2D167B531B00CC7D7C /* kruskalwalliscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kruskalwalliscommand.h; sourceTree = ""; }; A74A9A9D148E881E00AB5E3E /* spline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spline.h; sourceTree = ""; }; A74A9A9E148E881E00AB5E3E /* spline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spline.cpp; sourceTree = ""; }; A74D36B6137DAFAA00332B0C /* chimerauchimecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerauchimecommand.h; sourceTree = ""; }; @@ -1385,6 +1388,8 @@ A75790581301749D00A30DAB /* homovacommand.cpp */, A7E9B72C12D37EC400DA6239 /* indicatorcommand.h */, A7E9B72B12D37EC400DA6239 /* indicatorcommand.cpp */, + A7496D2D167B531B00CC7D7C /* kruskalwalliscommand.h */, + A7496D2C167B531B00CC7D7C /* kruskalwalliscommand.cpp */, A7E9B73C12D37EC400DA6239 /* libshuffcommand.h */, A7E9B73B12D37EC400DA6239 /* libshuffcommand.cpp */, A7A0671C156294810095C8C5 /* listotulabelscommand.h */, @@ -2298,6 +2303,7 @@ 83F25B0C163B031200ABE73D /* forest.cpp in Sources */, 834D9D581656D7C400E7FAB9 /* regularizedrandomforest.cpp in Sources */, 834D9D5C1656DEC800E7FAB9 /* regularizeddecisiontree.cpp in Sources */, + A7496D2E167B531B00CC7D7C /* kruskalwalliscommand.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/kruskalwalliscommand.cpp b/kruskalwalliscommand.cpp index 474e82c..b321f13 100644 --- a/kruskalwalliscommand.cpp +++ b/kruskalwalliscommand.cpp @@ -10,10 +10,10 @@ //********************************************************************************************************************** vector KruskalWallisCommand::setParameters(){ try { - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false,true); parameters.push_back(pgroups); + CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","summary",false,true,true); parameters.push_back(pshared); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -38,24 +38,19 @@ string KruskalWallisCommand::getHelpString(){ } } //********************************************************************************************************************** -string KruskalWallisCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string KruskalWallisCommand::getOutputPattern(string type) { + try { + string pattern = ""; - //is this a type this command creates - it = outputTypes.find(type); - if (it == outputTypes.end()) { m->mothurOut("[ERROR]: this command doesn't create a " + type + " output file.\n"); } - else { - if (type == "summary") { outputFileName = "cooccurence.summary"; } - else { m->mothurOut("[ERROR]: No definition for type " + type + " output file tag.\n"); m->control_pressed = true; } - } - return outputFileName; - } - catch(exception& e) { - m->errorOut(e, "KruskalWallisCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "summary") { pattern = "[filename],cooccurence.summary"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "KruskalWallisCommand", "getOutputPattern"); + exit(1); + } } //********************************************************************************************************************** KruskalWallisCommand::KruskalWallisCommand(){ @@ -155,7 +150,9 @@ int KruskalWallisCommand::execute(){ set userLabels = labels; ofstream out; - string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + getOutputFileNameTag("summary"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(sharedfile)); + string outputFileName = getOutputFileName("summary",variables); m->openOutputFile(outputFileName, out); outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint); diff --git a/kruskalwalliscommand.h b/kruskalwalliscommand.h index da1166e..feefebd 100644 --- a/kruskalwalliscommand.h +++ b/kruskalwalliscommand.h @@ -24,7 +24,7 @@ public: vector setParameters(); string getCommandName() { return "kruskalwallis"; } string getCommandCategory() { return "Hypothesis Testing"; } - string getOutputFileNameTag(string, string); + string getOutputPattern(string); string getHelpString(); string getCitation() { return "http://www.mothur.org/wiki/kruskalwallis"; } string getDescription() { return "Non-parametric method for testing whether samples originate from the same distribution."; } -- 2.39.2