X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=collectsharedcommand.cpp;h=966cc253552068ad1945a19e1aaaedfd9b3da506;hp=a5721b0a528b563c881a8815e74b6a7fd25a0299;hb=b206f634aae1b4ce13978d203247fb64757d5482;hpb=55386dddad84cc1140d736cabaf4dd0ae16f2e01 diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index a5721b0..966cc25 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -49,19 +49,21 @@ #include "memchord.h" #include "memeuclidean.h" #include "mempearson.h" +#include "sharedjsd.h" +#include "sharedrjsd.h" //********************************************************************************************************************** vector CollectSharedCommand::setParameters(){ try { - CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); - CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq); - CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc); - CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none","",false,true,true); parameters.push_back(pshared); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); + CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq); + CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson-jsd-rjsd", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "","",true,false,true); parameters.push_back(pcalc); + CommandParameter pall("all", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pall); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir); + CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir); vector myArray; for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); } @@ -89,7 +91,7 @@ string CollectSharedCommand::getHelpString(){ helpString += "The all parameter is used to specify if you want the estimate of all your groups together. This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n"; helpString += "If you use sharedchao and run into memory issues, set all to false. \n"; helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. You must enter at least 2 valid groups.\n"; - helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n"; + helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedfile).\n"; return helpString; } catch(exception& e) { @@ -97,6 +99,62 @@ string CollectSharedCommand::getHelpString(){ exit(1); } } +//********************************************************************************************************************** +string CollectSharedCommand::getOutputPattern(string type) { + try { + string pattern = ""; + + if (type == "sharedchao") { pattern = "[filename],shared.chao"; } + else if (type == "sharedsobs") { pattern = "[filename],shared.sobs"; } + else if (type == "sharedace") { pattern = "[filename],shared.ace"; } + else if (type == "jabund") { pattern = "[filename],jabund"; } + else if (type == "sorabund") { pattern = "[filename],sorabund"; } + else if (type == "jclass") { pattern = "[filename],jclass"; } + else if (type == "sorclass") { pattern = "[filename],sorclass"; } + else if (type == "jest") { pattern = "[filename],jest"; } + else if (type == "sorest") { pattern = "[filename],sorest"; } + else if (type == "thetayc") { pattern = "[filename],thetayc"; } + else if (type == "thetan") { pattern = "[filename],thetan"; } + else if (type == "kstest") { pattern = "[filename],kstest"; } + else if (type == "whittaker") { pattern = "[filename],whittaker"; } + else if (type == "sharednseqs") { pattern = "[filename],shared.nseqs"; } + else if (type == "ochiai") { pattern = "[filename],ochiai"; } + else if (type == "anderberg") { pattern = "[filename],anderberg"; } + else if (type == "kulczynski") { pattern = "[filename],kulczynski"; } + else if (type == "kulczynskicody") { pattern = "[filename],kulczynskicody"; } + else if (type == "lennon") { pattern = "[filename],lennon"; } + else if (type == "morisitahorn") { pattern = "[filename],morisitahorn"; } + else if (type == "braycurtis") { pattern = "[filename],braycurtis"; } + else if (type == "odum") { pattern = "[filename],odum"; } + else if (type == "canberra") { pattern = "[filename],canberra"; } + else if (type == "structeuclidean") { pattern = "[filename],structeuclidean"; } + else if (type == "structchord") { pattern = "[filename],structchord"; } + else if (type == "hellinger") { pattern = "[filename],hellinger"; } + else if (type == "manhattan") { pattern = "[filename],manhattan"; } + else if (type == "structpearson") { pattern = "[filename],structpearson"; } + else if (type == "soergel") { pattern = "[filename],soergel"; } + else if (type == "spearman") { pattern = "[filename],spearman"; } + else if (type == "structkulczynski") { pattern = "[filename],structkulczynski";} + else if (type == "structchi2") { pattern = "[filename],structchi2"; } + else if (type == "speciesprofile") { pattern = "[filename],speciesprofile"; } + else if (type == "hamming") { pattern = "[filename],hamming"; } + else if (type == "gower") { pattern = "[filename],gower"; } + else if (type == "memchi2") { pattern = "[filename],memchi2"; } + else if (type == "memchord") { pattern = "[filename],memchord"; } + else if (type == "memeuclidean") { pattern = "[filename],memeuclidean"; } + else if (type == "mempearson") { pattern = "[filename],mempearson"; } + else if (type == "jsd") { pattern = "[filename],jsd"; } + else if (type == "rjsd") { pattern = "[filename],rjsd"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "CollectSharedCommand", "getOutputPattern"); + exit(1); + } +} + //********************************************************************************************************************** CollectSharedCommand::CollectSharedCommand(){ try { @@ -142,6 +200,8 @@ CollectSharedCommand::CollectSharedCommand(){ outputTypes["memchord"] = tempOutNames; outputTypes["memeuclidean"] = tempOutNames; outputTypes["mempearson"] = tempOutNames; + outputTypes["jsd"] = tempOutNames; + outputTypes["rjsd"] = tempOutNames; } catch(exception& e) { @@ -214,6 +274,8 @@ CollectSharedCommand::CollectSharedCommand(string option) { outputTypes["memchord"] = tempOutNames; outputTypes["memeuclidean"] = tempOutNames; outputTypes["mempearson"] = tempOutNames; + outputTypes["jsd"] = tempOutNames; + outputTypes["rjsd"] = tempOutNames; //if the user changes the input directory command factory will send this info to us in the output parameter @@ -274,7 +336,7 @@ CollectSharedCommand::CollectSharedCommand(string option) { string temp; temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; } - convert(temp, freq); + m->mothurConvert(temp, freq); temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; } all = m->isTrue(temp); @@ -282,129 +344,138 @@ CollectSharedCommand::CollectSharedCommand(string option) { if (abort == false) { string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(sharedfile)); - + map variables; + variables["[filename]"] = fileNameRoot; + ValidCalculators validCalculator; for (int i=0; i