5#include "../SitePatterns.h"
6#include "../Tree/Tree.h"
7#include "../PatternTools.h"
8#include "../Io/Newick.h"
37void DistanceEstimation::init_()
39 auto desc = make_unique<MetaOptimizerInfos>();
42 std::vector<std::string> name;
43 auto procMb = dynamic_pointer_cast<SubstitutionProcessCollectionMember>(
process_);
46 name.push_back(
"BrLen0");
47 name.push_back(
"BrLen1");
51 const auto& vTn = procMb->getCollection()->getTreeNumbers();
52 numProc_ = *std::max_element(vTn.begin(), vTn.end()) + 1;
77 size_t n =
sites_->getNumberOfSequences();
78 vector<string> names =
sites_->getSequenceNames();
79 dist_ = std::make_shared<DistanceMatrix>(names);
80 optimizer_->setVerbose(
static_cast<unsigned int>(max(
static_cast<int>(
verbose_) - 2, 0)));
84 auto autoProc = dynamic_pointer_cast<AutonomousSubstitutionProcessInterface>(
process_);
85 auto procMb = dynamic_pointer_cast<SubstitutionProcessCollectionMember>(
process_);
86 if (!autoProc && !procMb)
87 throw Exception(
"DistanceMatrix::computeMatrix : unknown process type. Ask developpers.");
91 treeN = procMb->getTreeNumber();
93 for (
size_t i = 0; i < n; ++i)
100 for (
size_t j = i + 1; j < n; ++j)
107 auto phyloTree = make_shared<bpp::ParametrizablePhyloTree>(*reader.
parenthesisToPhyloTree(
"(" + names[j] +
":0.01," + names[i] +
":0.01);",
false,
"",
false,
false));
110 autoProc->setPhyloTree(*phyloTree);
113 auto& coll = procMb->collection();
117 coll.replaceTree(phyloTree,
numProc_);
118 procMb->setTreeNumber(
numProc_,
false);
121 auto lik = std::make_shared<LikelihoodCalculationSingleProcess>(context,
sites_,
process_);
122 auto llh = std::make_shared<SingleProcessPhyloLikelihood>(context, lik);
135 (*dist_)(i, j) = (*
dist_)(j, i) = llh->getParameterValue(
"BrLen0") + llh->getParameterValue(
"BrLen1");
145 procMb->setTreeNumber(treeN,
false);
static std::string CONSTRAINTS_AUTO
Context for dataflow node construction.
std::shared_ptr< DistanceMatrix > dist_
std::shared_ptr< const AlignmentDataInterface > sites_
void computeMatrix()
Perform the distance computation.
std::shared_ptr< MetaOptimizer > defaultOptimizer_
std::shared_ptr< SubstitutionProcessInterface > process_
ParameterList parameters_
std::shared_ptr< OptimizerInterface > optimizer_
The so-called 'newick' parenthetic format.
std::unique_ptr< PhyloTree > parenthesisToPhyloTree(const std::string &description, bool bootstrap=false, const std::string &propertyName="", bool withId=false, bool verbose=false) const
virtual void addParameters(const ParameterList ¶ms)
virtual std::vector< std::string > getParameterNames() const
std::string toString(T t)
Defines the basic types of data flow nodes.