unsigned int OptimizationTools::optimizeTreeScale( TreeLikelihood* tl, double tolerance, unsigned int tlEvalMax, OutputStream* messageHandler, OutputStream* profiler, unsigned int verbose) throw (Exception) { ScaleFunction sf(tl); BrentOneDimension bod(&sf); bod.setMessageHandler(messageHandler); bod.setProfiler(profiler); ParameterList singleParameter; singleParameter.addParameter(Parameter("scale factor", 0)); bod.setInitialInterval(-0.5, 0.5); bod.init(singleParameter); ParametersStopCondition PS(&bod, tolerance); bod.setStopCondition(PS); bod.setMaximumNumberOfEvaluations(tlEvalMax); bod.optimize(); ApplicationTools::displayTaskDone(); if (verbose > 0) ApplicationTools::displayResult("Tree scaled by", exp(sf.getParameters()[0].getValue())); return bod.getNumberOfEvaluations(); }
void LoadParameterHistory() { FILE* parameterFile = _wfopen(g_ParameterFileName, ACE_TEXT("r")); if (parameterFile != 0) { while (feof(parameterFile) == 0) { // Note: Remember that fwprintf takes wide-character format specifier but // save string as ASCII. Thus, history must be read as ASCII then converted // to wide-character (Unicode on WinCE). char singleParameter[MAX_COMMAND_LINE]; int size = 0; fread(&singleParameter[size], sizeof(char), 1, parameterFile); // WinCE does not have function that reads upto the end of line. while (singleParameter[size] != '\n') { fread(&singleParameter[++size], sizeof(char), 1, parameterFile); } if (size > 0) { singleParameter[size] = 0; // NULL terminator g_Parameter.addParameter(singleParameter); } } fclose(parameterFile); } }
std::shared_ptr<ComPWA::Parameter> TreeNode::recalculate() const { // has been changed or is lead node -> return Parameter if (Parameter && (!HasChanged || !ChildNodes.size())) return Parameter; std::shared_ptr<ComPWA::Parameter> result; if (Parameter) result = Parameter; ParameterList newVals; for (auto ch : ChildNodes) { auto p = ch->parameter(); if (p->isParameter()) newVals.addParameter(p); else newVals.addValue(p); } try { Strat->execute(newVals, result); } catch (std::exception &ex) { LOG(INFO) << "TreeNode::Recalculate() | Strategy " << Strat << " failed on node " << name() << ": " << ex.what(); throw; } return result; }
double NumTools::uniRoot(Function & f, const string & param, double a, double b, double tolerance) throw (Exception) { ParameterList pl; pl.addParameter(Parameter(param, a)); double fa = f.f(pl); pl[0]->setValue(b); double fb = f.f(pl); if(fa * fb > 0.) throw Exception("NumTools::uniRoot(). Initial interval values are not of opposite sign."); double c = (a + b) / 2.; double fc; while(abs(fb - fa) > tolerance) { c = (a + b) / 2.; //Better use golden section here... pl[0]->setValue(c); fc = f.f(pl); if(fc * fa < 0.) { b = c; fb = fc; } else { a = c; fa = fc; } } return c; }
unsigned int OneDimensionOptimizationTools::lineMinimization(DirectionFunction & f1dim, ParameterList & parameters, vector<double> & xi, double tolerance, ostream * profiler, ostream * messenger, int verbose) { // Initial guess for brackets: double ax = 0.; double xx = 0.01; f1dim.setConstraintPolicy(AutoParameter::CONSTRAINTS_AUTO); f1dim.setMessageHandler(messenger); f1dim.init(parameters, xi); BrentOneDimension bod(&f1dim); bod.setMessageHandler(messenger); bod.setProfiler(profiler); bod.setVerbose(verbose >= 1 ? 1 : 0); bod.setOptimizationProgressCharacter("."); bod.getStopCondition()->setTolerance(0.01); bod.setInitialInterval(ax, xx); bod.setConstraintPolicy(AutoParameter::CONSTRAINTS_KEEP); ParameterList singleParameter; singleParameter.addParameter(Parameter("x", 0.0)); bod.init(singleParameter); bod.optimize(); //Update parameters: //parameters.matchParametersValues(f1dim.getFunction()->getParameters()); double xmin = f1dim.getParameters()[0]->getValue(); for(unsigned int j = 0; j < parameters.size(); j++) { xi[j] *= xmin; parameters[j]->setValue(parameters[j]->getValue() + xi[j]); } return bod.getNumberOfEvaluations(); }
void GlobalClockTreeLikelihoodFunctionWrapper::computeBranchLengthsFromHeights_(const Node* node, double height, ParameterList& brlenPl) throw (Exception) { for (unsigned int i = 0; i < node->getNumberOfSons(); i++) { const Node* son = node->getSon(i); if (son->isLeaf()) { brlenPl.addParameter(Parameter("BrLen" + TextTools::toString(son->getId()), std::max(0.0000011, height), new IntervalConstraint(1, 0.000001, false), true)); } else { double sonHeightP = getParameter("HeightP" + TextTools::toString(son->getId())).getValue(); double sonHeight = sonHeightP * height; brlenPl.addParameter(Parameter("BrLen" + TextTools::toString(son->getId()), std::max(0.0000011, height - sonHeight), new IntervalConstraint(1, 0.000001, false), true)); computeBranchLengthsFromHeights_(son, sonHeight, brlenPl); } } }
unsigned int OneDimensionOptimizationTools::lineSearch(DirectionFunction& f1dim, ParameterList& parameters, std::vector<double>& xi, std::vector<double>& gradient, OutputStream* profiler, OutputStream* messenger, int verbose) { size_t size = xi.size(); f1dim.setConstraintPolicy(AutoParameter::CONSTRAINTS_AUTO); f1dim.setMessageHandler(messenger); f1dim.init(parameters, xi); double slope=0; for (unsigned int i=0; i<size; i++) slope+=xi[i]*gradient[i]; // if (slope>=0) // throw Exception("Slope problem in OneDimensionOptimizationTools::lineSearch. Slope="+TextTools::toString(slope)); double x, temp, test=0; for (unsigned int i=0; i<size; i++) { x=abs(parameters[i].getValue()); temp=abs(xi[i]); if (x>1.0) temp/=x; if (temp>test) test=temp; } NewtonBacktrackOneDimension nbod(&f1dim, slope, test); nbod.setMessageHandler(messenger); nbod.setProfiler(profiler); nbod.setVerbose(verbose >= 1 ? 1 : 0); nbod.setOptimizationProgressCharacter("."); nbod.getStopCondition()->setTolerance(0.0001); // nbod.setInitialInterval(ax, xx); nbod.setConstraintPolicy(AutoParameter::CONSTRAINTS_KEEP); ParameterList singleParameter; singleParameter.addParameter(Parameter("x", 0.0)); nbod.init(singleParameter); nbod.optimize(); //Update parameters: //parameters.matchParametersValues(f1dim.getFunction()->getParameters()); double xmin = f1dim.getParameters()[0].getValue(); for(unsigned int j = 0; j < parameters.size(); j++) { xi[j] *= xmin; parameters[j].setValue(parameters[j].getValue() + xi[j]); } return nbod.getNumberOfEvaluations(); }
void AbstractBiblioSubstitutionModel::setFreqFromData(const SequenceContainer& data, double pseudoCount) { getModel().setFreqFromData(data, pseudoCount); map<string, string>::iterator it; ParameterList pl; for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++) { pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first)))); } matchParametersValues(pl); }
ParameterList GlobalClockTreeLikelihoodFunctionWrapper::getHeightParameters() const { ParameterList pl; for (unsigned int i = 0; i < getNumberOfParameters(); ++i) { Parameter p = getParameter_(i); if (p.getName().substr(0, 7) == "HeightP" || p.getName() == "TotalHeight") pl.addParameter(p); } return pl; }
void AbstractBiblioSubstitutionModel::setFreq(std::map<int, double>& m) { getModel().setFreq(m); map<string, string>::iterator it; ParameterList pl; for (it = mapParNamesFromPmodel_.begin(); it != mapParNamesFromPmodel_.end(); it++) { pl.addParameter(Parameter(getNamespace() + it->second, getModel().getParameterValue(getModel().getParameterNameWithoutNamespace(it->first)))); } matchParametersValues(pl); }
ParameterList SubstitutionModelSet::getModelParameters(size_t modelIndex) const { ParameterList pl; size_t offset = stationarity_ ? 0 : rootFrequencies_->getNumberOfParameters(); // Root frequencies are the first parameters! We should ignore them here. for (size_t i = 0; i < modelParameterNames_.size(); i++) { // Check associations: const vector<size_t>* modelIndexes = ¶mToModels_[i]; for (size_t j = 0; j < modelIndexes->size(); j++) { if ((*modelIndexes)[j] == modelIndex) { pl.addParameter(getParameter_(offset + i)); break; } } } return pl; }
LRESULT CALLBACK CommandLine(HWND hDlg, UINT message, WPARAM wParam, LPARAM) { int wmId; int wmEvent; switch (message) { case WM_INITDIALOG: g_Parameter.sendParameterMSG(hDlg, CB_INSERTSTRING); SetDlgItemText(hDlg, IDC_CMDEDIT, g_CommandLine); // pass existing command line for display return TRUE; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDOK: // new command line accepted GetDlgItemText(hDlg, IDC_CMDEDIT, g_CommandLine, MAX_COMMAND_LINE - 1); EndDialog(hDlg, wmId); g_Parameter.addParameter(g_CommandLine); return TRUE; case IDCANCEL: EndDialog(hDlg, wmId); return TRUE; default: return FALSE; } break; default: return FALSE; } return FALSE; }
double NNIHomogeneousTreeLikelihood::testNNI(int nodeId) const throw (NodeException) { const Node * son = _tree->getNode(nodeId); if(!son->hasFather()) throw NodeException("DRHomogeneousTreeLikelihood::testNNI(). Node 'son' must not be the root node.", son); const Node * parent = son->getFather(); if(!parent->hasFather()) throw NodeException("DRHomogeneousTreeLikelihood::testNNI(). Node 'parent' must not be the root node.", parent); const Node * grandFather = parent->getFather(); //From here: Bifurcation assumed. //In case of multifurcation, an arbitrary uncle is chosen. //If we are at root node with a trifurcation, this does not matter, since 2 NNI are possible (see doc of the NNISearchable interface). unsigned int parentPosition = grandFather->getSonPosition(*parent); //const Node * uncle = grandFather->getSon(parentPosition > 1 ? parentPosition - 1 : 1 - parentPosition); const Node * uncle = grandFather->getSon(parentPosition > 1 ? 0 : 1 - parentPosition); //Retrieving arrays of interest: const DRASDRTreeLikelihoodNodeData * parentData = & _likelihoodData->getNodeData(parent->getId()); const VVVdouble * sonArray = & parentData->getLikelihoodArrayForNeighbor(son->getId()); vector<const Node *> parentNeighbors = TreeTemplateTools::getRemainingNeighbors(parent, grandFather, son); unsigned int nbParentNeighbors = parentNeighbors.size(); vector<const VVVdouble *> parentArrays(nbParentNeighbors); vector<const VVVdouble *> parentTProbs(nbParentNeighbors); for(unsigned int k = 0; k < nbParentNeighbors; k++) { const Node * n = parentNeighbors[k]; // This neighbor parentArrays[k] = & parentData->getLikelihoodArrayForNeighbor(n->getId()); //if(n != grandFather) parentTProbs[k] = & pxy_[n->getId()]; //else parentTProbs[k] = & pxy_[parent->getId()]; parentTProbs[k] = & pxy_[n->getId()]; } const DRASDRTreeLikelihoodNodeData * grandFatherData = & _likelihoodData->getNodeData(grandFather->getId()); const VVVdouble * uncleArray = & grandFatherData->getLikelihoodArrayForNeighbor(uncle->getId()); vector<const Node *> grandFatherNeighbors = TreeTemplateTools::getRemainingNeighbors(grandFather, parent, uncle); unsigned int nbGrandFatherNeighbors = grandFatherNeighbors.size(); vector<const VVVdouble *> grandFatherArrays; vector<const VVVdouble *> grandFatherTProbs; for(unsigned int k = 0; k < nbGrandFatherNeighbors; k++) { const Node * n = grandFatherNeighbors[k]; // This neighbor if(grandFather->getFather() == NULL || n != grandFather->getFather()) { grandFatherArrays.push_back(& grandFatherData->getLikelihoodArrayForNeighbor(n->getId())); grandFatherTProbs.push_back(& pxy_[n->getId()]); } } //Compute array 1: grand father array VVVdouble array1 = *sonArray; resetLikelihoodArray(array1); grandFatherArrays.push_back(sonArray); grandFatherTProbs.push_back(& pxy_[son->getId()]); if(grandFather->hasFather()) { computeLikelihoodFromArrays(grandFatherArrays, grandFatherTProbs, & grandFatherData->getLikelihoodArrayForNeighbor(grandFather->getFather()->getId()), & pxy_[grandFather->getId()], array1, nbGrandFatherNeighbors, nbDistinctSites_, nbClasses_, nbStates_, false); } else { computeLikelihoodFromArrays(grandFatherArrays, grandFatherTProbs, array1, nbGrandFatherNeighbors + 1, nbDistinctSites_, nbClasses_, nbStates_, false); //This is the root node, we have to account for the ancestral frequencies: for(unsigned int i = 0; i < nbDistinctSites_; i++) { for(unsigned int j = 0; j < nbClasses_; j++) { for(unsigned int x = 0; x < nbStates_; x++) array1[i][j][x] *= rootFreqs_[x]; } } } //Compute array 2: parent array VVVdouble array2 = *uncleArray; resetLikelihoodArray(array2); parentArrays.push_back(uncleArray); parentTProbs.push_back(& pxy_[uncle->getId()]); computeLikelihoodFromArrays(parentArrays, parentTProbs, array2, nbParentNeighbors + 1, nbDistinctSites_, nbClasses_, nbStates_, false); //Initialize BranchLikelihood: _brLikFunction->initModel(model_, _rateDistribution); _brLikFunction->initLikelihoods(&array1, &array2); ParameterList parameters; unsigned int pos = 0; while(pos < nodes_.size() && nodes_[pos]->getId() != parent->getId()) pos++; if(pos == nodes_.size()) throw Exception("NNIHomogeneousTreeLikelihood::testNNI. Unvalid node id."); Parameter brLen = getParameter("BrLen" + TextTools::toString(pos)); brLen.setName("BrLen"); parameters.addParameter(brLen); _brLikFunction->setParameters(parameters); //Re-estimate branch length: _brentOptimizer->setFunction(_brLikFunction); _brentOptimizer->getStopCondition()->setTolerance(0.1); _brentOptimizer->setInitialInterval(brLen.getValue(), brLen.getValue()+0.01); _brentOptimizer->init(parameters); _brentOptimizer->optimize(); //_brLenNNIValues[nodeId] = _brLikFunction->getParameterValue("BrLen"); _brLenNNIValues[nodeId] = _brentOptimizer->getParameters().getParameter("BrLen").getValue(); _brLikFunction->resetLikelihoods(); //Array1 and Array2 will be destroyed after this function call. //We should not keep pointers towards them... //Return the resulting likelihood: return _brLikFunction->getValue() - getValue(); }
int main(int args, char ** argv) { cout << "******************************************************************" << endl; cout << "* Bio++ Distance Methods, version 2.2.0 *" << endl; cout << "* Author: J. Dutheil Created 05/05/07 *" << endl; cout << "* Last Modif. 04/02/15 *" << endl; cout << "******************************************************************" << endl; cout << endl; if(args == 1) { help(); return 0; } try { BppApplication bppdist(args, argv, "BppDist"); bppdist.startTimer(); Alphabet* alphabet = SequenceApplicationTools::getAlphabet(bppdist.getParams(), "", false); auto_ptr<GeneticCode> gCode; CodonAlphabet* codonAlphabet = dynamic_cast<CodonAlphabet*>(alphabet); if (codonAlphabet) { string codeDesc = ApplicationTools::getStringParameter("genetic_code", bppdist.getParams(), "Standard", "", true, true); ApplicationTools::displayResult("Genetic Code", codeDesc); gCode.reset(SequenceApplicationTools::getGeneticCode(codonAlphabet->getNucleicAlphabet(), codeDesc)); } VectorSiteContainer* allSites = SequenceApplicationTools::getSiteContainer(alphabet, bppdist.getParams()); VectorSiteContainer* sites = SequenceApplicationTools::getSitesToAnalyse(* allSites, bppdist.getParams()); delete allSites; ApplicationTools::displayResult("Number of sequences", TextTools::toString(sites->getNumberOfSequences())); ApplicationTools::displayResult("Number of sites", TextTools::toString(sites->getNumberOfSites())); SubstitutionModel* model = PhylogeneticsApplicationTools::getSubstitutionModel(alphabet, gCode.get(), sites, bppdist.getParams()); DiscreteDistribution* rDist = 0; if (model->getNumberOfStates() > model->getAlphabet()->getSize()) { //Markov-modulated Markov model! rDist = new ConstantRateDistribution(); } else { rDist = PhylogeneticsApplicationTools::getRateDistribution(bppdist.getParams()); } DistanceEstimation distEstimation(model, rDist, sites, 1, false); string method = ApplicationTools::getStringParameter("method", bppdist.getParams(), "nj"); ApplicationTools::displayResult("Tree reconstruction method", method); TreeTemplate<Node>* tree; AgglomerativeDistanceMethod* distMethod = 0; if(method == "wpgma") { PGMA* wpgma = new PGMA(true); distMethod = wpgma; } else if(method == "upgma") { PGMA* upgma = new PGMA(false); distMethod = upgma; } else if(method == "nj") { NeighborJoining* nj = new NeighborJoining(); nj->outputPositiveLengths(true); distMethod = nj; } else if(method == "bionj") { BioNJ* bionj = new BioNJ(); bionj->outputPositiveLengths(true); distMethod = bionj; } else throw Exception("Unknown tree reconstruction method."); string type = ApplicationTools::getStringParameter("optimization.method", bppdist.getParams(), "init"); ApplicationTools::displayResult("Model parameters estimation method", type); if (type == "init") type = OptimizationTools::DISTANCEMETHOD_INIT; else if (type == "pairwise") type = OptimizationTools::DISTANCEMETHOD_PAIRWISE; else if (type == "iterations") type = OptimizationTools::DISTANCEMETHOD_ITERATIONS; else throw Exception("Unknown parameter estimation procedure '" + type + "'."); unsigned int optVerbose = ApplicationTools::getParameter<unsigned int>("optimization.verbose", bppdist.getParams(), 2); string mhPath = ApplicationTools::getAFilePath("optimization.message_handler", bppdist.getParams(), false, false); OutputStream* messenger = (mhPath == "none") ? 0 : (mhPath == "std") ? ApplicationTools::message : new StlOutputStream(new ofstream(mhPath.c_str(), ios::out)); ApplicationTools::displayResult("Message handler", mhPath); string prPath = ApplicationTools::getAFilePath("optimization.profiler", bppdist.getParams(), false, false); OutputStream* profiler = (prPath == "none") ? 0 : (prPath == "std") ? ApplicationTools::message : new StlOutputStream(new ofstream(prPath.c_str(), ios::out)); if(profiler) profiler->setPrecision(20); ApplicationTools::displayResult("Profiler", prPath); // Should I ignore some parameters? ParameterList allParameters = model->getParameters(); allParameters.addParameters(rDist->getParameters()); ParameterList parametersToIgnore; string paramListDesc = ApplicationTools::getStringParameter("optimization.ignore_parameter", bppdist.getParams(), "", "", true, false); bool ignoreBrLen = false; StringTokenizer st(paramListDesc, ","); while (st.hasMoreToken()) { try { string param = st.nextToken(); if (param == "BrLen") ignoreBrLen = true; else { if (allParameters.hasParameter(param)) { Parameter* p = &allParameters.getParameter(param); parametersToIgnore.addParameter(*p); } else ApplicationTools::displayWarning("Parameter '" + param + "' not found."); } } catch (ParameterNotFoundException& pnfe) { ApplicationTools::displayError("Parameter '" + pnfe.getParameter() + "' not found, and so can't be ignored!"); } } unsigned int nbEvalMax = ApplicationTools::getParameter<unsigned int>("optimization.max_number_f_eval", bppdist.getParams(), 1000000); ApplicationTools::displayResult("Max # ML evaluations", TextTools::toString(nbEvalMax)); double tolerance = ApplicationTools::getDoubleParameter("optimization.tolerance", bppdist.getParams(), .000001); ApplicationTools::displayResult("Tolerance", TextTools::toString(tolerance)); //Here it is: ofstream warn("warnings", ios::out); ApplicationTools::warning = new StlOutputStreamWrapper(&warn); tree = OptimizationTools::buildDistanceTree(distEstimation, *distMethod, parametersToIgnore, !ignoreBrLen, type, tolerance, nbEvalMax, profiler, messenger, optVerbose); warn.close(); delete ApplicationTools::warning; ApplicationTools::warning = ApplicationTools::message; string matrixPath = ApplicationTools::getAFilePath("output.matrix.file", bppdist.getParams(), false, false, "", false); if (matrixPath != "none") { ApplicationTools::displayResult("Output matrix file", matrixPath); string matrixFormat = ApplicationTools::getAFilePath("output.matrix.format", bppdist.getParams(), false, false, "", false); string format = ""; bool extended = false; std::map<std::string, std::string> unparsedArguments_; KeyvalTools::parseProcedure(matrixFormat, format, unparsedArguments_); if (unparsedArguments_.find("type") != unparsedArguments_.end()) { if (unparsedArguments_["type"] == "extended") { extended = true; } else if (unparsedArguments_["type"] == "classic") extended = false; else ApplicationTools::displayWarning("Argument '" + unparsedArguments_["type"] + "' for parameter 'Phylip#type' is unknown. " + "Default used instead: not extended."); } else ApplicationTools::displayWarning("Argument 'Phylip#type' not found. Default used instead: not extended."); ODistanceMatrix* odm = IODistanceMatrixFactory().createWriter(IODistanceMatrixFactory::PHYLIP_FORMAT, extended); odm->write(*distEstimation.getMatrix(), matrixPath, true); delete odm; } PhylogeneticsApplicationTools::writeTree(*tree, bppdist.getParams()); //Output some parameters: if (type == OptimizationTools::DISTANCEMETHOD_ITERATIONS) { // Write parameters to screen: ParameterList parameters = model->getParameters(); for (unsigned int i = 0; i < parameters.size(); i++) { ApplicationTools::displayResult(parameters[i].getName(), TextTools::toString(parameters[i].getValue())); } parameters = rDist->getParameters(); for (unsigned int i = 0; i < parameters.size(); i++) { ApplicationTools::displayResult(parameters[i].getName(), TextTools::toString(parameters[i].getValue())); } // Write parameters to file: string parametersFile = ApplicationTools::getAFilePath("output.estimates", bppdist.getParams(), false, false); if (parametersFile != "none") { ofstream out(parametersFile.c_str(), ios::out); parameters = model->getParameters(); for (unsigned int i = 0; i < parameters.size(); i++) { out << parameters[i].getName() << " = " << parameters[i].getValue() << endl; } parameters = rDist->getParameters(); for (unsigned int i = 0; i < parameters.size(); i++) { out << parameters[i].getName() << " = " << parameters[i].getValue() << endl; } out.close(); } } //Bootstrap: unsigned int nbBS = ApplicationTools::getParameter<unsigned int>("bootstrap.number", bppdist.getParams(), 0); if(nbBS > 0) { ApplicationTools::displayResult("Number of bootstrap samples", TextTools::toString(nbBS)); bool approx = ApplicationTools::getBooleanParameter("bootstrap.approximate", bppdist.getParams(), true); ApplicationTools::displayResult("Use approximate bootstrap", TextTools::toString(approx ? "yes" : "no")); if(approx) { type = OptimizationTools::DISTANCEMETHOD_INIT; parametersToIgnore = allParameters; ignoreBrLen = true; } bool bootstrapVerbose = ApplicationTools::getBooleanParameter("bootstrap.verbose", bppdist.getParams(), false, "", true, false); string bsTreesPath = ApplicationTools::getAFilePath("bootstrap.output.file", bppdist.getParams(), false, false); ofstream *out = NULL; if(bsTreesPath != "none") { ApplicationTools::displayResult("Bootstrap trees stored in file", bsTreesPath); out = new ofstream(bsTreesPath.c_str(), ios::out); } Newick newick; vector<Tree *> bsTrees(nbBS); ApplicationTools::displayTask("Bootstrapping", true); for(unsigned int i = 0; i < nbBS; i++) { ApplicationTools::displayGauge(i, nbBS-1, '='); VectorSiteContainer * sample = SiteContainerTools::bootstrapSites(*sites); if(approx) model->setFreqFromData(*sample); distEstimation.setData(sample); bsTrees[i] = OptimizationTools::buildDistanceTree( distEstimation, *distMethod, parametersToIgnore, ignoreBrLen, type, tolerance, nbEvalMax, NULL, NULL, (bootstrapVerbose ? 1 : 0) ); if(out && i == 0) newick.write(*bsTrees[i], bsTreesPath, true); if(out && i > 0) newick.write(*bsTrees[i], bsTreesPath, false); delete sample; } if(out) out->close(); if(out) delete out; ApplicationTools::displayTaskDone(); ApplicationTools::displayTask("Compute bootstrap values"); TreeTools::computeBootstrapValues(*tree, bsTrees); ApplicationTools::displayTaskDone(); for(unsigned int i = 0; i < nbBS; i++) delete bsTrees[i]; //Write resulting tree: PhylogeneticsApplicationTools::writeTree(*tree, bppdist.getParams()); } delete alphabet; delete sites; delete distMethod; delete tree; bppdist.done();} catch(exception & e) { cout << e.what() << endl; return 1; } return 0; }