Example #1
0
    def add_tracer_logger(self):
        """
        Add file logger, if configured to do so.
        """
        if not (self.config.admin.log_probabilities
                or self.config.admin.log_params):
            return
        tracer_logger = xml.logger(self.run,
                                   id="tracelog",
                                   fileName=self.config.admin.path(".log"),
                                   logEvery=self.config.admin.log_every,
                                   sort="smart")
        # Log prior, likelihood and posterior
        if self.config.admin.log_probabilities:
            xml.log(tracer_logger, idref="prior")
            xml.log(tracer_logger, idref="likelihood")
            xml.log(tracer_logger, idref="posterior")
        if self.config.admin.log_params:
            # Log tree metadata
            self.config.treeprior.add_logging(self, tracer_logger)
            for clock in self.config.clocks:
                clock.add_param_logs(tracer_logger)
            for model in self.config.all_models:
                model.add_param_logs(tracer_logger)

        # Log calibration clade heights
        for clade, cal in sorted(
                itertools.chain(self.config.calibrations.items(),
                                self.config.tip_calibrations.items())):
            # Don't log unchanging tip heights
            if cal.dist == "point":
                continue
            xml.log(tracer_logger, idref="%sMRCA" % clade.replace(" ", "_"))
Example #2
0
 def add_trait_logger(self, suffix=""):
     """Add a logger referencing all AncestralStateLogger likelihoods in the tree."""
     trait_logger = xml.logger(self.run,
                               fileName=self.config.admin.path(suffix +
                                                               ".log"),
                               logEvery=self.config.admin.log_every,
                               id="traitLogger" + suffix)
     for model in self.config.models:
         for reference in model.metadata:
             xml.log(trait_logger, idref=reference)
Example #3
0
 def add_trait_tree_logger(self, suffix=""):
     tree_logger = xml.logger(self.run,
                              mode="tree",
                              fileName=self.config.admin.path(suffix +
                                                              ".nex"),
                              logEvery=self.config.admin.log_every,
                              id="treeLogger" + suffix)
     log = xml.log(tree_logger,
                   id="ReconstructedStateTreeLogger",
                   spec="beast.evolution.tree.TreeWithTraitLogger",
                   tree="@{:}".format(self.config.treeprior.tree_id))
     for model in self.config.models:
         for md in model.treedata:
             xml.metadata(log, idref=md)
Example #4
0
 def add_screen_logger(self):
     """
     Add the screen logger, if configured to do so.
     """
     if self.config.admin.screenlog:
         screen_logger = xml.logger(self.run,
                                    id="screenlog",
                                    logEvery=self.config.admin.log_every)
         xml.log(screen_logger,
                 arg="@posterior",
                 id="ESS.0",
                 spec="util.ESS")
         xml.log(screen_logger, idref="prior")
         xml.log(screen_logger, idref="likelihood")
         xml.log(screen_logger, idref="posterior")
Example #5
0
 def add_tree_logger(self,
                     suffix="",
                     branchrate_model_id=None,
                     locations=False):
     tree_logger = xml.logger(self.run,
                              mode="tree",
                              fileName=self.config.admin.path(suffix +
                                                              ".nex"),
                              logEvery=self.config.admin.log_every,
                              id="treeLogger" + suffix)
     log = xml.log(tree_logger,
                   id="TreeLoggerWithMetaData" + suffix,
                   spec="beast.evolution.tree.TreeWithMetaDataLogger",
                   tree="@{:}".format(self.config.treeprior.tree_id),
                   dp=self.config.admin.log_dp)
     if branchrate_model_id:
         xml.branchratemodel(log, idref=branchrate_model_id)
     if locations:
         xml.metadata(log,
                      text="0.0",
                      id="location",
                      spec="sphericalGeo.TraitFunction",
                      likelihood="@sphericalGeographyLikelihood")