X-Git-Url: https://git.donarmstrong.com/?p=mothur.git;a=blobdiff_plain;f=unifracunweightedcommand.cpp;h=272ae8255b6566e0f2c0ff04489580a9a36acdfd;hp=0749cb79ff41e03c55ca2a9defeb1b70e44645d8;hb=615301e57c25e241356a9c2380648d117709458d;hpb=2ecee16fec29d4c525f740ec19b27962ca09c050 diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp index 0749cb7..272ae82 100644 --- a/unifracunweightedcommand.cpp +++ b/unifracunweightedcommand.cpp @@ -15,19 +15,20 @@ //********************************************************************************************************************** vector UnifracUnweightedCommand::setParameters(){ try { - CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree); - CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup); - CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname); - CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups); - CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters); - CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors); - CommandParameter prandom("random", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prandom); - CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "",false,false); parameters.push_back(pdistance); - CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample); - CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pconsensus); - CommandParameter proot("root", "Boolean", "F", "", "", "", "",false,false); parameters.push_back(proot); - CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir); - CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir); + CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none","unweighted-uwsummary",false,true,true); parameters.push_back(ptree); + CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "none","",false,false,true); parameters.push_back(pname); + CommandParameter pcount("count", "InputTypes", "", "", "NameCount-CountGroup", "none", "none","",false,false,true); parameters.push_back(pcount); + CommandParameter pgroup("group", "InputTypes", "", "", "CountGroup", "none", "none","",false,false,true); parameters.push_back(pgroup); + CommandParameter pgroups("groups", "String", "", "", "", "", "","",false,false); parameters.push_back(pgroups); + CommandParameter piters("iters", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(piters); + CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors); + CommandParameter prandom("random", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(prandom); + CommandParameter pdistance("distance", "Multiple", "column-lt-square-phylip", "column", "", "", "","phylip-column",false,false); parameters.push_back(pdistance); + CommandParameter psubsample("subsample", "String", "", "", "", "", "","",false,false); parameters.push_back(psubsample); + CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "","tree",false,false); parameters.push_back(pconsensus); + CommandParameter proot("root", "Boolean", "F", "", "", "", "","",false,false); parameters.push_back(proot); + 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); } @@ -42,7 +43,7 @@ vector UnifracUnweightedCommand::setParameters(){ string UnifracUnweightedCommand::getHelpString(){ try { string helpString = ""; - helpString += "The unifrac.unweighted command parameters are tree, group, name, groups, iters, distance, processors, root and random. tree parameter is required unless you have valid current tree file.\n"; + helpString += "The unifrac.unweighted command parameters are tree, group, name, count, groups, iters, distance, processors, root and random. tree parameter is required unless you have valid current tree file.\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 1 valid group.\n"; helpString += "The group names are separated by dashes. The iters parameter allows you to specify how many random trees you would like compared to your tree.\n"; helpString += "The distance parameter allows you to create a distance file from the results. The default is false. You may set distance to lt, square or column.\n"; @@ -64,30 +65,23 @@ string UnifracUnweightedCommand::getHelpString(){ } } //********************************************************************************************************************** -string UnifracUnweightedCommand::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 == "unweighted") { outputFileName = "unweighted"; } - else if (type == "uwsummary") { outputFileName = "uwsummary"; } - else if (type == "phylip") { outputFileName = "dist"; } - else if (type == "column") { outputFileName = "dist"; } - else if (type == "tree") { outputFileName = "tre"; } - 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, "UnifracUnweightedCommand", "getOutputFileNameTag"); - exit(1); - } +string UnifracUnweightedCommand::getOutputPattern(string type) { + try { + string pattern = ""; + if (type == "unweighted") { pattern = "[filename],unweighted-[filename],[tag],unweighted"; } + else if (type == "uwsummary") { pattern = "[filename],uwsummary"; } + else if (type == "phylip") { pattern = "[filename],[tag],[tag2],dist"; } + else if (type == "column") { pattern = "[filename],[tag],[tag2],dist"; } + else if (type == "tree") { pattern = "[filename],[tag],[tag2],tre"; } + else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->control_pressed = true; } + + return pattern; + } + catch(exception& e) { + m->errorOut(e, "UnifracUnweightedCommand", "getOutputPattern"); + exit(1); + } } - //********************************************************************************************************************** UnifracUnweightedCommand::UnifracUnweightedCommand(){ try { @@ -165,6 +159,14 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { //if the user has not given a path then, add inputdir. else leave path alone. if (path == "") { parameters["name"] = inputDir + it->second; } } + + it = parameters.find("count"); + //user has given a template file + if(it != parameters.end()){ + path = m->hasPath(it->second); + //if the user has not given a path then, add inputdir. else leave path alone. + if (path == "") { parameters["count"] = inputDir + it->second; } + } } //check for required parameters @@ -186,6 +188,19 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { if (namefile == "not open") { namefile = ""; abort = true; } else if (namefile == "not found") { namefile = ""; } else { m->setNameFile(namefile); } + + countfile = validParameter.validFile(parameters, "count", true); + if (countfile == "not open") { countfile = ""; abort = true; } + else if (countfile == "not found") { countfile = ""; } + else { m->setCountTableFile(countfile); } + + if ((namefile != "") && (countfile != "")) { + m->mothurOut("[ERROR]: you may only use one of the following: name or count."); m->mothurOutEndLine(); abort = true; + } + + if ((groupfile != "") && (countfile != "")) { + m->mothurOut("[ERROR]: you may only use one of the following: group or count."); m->mothurOutEndLine(); abort=true; + } outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(treefile); } @@ -233,7 +248,13 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { consensus = m->isTrue(temp); if (subsample && random) { m->mothurOut("[ERROR]: random must be false, if subsample=t.\n"); abort=true; } - if (subsample && (groupfile == "")) { m->mothurOut("[ERROR]: if subsample=t, a group file must be provided.\n"); abort=true; } + if (countfile == "") { if (subsample && (groupfile == "")) { m->mothurOut("[ERROR]: if subsample=t, a group file must be provided.\n"); abort=true; } } + else { + CountTable testCt; + if ((!testCt.testGroups(countfile)) && (subsample)) { + m->mothurOut("[ERROR]: if subsample=t, a count file with group info must be provided.\n"); abort=true; + } + } if (subsample && (!phylip)) { phylip=true; outputForm = "lt"; } if (consensus && (!subsample)) { m->mothurOut("[ERROR]: you cannot use consensus without subsample.\n"); abort=true; } @@ -246,10 +267,12 @@ UnifracUnweightedCommand::UnifracUnweightedCommand(string option) { m->setGroups(Groups); } - if (namefile == "") { - vector files; files.push_back(treefile); - parser.getNameFile(files); - } + if (countfile=="") { + if (namefile == "") { + vector files; files.push_back(treefile); + parser.getNameFile(files); + } + } } } @@ -267,20 +290,22 @@ int UnifracUnweightedCommand::execute() { m->setTreeFile(treefile); - TreeReader* reader = new TreeReader(treefile, groupfile, namefile); + TreeReader* reader; + if (countfile == "") { reader = new TreeReader(treefile, groupfile, namefile); } + else { reader = new TreeReader(treefile, countfile); } T = reader->getTrees(); - tmap = T[0]->getTreeMap(); - map nameMap = reader->getNames(); - map unique2Dup = reader->getNameMap(); - delete reader; + ct = T[0]->getCountTable(); + delete reader; - sumFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + getOutputFileNameTag("uwsummary"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile)); + sumFile = getOutputFileName("uwsummary",variables); outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile); m->openOutputFile(sumFile, outSum); SharedUtil util; Groups = m->getGroups(); - vector namesGroups = tmap->getNamesOfGroups(); + vector namesGroups = ct->getNamesOfGroups(); util.setGroups(Groups, namesGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze Unweighted unweighted(includeRoot); @@ -292,10 +317,9 @@ int UnifracUnweightedCommand::execute() { //user has not set size, set size = smallest samples size if (subsampleSize == -1) { vector temp; temp.push_back(Groups[0]); - subsampleSize = (tmap->getNamesSeqs(temp)).size(); //num in first group + subsampleSize = ct->getGroupCount(Groups[0]); //num in first group for (int i = 1; i < Groups.size(); i++) { - temp.clear(); temp.push_back(Groups[i]); - int thisSize = (tmap->getNamesSeqs(temp)).size(); + int thisSize = ct->getGroupCount(Groups[i]); if (thisSize < subsampleSize) { subsampleSize = thisSize; } } m->mothurOut("\nSetting subsample size to " + toString(subsampleSize) + ".\n\n"); @@ -303,9 +327,7 @@ int UnifracUnweightedCommand::execute() { vector newGroups = Groups; Groups.clear(); for (int i = 0; i < newGroups.size(); i++) { - vector thisGroup; thisGroup.push_back(newGroups[i]); - vector thisGroupsSeqs = tmap->getNamesSeqs(thisGroup); - int thisSize = thisGroupsSeqs.size(); + int thisSize = ct->getGroupCount(newGroups[i]); if (thisSize >= subsampleSize) { Groups.push_back(newGroups[i]); } else { m->mothurOut("You have selected a size that is larger than "+newGroups[i]+" number of sequences, removing "+newGroups[i]+".\n"); } @@ -330,14 +352,16 @@ int UnifracUnweightedCommand::execute() { //get pscores for users trees for (int i = 0; i < T.size(); i++) { - if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } + if (m->control_pressed) { delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; }outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } counter = 0; if (random) { - output = new ColumnFile(outputDir + m->getSimpleName(treefile) + toString(i+1) + "." + getOutputFileNameTag("unweighted"), itersString); - outputNames.push_back(outputDir + m->getSimpleName(treefile) + toString(i+1) + "." + getOutputFileNameTag("unweighted")); - outputTypes["unweighted"].push_back(outputDir + m->getSimpleName(treefile) + toString(i+1) + "." + getOutputFileNameTag("unweighted")); + variables["[filename]"] = outputDir + m->getSimpleName(treefile); + variables["[tag]"] = toString(i+1); + string unFileName = getOutputFileName("unweighted", variables); + output = new ColumnFile(unFileName, itersString); + outputNames.push_back(unFileName); outputTypes["unweighted"].push_back(unFileName); } @@ -351,7 +375,7 @@ int UnifracUnweightedCommand::execute() { userData = unweighted.getValues(T[i], processors, outputDir); //userData[0] = unweightedscore - if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }return 0; } + if (m->control_pressed) { delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }return 0; } //output scores for each combination for(int k = 0; k < numComp; k++) { @@ -366,7 +390,7 @@ int UnifracUnweightedCommand::execute() { if (random) { runRandomCalcs(T[i], userData); } - if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } + if (m->control_pressed) { delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } int startSubsample = time(NULL); @@ -376,32 +400,32 @@ int UnifracUnweightedCommand::execute() { if (m->control_pressed) { break; } //copy to preserve old one - would do this in subsample but memory cleanup becomes messy. - TreeMap* newTmap = new TreeMap(); - //newTmap->getCopy(*tmap); - - //SubSample sample; - //Tree* subSampleTree = sample.getSample(T[i], newTmap, nameMap, subsampleSize); - + CountTable* newCt = new CountTable(); + //uses method of setting groups to doNotIncludeMe + int sampleTime = 0; + if (m->debug) { sampleTime = time(NULL); } SubSample sample; - Tree* subSampleTree = sample.getSample(T[i], tmap, newTmap, subsampleSize, unique2Dup); + Tree* subSampleTree = sample.getSample(T[i], ct, newCt, subsampleSize); + + if (m->debug) { m->mothurOut("[DEBUG]: iter " + toString(thisIter) + " took " + toString(time(NULL) - sampleTime) + " seconds to sample tree.\n"); } //call new weighted function vector iterData; iterData.resize(numComp,0); Unweighted thisUnweighted(includeRoot); iterData = thisUnweighted.getValues(subSampleTree, processors, outputDir); //userData[0] = weightedscore - + //save data to make ave dist, std dist calcDistsTotals.push_back(iterData); - delete newTmap; + delete newCt; delete subSampleTree; - if((thisIter+1) % 100 == 0){ m->mothurOut(toString(thisIter+1)); m->mothurOutEndLine(); } + if((thisIter+1) % 100 == 0){ m->mothurOutJustToScreen(toString(thisIter+1)+"\n"); } } - m->mothurOut("It took " + toString(time(NULL) - startSubsample) + " secs to run the subsampling."); m->mothurOutEndLine(); + if (subsample) { m->mothurOut("It took " + toString(time(NULL) - startSubsample) + " secs to run the subsampling."); m->mothurOutEndLine(); } - if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } + if (m->control_pressed) { delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (subsample) { getAverageSTDMatrices(calcDistsTotals, i); } if (consensus) { getConsensusTrees(calcDistsTotals, i); } @@ -420,7 +444,7 @@ int UnifracUnweightedCommand::execute() { outSum.close(); - delete tmap; + delete ct; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -457,43 +481,31 @@ int UnifracUnweightedCommand::execute() { int UnifracUnweightedCommand::getAverageSTDMatrices(vector< vector >& dists, int treeNum) { try { //we need to find the average distance and standard deviation for each groups distance - //finds sum - vector averages; averages.resize(numComp, 0); - for (int thisIter = 0; thisIter < subsampleIters; thisIter++) { - for (int i = 0; i < dists[thisIter].size(); i++) { - averages[i] += dists[thisIter][i]; - } - } - - //finds average. - for (int i = 0; i < averages.size(); i++) { averages[i] /= (float) subsampleIters; } + vector averages = m->getAverages(dists); //find standard deviation - vector stdDev; stdDev.resize(numComp, 0); - - for (int thisIter = 0; thisIter < iters; thisIter++) { //compute the difference of each dist from the mean, and square the result of each - for (int j = 0; j < dists[thisIter].size(); j++) { - stdDev[j] += ((dists[thisIter][j] - averages[j]) * (dists[thisIter][j] - averages[j])); - } - } - for (int i = 0; i < stdDev.size(); i++) { - stdDev[i] /= (float) subsampleIters; - stdDev[i] = sqrt(stdDev[i]); - } + vector stdDev = m->getStandardDeviation(dists, averages); //make matrix with scores in it - vector< vector > avedists; avedists.resize(m->getNumGroups()); + vector< vector > avedists; //avedists.resize(m->getNumGroups()); for (int i = 0; i < m->getNumGroups(); i++) { - avedists[i].resize(m->getNumGroups(), 0.0); + vector temp; + for (int j = 0; j < m->getNumGroups(); j++) { temp.push_back(0.0); } + avedists.push_back(temp); } //make matrix with scores in it - vector< vector > stddists; stddists.resize(m->getNumGroups()); + vector< vector > stddists; //stddists.resize(m->getNumGroups()); for (int i = 0; i < m->getNumGroups(); i++) { - stddists[i].resize(m->getNumGroups(), 0.0); + vector temp; + for (int j = 0; j < m->getNumGroups(); j++) { temp.push_back(0.0); } + //stddists[i].resize(m->getNumGroups(), 0.0); + stddists.push_back(temp); } + if (m->debug) { m->mothurOut("[DEBUG]: about to fill matrix.\n"); } + //flip it so you can print it int count = 0; for (int r=0; rgetNumGroups(); r++) { @@ -506,13 +518,20 @@ int UnifracUnweightedCommand::getAverageSTDMatrices(vector< vector >& di } } - string aveFileName = outputDir + m->getSimpleName(treefile) + toString(treeNum+1) + ".unweighted.ave." + getOutputFileNameTag("phylip"); + if (m->debug) { m->mothurOut("[DEBUG]: done filling matrix.\n"); } + + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile)); + variables["[tag]"] = toString(treeNum+1); + variables["[tag2]"] = "unweighted.ave"; + string aveFileName = getOutputFileName("phylip",variables); if (outputForm != "column") { outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName); } else { outputNames.push_back(aveFileName); outputTypes["column"].push_back(aveFileName); } ofstream out; m->openOutputFile(aveFileName, out); - string stdFileName = outputDir + m->getSimpleName(treefile) + toString(treeNum+1) + ".unweighted.std." + getOutputFileNameTag("phylip"); + variables["[tag2]"] = "unweighted.std"; + string stdFileName = getOutputFileName("phylip",variables); if (outputForm != "column") { outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); } else { outputNames.push_back(stdFileName); outputTypes["column"].push_back(stdFileName); } ofstream outStd; @@ -578,8 +597,16 @@ int UnifracUnweightedCommand::getConsensusTrees(vector< vector >& dists, m->runParse = false; //create treemap class from groupmap for tree class to use - TreeMap newTmap; - newTmap.makeSim(m->getGroups()); + CountTable newCt; + set nameMap; + map groupMap; + set gps; + for (int i = 0; i < m->getGroups().size(); i++) { + nameMap.insert(m->getGroups()[i]); + gps.insert(m->getGroups()[i]); + groupMap[m->getGroups()[i]] = m->getGroups()[i]; + } + newCt.createTable(nameMap, groupMap, gps); //clear old tree names if any m->Treenames.clear(); @@ -587,7 +614,7 @@ int UnifracUnweightedCommand::getConsensusTrees(vector< vector >& dists, //fills globaldatas tree names m->Treenames = m->getGroups(); - vector newTrees = buildTrees(dists, treeNum, newTmap); //also creates .all.tre file containing the trees created + vector newTrees = buildTrees(dists, treeNum, newCt); //also creates .all.tre file containing the trees created if (m->control_pressed) { return 0; } @@ -595,7 +622,11 @@ int UnifracUnweightedCommand::getConsensusTrees(vector< vector >& dists, Tree* conTree = con.getTree(newTrees); //create a new filename - string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.cons." + getOutputFileNameTag("tree"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile)); + variables["[tag]"] = toString(treeNum+1); + variables["[tag2]"] = "unweighted.cons"; + string conFile = getOutputFileName("tree",variables); outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); ofstream outTree; m->openOutputFile(conFile, outTree); @@ -613,13 +644,17 @@ int UnifracUnweightedCommand::getConsensusTrees(vector< vector >& dists, } /**************************************************************************************************/ -vector UnifracUnweightedCommand::buildTrees(vector< vector >& dists, int treeNum, TreeMap& mytmap) { +vector UnifracUnweightedCommand::buildTrees(vector< vector >& dists, int treeNum, CountTable& myct) { try { vector trees; //create a new filename - string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.all." + getOutputFileNameTag("tree"); + map variables; + variables["[filename]"] = outputDir + m->getRootName(m->getSimpleName(treefile)); + variables["[tag]"] = toString(treeNum+1); + variables["[tag2]"] = "unweighted.all"; + string outputFile = getOutputFileName("tree",variables); outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); ofstream outAll; @@ -647,9 +682,8 @@ vector UnifracUnweightedCommand::buildTrees(vector< vector >& dis } //create tree - Tree* tempTree = new Tree(&mytmap, sims); - map empty; - tempTree->assembleTree(empty); + Tree* tempTree = new Tree(&myct, sims); + tempTree->assembleTree(); trees.push_back(tempTree); @@ -786,11 +820,16 @@ void UnifracUnweightedCommand::printUWSummaryFile(int i) { void UnifracUnweightedCommand::createPhylipFile(int i) { try { string phylipFileName; + map variables; + variables["[filename]"] = outputDir + m->getSimpleName(treefile); + variables["[tag]"] = toString(i+1); if ((outputForm == "lt") || (outputForm == "square")) { - phylipFileName = outputDir + m->getSimpleName(treefile) + toString(i+1) + ".unweighted.phylip." + getOutputFileNameTag("phylip"); + variables["[tag2]"] = "unweighted.phylip"; + phylipFileName = getOutputFileName("phylip",variables); outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); }else { //column - phylipFileName = outputDir + m->getSimpleName(treefile) + toString(i+1) + ".unweighted.column." + getOutputFileNameTag("column"); + variables["[tag2]"] = "unweighted.column"; + phylipFileName = getOutputFileName("column",variables); outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); }