bpp-phyl3 3.0.0
PhyloLikelihoodSet.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
6
7using namespace bpp;
8using namespace std;
9
10AbstractPhyloLikelihoodSet::AbstractPhyloLikelihoodSet(
11 Context& context,
12 std::shared_ptr<PhyloLikelihoodContainer> pC,
13 bool inCollection,
14 const std::string& prefix) :
17 pPhyloCont_(pC),
18 nPhylo_(),
19 vLikCal_()
20{
22 {
23 addPhyloLikelihood(np, inCollection ? "" : "_" + TextTools::toString(np));
24 }
25}
26
28 Context& context,
29 std::shared_ptr<PhyloLikelihoodContainer> pC,
30 const std::vector<size_t>& nPhylo,
31 bool inCollection,
32 const std::string& prefix) :
35 pPhyloCont_(pC),
36 nPhylo_(),
37 vLikCal_()
38{
39 for (auto np:nPhylo)
40 {
41 addPhyloLikelihood(np, inCollection ? "" : "_" + TextTools::toString(np));
42 }
43}
44
45bool AbstractPhyloLikelihoodSet::addPhyloLikelihood(size_t nPhyl, const std::string& suff)
46{
47 auto aPL = getPhyloLikelihood(nPhyl);
48
49 if (aPL)
50 {
51 nPhylo_.push_back(nPhyl);
52 if (suff != "") // Use specific parameters names
53 {
54 const auto& pl = aPL->getParameters();
55
56 for (size_t i = 0; i < pl.size(); i++)
57 {
58 auto confP = dynamic_pointer_cast<ConfiguredParameter>(pl.getParameter(i));
59 if (confP == 0)
60 throw Exception("SetOfAbstractPhyloLikelihood::addPhyloLikelihood: Parameter " + pl[i].getName() + " is not configured in PhyloLikelihood " + TextTools::toString(nPhyl));
61
62 auto name = confP->getName() + suff;
63
64 if (!hasParameter(name))
65 {
66 Parameter par(pl[i]);
67 par.setName(name);
68
69 auto cfPar = ConfiguredParameter::create(context_, {confP->dependency(0)}, par);
70 shareParameter_(cfPar);
71 }
72 }
73 }
74 else
75 shareParameters_(aPL->getParameters());
76
77
78 vLikCal_.push_back(aPL->getLikelihoodCalculation());
79 return true;
80 }
81 return false;
82}
83
85{
87 for (size_t i = 0; i < nPhylo_.size(); i++)
88 {
90 }
91
92 return pl;
93}
94
96{
98 for (size_t i = 0; i < nPhylo_.size(); i++)
99 {
101 }
102
103 return pl;
104}
105
106
108{
109 ParameterList pl;
110 for (size_t i = 0; i < nPhylo_.size(); i++)
111 {
113 }
114
115 return pl;
116}
117
119{
120 ParameterList pl;
121 for (size_t i = 0; i < nPhylo_.size(); i++)
122 {
124 }
125
126 return pl;
127}
128
130{
131 ParameterList pl;
132 for (size_t i = 0; i < nPhylo_.size(); i++)
133 {
135 }
136
137 return pl;
138}
139
141{
142 ParameterList pl;
143 for (size_t i = 0; i < nPhylo_.size(); i++)
144 {
146 }
147
148 return pl;
149}
virtual void shareParameters_(const ParameterList &parameters)
virtual void shareParameter_(const std::shared_ptr< Parameter > &parameter)
bool hasParameter(const std::string &name) const override
ParameterList getRootFrequenciesParameters() const override
Get the parameters associated to the root frequencies(s).
ParameterList getSubstitutionModelParameters() const override
Get the parameters associated to substitution model(s).
std::vector< size_t > nPhylo_
vector of AbstractPhyloLikelihood numbers
const std::vector< size_t > & getNumbersOfPhyloLikelihoods() const override
ParameterList getRateDistributionParameters() const override
Get the parameters associated to the rate distribution(s).
std::shared_ptr< const PhyloLikelihoodInterface > getPhyloLikelihood(size_t nPhyl) const override
ParameterList getDerivableParameters() const override
ParameterList getNonDerivableParameters() const override
ParameterList getBranchLengthParameters() const override
Get the branch lengths parameters.
AbstractPhyloLikelihoodSet(Context &context, std::shared_ptr< PhyloLikelihoodContainer > pC, bool inCollection=true, const std::string &prefix="")
std::vector< std::shared_ptr< LikelihoodCalculation > > vLikCal_
virtual bool addPhyloLikelihood(size_t nPhyl, const std::string &suff="") override
adds a PhyloLikelihood already stored in the PhyloLikelihoodContainer, iff it is an AbstractPhyloLike...
std::shared_ptr< PhyloLikelihoodContainer > getPhyloContainer() override
static std::shared_ptr< Self > create(Context &c, NodeRefVec &&deps, const Parameter &param)
Build a new ConfiguredParameter node.
Definition: Parameter.h:36
Context for dataflow node construction.
Definition: DataFlow.h:527
virtual void includeParameters(const ParameterList &params)
virtual void setName(const std::string &name)
std::string toString(T t)
Defines the basic types of data flow nodes.