X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=collectsharedcommand.cpp;h=dd1ec270334e09f1d316ce060c2ab8c185e0d313;hp=0fe4d0f239fad770e83b68cee3f68eb9630aa368;hb=d1c97b8c04bb75faca1e76ffad60b37a4d789d3d;hpb=ca9ac1d80c62f57270b0dcd49410ebe08a8aecd6 diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 0fe4d0f..dd1ec27 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -54,14 +54,14 @@ //********************************************************************************************************************** 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-skulczynski-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", "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 +89,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\n"; + helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n"; return helpString; } catch(exception& e) { @@ -97,6 +97,60 @@ 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 { 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 { @@ -119,7 +173,7 @@ CollectSharedCommand::CollectSharedCommand(){ outputTypes["sharednseqs"] = tempOutNames; outputTypes["ochiai"] = tempOutNames; outputTypes["anderberg"] = tempOutNames; - outputTypes["skulczynski"] = tempOutNames; + outputTypes["kulczynski"] = tempOutNames; outputTypes["kulczynskicody"] = tempOutNames; outputTypes["lennon"] = tempOutNames; outputTypes["morisitahorn"] = tempOutNames; @@ -157,6 +211,7 @@ CollectSharedCommand::CollectSharedCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { vector myArray = setParameters(); @@ -190,7 +245,7 @@ CollectSharedCommand::CollectSharedCommand(string option) { outputTypes["sharednseqs"] = tempOutNames; outputTypes["ochiai"] = tempOutNames; outputTypes["anderberg"] = tempOutNames; - outputTypes["skulczynski"] = tempOutNames; + outputTypes["kulczynski"] = tempOutNames; outputTypes["kulczynskicody"] = tempOutNames; outputTypes["lennon"] = tempOutNames; outputTypes["morisitahorn"] = tempOutNames; @@ -237,7 +292,7 @@ CollectSharedCommand::CollectSharedCommand(string option) { sharedfile = m->getSharedFile(); if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; } - } + }else { m->setSharedFile(sharedfile); } //if the user changes the output directory command factory will send this info to us in the output parameter @@ -258,17 +313,22 @@ CollectSharedCommand::CollectSharedCommand(string option) { if (calc == "default") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan"; } } m->splitAtDash(calc, Estimators); + if (m->inUsersGroups("citation", Estimators)) { + ValidCalculators validCalc; validCalc.printCitations(Estimators); + //remove citation from list of calcs + for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") { Estimators.erase(Estimators.begin()+i); break; } } + } groups = validParameter.validFile(parameters, "groups", false); if (groups == "not found") { groups = ""; } else { m->splitAtDash(groups, Groups); } - m->Groups = Groups; + m->setGroups(Groups); 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); @@ -276,128 +336,130 @@ 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; isetGroups(m->Groups, m->namesOfGroups, "collect"); + Groups = m->getGroups(); + vector allGroups = m->getAllGroups(); + util->setGroups(Groups, allGroups, "collect"); + m->setGroups(Groups); + m->setAllGroups(allGroups); delete util; while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) { if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;iGroups.clear(); + m->clearGroups(); return 0; } @@ -487,9 +553,9 @@ int CollectSharedCommand::execute(){ } if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;iGroups.clear(); + m->clearGroups(); delete input; return 0; } @@ -518,11 +584,11 @@ int CollectSharedCommand::execute(){ delete cCurve; if (m->control_pressed) { - for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } outputTypes.clear(); + for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for(int i=0;iGroups.clear(); + m->clearGroups(); return 0; } @@ -532,7 +598,7 @@ int CollectSharedCommand::execute(){ for(int i=0;iGroups.clear(); + m->clearGroups(); delete input; m->mothurOutEndLine();