X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=collectsharedcommand.cpp;h=baebeb16298b28c3cd6372fe06a2de547e7bfbdc;hb=d71a31a60542608595ce1278cc4a3398479cec7f;hp=46f49b28f7b2de79b6525c05b2110325684194da;hpb=8f7f4fc08b8c70d9ef0f79607813dba4e926e102;p=mothur.git diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 46f49b2..baebeb1 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -57,7 +57,7 @@ vector CollectSharedCommand::setParameters(){ 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 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); @@ -98,6 +98,64 @@ string CollectSharedCommand::getHelpString(){ } } //********************************************************************************************************************** +string CollectSharedCommand::getOutputFileNameTag(string type, string inputName=""){ + try { + string outputFileName = ""; + map >::iterator it; + + //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 == "sharedchao") { outputFileName = "shared.chao"; } + else if (type == "sharedsobs") { outputFileName = "shared.sobs"; } + else if (type == "sharedace") { outputFileName = "shared.ace"; } + else if (type == "jabund") { outputFileName = "jabund"; } + else if (type == "sorabund") { outputFileName = "sorabund"; } + else if (type == "jclass") { outputFileName = "jclass"; } + else if (type == "sorclass") { outputFileName = "sorclass"; } + else if (type == "jest") { outputFileName = "jest"; } + else if (type == "sorest") { outputFileName = "sorest"; } + else if (type == "thetayc") { outputFileName = "thetayc"; } + else if (type == "thetan") { outputFileName = "thetan"; } + else if (type == "kstest") { outputFileName = "kstest"; } + else if (type == "whittaker") { outputFileName = "whittaker"; } + else if (type == "sharednseqs") { outputFileName = "shared.nseqs"; } + else if (type == "ochiai") { outputFileName = "ochiai"; } + else if (type == "anderberg") { outputFileName = "anderberg"; } + else if (type == "kulczynski") { outputFileName = "kulczynski"; } + else if (type == "kulczynskicody") { outputFileName = "kulczynskicody"; } + else if (type == "lennon") { outputFileName = "lennon"; } + else if (type == "morisitahorn") { outputFileName = "morisitahorn"; } + else if (type == "braycurtis") { outputFileName = "braycurtis"; } + else if (type == "odum") { outputFileName = "odum"; } + else if (type == "canberra") { outputFileName = "canberra"; } + else if (type == "structeuclidean") { outputFileName = "structeuclidean"; } + else if (type == "structchord") { outputFileName = "structchord"; } + else if (type == "hellinger") { outputFileName = "hellinger"; } + else if (type == "manhattan") { outputFileName = "manhattan"; } + else if (type == "structpearson") { outputFileName = "structpearson"; } + else if (type == "soergel") { outputFileName = "soergel"; } + else if (type == "spearman") { outputFileName = "spearman"; } + else if (type == "structkulczynski") { outputFileName = "structkulczynski";} + else if (type == "structchi2") { outputFileName = "structchi2"; } + else if (type == "speciesprofile") { outputFileName = "speciesprofile"; } + else if (type == "hamming") { outputFileName = "hamming"; } + else if (type == "gower") { outputFileName = "gower"; } + else if (type == "memchi2") { outputFileName = "memchi2"; } + else if (type == "memchord") { outputFileName = "memchord"; } + else if (type == "memeuclidean") { outputFileName = "memeuclidean"; } + else if (type == "mempearson") { outputFileName = "mempearson"; } + 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, "CollectSharedCommand", "getOutputFileNameTag"); + exit(1); + } +} +//********************************************************************************************************************** CollectSharedCommand::CollectSharedCommand(){ try { abort = true; calledHelp = true; @@ -119,7 +177,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; @@ -191,7 +249,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; @@ -238,7 +296,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 @@ -270,11 +328,11 @@ CollectSharedCommand::CollectSharedCommand(string option) { 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); @@ -288,122 +346,122 @@ CollectSharedCommand::CollectSharedCommand(string option) { 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; } @@ -493,9 +555,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; } @@ -524,11 +586,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; } @@ -538,7 +600,7 @@ int CollectSharedCommand::execute(){ for(int i=0;iGroups.clear(); + m->clearGroups(); delete input; m->mothurOutEndLine();