19map<size_t, std::shared_ptr<PhyloTree>> BppPhylogeneticsApplication::getPhyloTreesMap(
20 const map<
size_t, std::shared_ptr<const AlignmentDataInterface>>& mSites,
21 map<string, string>& unparsedParams,
22 const std::string& prefix,
23 const std::string& suffix,
24 bool suffixIsOptional)
const
38 for (
auto it : mpTree)
40 it.second->scaleTree(scale);
48 std::shared_ptr<const Alphabet> alphabet,
49 std::shared_ptr<const GeneticCode> gCode,
50 const map<
size_t, std::shared_ptr<const AlignmentDataInterface>>& mSites,
51 map<string, string>& unparsedParams,
52 const std::string& prefix,
53 const std::string& suffix,
54 bool suffixIsOptional)
const
56 auto mpTree =
getPhyloTreesMap(mSites, unparsedParams, prefix, suffix, suffixIsOptional);
57 auto SPC =
getCollection(alphabet, gCode, mSites, mpTree, unparsedParams, prefix, suffix, suffixIsOptional);
62 std::shared_ptr<const Alphabet> alphabet,
63 std::shared_ptr<const GeneticCode> gCode,
64 const map<
size_t, std::shared_ptr<const AlignmentDataInterface>>& mSites,
65 const map<
size_t, std::shared_ptr<PhyloTree>>& mpTree,
66 map<string, string>& unparsedParams,
67 const std::string& prefix,
68 const std::string& suffix,
69 bool suffixIsOptional)
const
73 auto mMod = PhylogeneticsApplicationTools::uniqueToSharedMap<BranchModelInterface>(mModU);
75 auto mRootFreq = PhylogeneticsApplicationTools::uniqueToSharedMap<FrequencySetInterface>(mRootFreqU);
77 auto mModelPath = PhylogeneticsApplicationTools::uniqueToSharedMap<ModelPath>(mModelPathU);
79 auto mScenario = PhylogeneticsApplicationTools::uniqueToSharedMap<ModelScenario>(mScenarioU);
81 auto SPC =
PhylogeneticsApplicationTools::getSubstitutionProcessCollection(alphabet, gCode, mpTree, mMod, mRootFreq, mDist, mScenario,
params_, unparsedParams, suffix, suffixIsOptional,
verbose_,
warn_);
88 shared_ptr<SubstitutionProcessCollection> collection,
89 map<string, string>& unparsedParams,
90 const std::string& suffix,
91 bool suffixIsOptional)
const
100 map<
size_t, shared_ptr<SequenceEvolution>> mSeqEvol,
101 shared_ptr<SubstitutionProcessCollection> collection,
102 const map<
size_t, shared_ptr<const AlignmentDataInterface>>& mSites,
103 const std::string& suffix,
104 bool suffixIsOptional)
const
112 shared_ptr<const Alphabet> alphabet,
113 shared_ptr<const GeneticCode> gCode,
114 shared_ptr<PhyloLikelihoodInterface> phylolik,
115 const std::string& suffix,
116 bool suffixIsOptional)
const
118 double logL = phylolik->getValue();
120 if (!std::isnormal(logL))
128 for (
size_t i = 0; i < pl.
size(); i++)
130 if (pl[i].getValue() < 0.000001)
131 pl[i].setValue(0.001);
134 logL = phylolik->getValue();
139 if (!std::isnormal(logL))
143 map<size_t, shared_ptr<SingleDataPhyloLikelihoodInterface>> mSD;
145 if (dynamic_pointer_cast<SingleDataPhyloLikelihoodInterface>(phylolik))
146 mSD[1] = dynamic_pointer_cast<SingleDataPhyloLikelihoodInterface>(phylolik);
149 auto sOAP = dynamic_pointer_cast<PhyloLikelihoodSetInterface>(phylolik);
152 const vector<size_t>& nSD = sOAP->getNumbersOfPhyloLikelihoods();
154 for (
size_t iSD = 0; iSD < nSD.size(); ++iSD)
156 auto pASDP = dynamic_pointer_cast<SingleDataPhyloLikelihoodInterface>(sOAP->getPhyloLikelihood(nSD[iSD]));
159 mSD[nSD[iSD]] = pASDP;
164 for (
auto& itm : mSD)
168 if (!std::isnormal(itm.second->getValue()))
170 auto sDP = itm.second;
172 auto vData = std::shared_ptr<AlignmentDataInterface>(sDP->getData()->clone());
174 auto vSC = std::dynamic_pointer_cast<SiteContainerInterface>(vData);
175 auto pSC = std::dynamic_pointer_cast<ProbabilisticSiteContainerInterface>(vData);
181 for (
size_t i = 0; i < vData->getNumberOfSites(); ++i)
183 if (!std::isnormal(sDP->getLogLikelihoodForASite(i)))
187 const Site& site = vSC->site(i);
189 for (
size_t j = 0; j < s; ++j)
191 if (gCode->isStop(site.
getValue(j)))
202 for (
size_t j = 0; j < s; ++j)
205 for (
int st = 0; !g && st < static_cast<int>(alphabet->getSize()); ++st)
231 for (
size_t i = vData->getNumberOfSites(); i > 0; --i)
233 if (!std::isnormal(sDP->getLogLikelihoodForASite(i - 1)))
236 vData->deleteSites(i - 1, 1);
244 logL = sDP->getValue();
246 vector<size_t> vsiteok, vsitemin;
248 if (!std::isnormal(logL))
251 for (
unsigned int i = 0; i < vData->getNumberOfSites(); i++)
253 auto x = sDP->getLogLikelihoodForASite(i);
254 if (!std::isnormal(x))
256 (*
ApplicationTools::error <<
"Site " << vData->site(i).getCoordinate() <<
"\tlog likelihood = " << x).endLine();
257 vsitemin.push_back(i);
260 vsiteok.push_back(i);
266 sDP->setData(vDataok);
267 logL = sDP->getValue();
298 for (
size_t i = 0; i < parameters.
size(); i++)
int getCoordinate() const override
const int & getValue(size_t pos) const override
std::map< std::string, std::string > params_
virtual void fixLikelihood(std::shared_ptr< const Alphabet > alphabet, std::shared_ptr< const GeneticCode > gCode, std::shared_ptr< PhyloLikelihoodInterface > phylolik, const std::string &suffix="", bool suffixIsOptional=true) const
Method to have a clean likelihood (ie not saturated, nor infinite).
virtual std::map< size_t, std::unique_ptr< SequenceEvolution > > getProcesses(std::shared_ptr< SubstitutionProcessCollection > collection, std::map< std::string, std::string > &unparsedParams, const std::string &suffix="", bool suffixIsOptional=true) const
get the substitution processes.
virtual std::map< size_t, std::shared_ptr< PhyloTree > > getPhyloTreesMap(const std::map< size_t, std::shared_ptr< const AlignmentDataInterface > > &mSites, std::map< std::string, std::string > &unparsedParams, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true) const
Methods to build objects.
virtual std::unique_ptr< SubstitutionProcessCollection > getCollection(std::shared_ptr< const Alphabet > alphabet, std::shared_ptr< const GeneticCode > gCode, const std::map< size_t, std::shared_ptr< const AlignmentDataInterface > > &mSites, const std::map< size_t, std::shared_ptr< PhyloTree > > &mpTree, std::map< std::string, std::string > &unparsedParams, const std::string &prefix="input.", const std::string &suffix="", bool suffixIsOptional=true) const
get the collection of objects necessary to build substitution processes.
virtual void displayParameters(const PhyloLikelihoodInterface &tl, bool displaylL=true) const
Display parameter values.
virtual std::shared_ptr< PhyloLikelihoodContainer > getPhyloLikelihoods(Context &context, std::map< size_t, std::shared_ptr< SequenceEvolution > > mSeqEvol, std::shared_ptr< SubstitutionProcessCollection > collection, const std::map< size_t, std::shared_ptr< const AlignmentDataInterface > > &mSites, const std::string &suffix="", bool suffixIsOptional=true) const
get the phylolikelihoods.
Context for dataflow node construction.
virtual size_t size() const=0
virtual double getValue() const=0
virtual std::vector< std::string > getParameterNames() const
virtual bool matchParametersValues(const ParameterList ¶ms, std::vector< size_t > *updatedParameters=0)
virtual void deleteParameters(const std::vector< std::string > &names, bool mustExist=true)
virtual size_t getNumberOfParameters() const=0
virtual const ParameterList & getParameters() const=0
The PhyloLikelihood interface, for phylogenetic likelihood.
virtual ParameterList getBranchLengthParameters() const =0
Get the independent branch lengths parameters.
double getStateValueAt(size_t sequencePosition, int state) const
std::string toString(T t)
Defines the basic types of data flow nodes.