X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=rarefactsharedcommand.cpp;h=64b40aad41b9fb520892cab6969c98fa0a83a80d;hp=6451041461a21255ff929feba717a0fd02fd96fa;hb=df7e3ff9f68ef157b0328a2d353c3258c5d45d89;hpb=f06b339c5fc4b6d1b9d2a08fe16bf7670bf7aeb4 diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 6451041..64b40aa 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -16,20 +16,20 @@ //********************************************************************************************************************** vector RareFactSharedCommand::setParameters(){ try { - CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared); - CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pdesign); - CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel); - CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq); - CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters); - CommandParameter pcalc("calc", "Multiple", "sharednseqs-sharedobserved", "sharedobserved", "", "", "",true,false); parameters.push_back(pcalc); - CommandParameter psubsampleiters("subsampleiters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(psubsampleiters); - CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample); - CommandParameter pjumble("jumble", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pjumble); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets); - CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode); - 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 pdesign("design", "InputTypes", "", "", "none", "none", "none","",false,false); parameters.push_back(pdesign); + CommandParameter plabel("label", "String", "", "", "", "", "","",false,false); parameters.push_back(plabel); + CommandParameter pfreq("freq", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pfreq); + CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters); + CommandParameter pcalc("calc", "Multiple", "sharednseqs-sharedobserved", "sharedobserved", "", "", "","",true,false,true); parameters.push_back(pcalc); + CommandParameter psubsampleiters("subsampleiters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(psubsampleiters); + CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample); + CommandParameter pjumble("jumble", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pjumble); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + CommandParameter psets("sets", "String", "", "", "", "", "","",false,false); parameters.push_back(psets); + CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pgroupmode); + 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); } @@ -68,25 +68,20 @@ string RareFactSharedCommand::getHelpString(){ } } //********************************************************************************************************************** -string RareFactSharedCommand::getOutputFileNameTag(string type, string inputName=""){ - try { - string outputFileName = ""; - map >::iterator it; +string RareFactSharedCommand::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 == "sharedrarefaction") { outputFileName = "shared.rarefaction"; } - else if (type == "sharedr_nseqs") { outputFileName = "shared.r_nseqs"; } - 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, "RareFactSharedCommand", "getOutputFileNameTag"); - exit(1); - } + if (type == "sharedrarefaction") { pattern = "[filename],shared.rarefaction"; } + else if (type == "sharedr_nseqs") { pattern = "[filename],shared.r_nseqs"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "RareFactSharedCommand", "getOutputPattern"); + exit(1); + } } //********************************************************************************************************************** RareFactSharedCommand::RareFactSharedCommand(){ @@ -346,16 +341,18 @@ int RareFactSharedCommand::process(GroupMap& designMap, string thisSet){ if (subset.size() < 2) { m->mothurOut("You have not provided enough valid groups. I cannot run the command."); m->mothurOutEndLine(); m->control_pressed = true; return 0; } } /******************************************************/ - + + map variables; + variables["[filename]"] = fileNameRoot; ValidCalculators validCalculator; for (int i=0; i& thisLook string thisfileNameRoot = fileNameRoot + toString(thisIter); + map variables; + variables["[filename]"] = thisfileNameRoot; + ValidCalculators validCalculator; for (int i=0; i& thisLook if (!m->control_pressed) { //process results - string outputFile = fileNameRoot + "ave-std." + thisLookup[0]->getLabel() + "." + getOutputFileNameTag(it->first); + map variables; variables["[filename]"] = fileNameRoot + "ave-std." + thisLookup[0]->getLabel() + "."; + + string outputFile = getOutputFileName(it->first,variables); ofstream out; m->openOutputFile(outputFile, out); outputNames.push_back(outputFile); outputTypes[it->first].push_back(outputFile);