def add_pruned_branchrate_model(self, distribution, name, tree_id): xml.branchRateModel( distribution, id="PrunedRelaxedClockModel.c:%s" % name, spec="beast.evolution.branchratemodel.PrunedRelaxedClockModel", rates="@%s" % self.branchrate_model_id, tree="@%s" % tree_id)
def add_branchrate_model(self, beast): xml.branchRateModel( beast, attrib={"clock.rate": self.mean_rate_idref}, id="RandomLocalClock.c:%s" % self.name, spec="beast.evolution.branchratemodel.RandomLocalClockModel", indicators="@Indicators.c:%s" % self.name, rates="@clockrates.c:%s" % self.name, ratesAreMultipliers=self.correlated, tree="@Tree.t:beastlingTree") self.branchrate_model_id = "RandomLocalClock.c:%s" % self.name
def add_branchrate_model(self, beast): self.branchrate = xml.branchRateModel( beast, id="RelaxedClockModel.c:%s" % self.name, spec="beast.evolution.branchratemodel.UCRelaxedClockModel", rateCategories="@rateCategories.c:%s" % self.name, tree="@Tree.t:beastlingTree", numberOfDiscreteRates=self.number_of_rates, attrib={"clock.rate": self.mean_rate_idref}) self.branchrate_model_id = "RelaxedClockModel.c:%s" % self.name
def add_likelihood(self, likelihood): """ Add likelihood distribution corresponding to all features in the dataset. """ attribs = { "id": "sphericalGeographyLikelihood", "tree": "@Tree.t:beastlingTree", "logAverage": "true", "scale": "false", "location": "@location.geo" } # Use appropriate Likelihood implementation depending # upon presence/absence of sampled locations if self.sampling_points: attribs[ "spec"] = "sphericalGeo.ApproxMultivariateTraitLikelihoodF2" else: attribs["spec"] = "sphericalGeo.ApproxMultivariateTraitLikelihood" distribution = xml.distribution(likelihood, attrib=attribs) # Add data first, as this may trigger the creation of additional # sampling points (for langs with missing locations data) self.add_data(distribution) # Now add geopriors if self.sampling_points: multi = xml.multiGeoprior(distribution, id="multiGeoPrior", spec="sphericalGeo.MultiGeoPrior", tree="@Tree.t:beastlingTree", newick="") for clade in self.sampling_points: # Get languages in clade if clade == "root": langs = self.config.languages.languages else: langs = self.config.language_group(clade) if not langs: continue # Add the geo prior, which will trigger sampling geoprior = xml.geoprior(multi, id="%s.geoPrior" % clade, spec="sphericalGeo.GeoPrior", location="@location.geo", tree="@Tree.t:beastlingTree") if len(langs) > 1: self.beastxml.add_taxon_set(geoprior, "%s.geo" % clade, langs) else: xml.taxon(geoprior, idref=list(langs)[0]) # Drop back to F, not F2, so singletons can be sampled distribution.set( "spec", "sphericalGeo.ApproxMultivariateTraitLikelihoodF") # Also add the KML file if we have an actual constraint if clade in self.geo_priors: xml.region(geoprior, spec="sphericalGeo.region.KMLRegion", kml=self.geo_priors[clade]) self.add_sitemodel(distribution) xml.branchRateModel(distribution, idref=self.clock.branchrate_model_id)
def add_pruned_branchrate_model(self, distribution, name, tree_id): # For StrictClocks, it's safe to just reuse the global branchRateModel self.branchrate = xml.branchRateModel(distribution, idref=self.branchrate_model_id)
def add_branchrate_model(self, beast): xml.branchRateModel( beast, id="StrictClockModel.c:%s" % self.name, spec="beast.evolution.branchratemodel.StrictClockModel", attrib={"clock.rate": "@clockRate.c:%s" % self.name})