Example #1
0
 def add_init(self, beastxml):
     """
     Add the <init> element for the tree.
     """
     # If a starting tree is specified, use it...
     if beastxml.config.languages.starting_tree:
         beastxml.init = xml.init(
             beastxml.run,
             estimate="false",
             id="startingTree",
             initial="@Tree.t:beastlingTree",
             spec="beast.util.TreeParser",
             IsLabelledNewick="true",
             newick=beastxml.config.languages.starting_tree)
     # ...if not, use the simplest random tree initialiser possible
     else:
         # If we have non-trivial monophyly constraints, use ConstrainedRandomTree
         if beastxml.config.languages.monophyly and len(
                 beastxml.config.languages.languages) > 2:
             self.add_constrainedrandomtree_init(beastxml)
         # If we have hard-bound calibrations, use SimpleRandomTree
         elif any([
                 c.dist == "uniform"
                 for c in beastxml.config.calibrations.values()
         ]):
             self.add_simplerandomtree_init(beastxml)
         # Otherwise, just use RandomTree
         else:
             self.add_randomtree_init(beastxml)
Example #2
0
 def add_constrainedrandomtree_init(self, beastxml):
     attribs = {"estimate":"false", "id":"startingTree", "initial":"@Tree.t:beastlingTree", "taxonset":"@taxa", "spec":"beast.evolution.tree.ConstrainedRandomTree", "constraints":"@constraints"}
     if self.birthrate_estimate is not None:
         attribs["rootHeight"] = str(self.treeheight_estimate)
     beastxml.init = xml.init(beastxml.run, attrib=attribs)
     popmod = xml.populationModel(beastxml.init, spec="ConstantPopulation")
     xml.popSize(popmod, spec="parameter.RealParameter", value="1")
Example #3
0
 def add_simplerandomtree_init(self, beastxml):
     attribs = {
         "estimate": "false",
         "id": "startingTree",
         "initial": "@Tree.t:beastlingTree",
         "taxonset": "@taxa",
         "spec": "beast.evolution.tree.SimpleRandomTree"
     }
     if self.birthrate_estimate is not None:
         attribs["rootHeight"] = str(self.treeheight_estimate)
     beastxml.init = xml.init(beastxml.run, attrib=attribs)