Ejemplo n.º 1
0
def _commonCStuff(self, resetEmpiricalComps=True):
    """Allocate and set c-stuff, and setPrams."""
    if not self.data:
        if self.name:
            gm = ["Tree %s  (_commonCStuff)" % self.name]
        else:
            gm = ["Tree (_commonCStuff)"]
        gm.append(
            "This tree has no data attached.  Before doing an optimization, likelihood"
        )
        gm.append(
            "calculation, or simulation, you need to do something like this:")
        gm.append("    theTree.data = theData")
        raise Glitch, gm

    #print "self.cTree = %s" % self.cTree
    if not self.cTree:
        # This calls self.modelSanityCheck(), which calls self.setEmpiricalComps()
        self.allocCStuff(resetEmpiricalComps=resetEmpiricalComps)
    #print "About to self.model.setCStuff()"
    self.model.setCStuff()
    #print "About to self.setCStuff()"
    self.setCStuff()
    #print "about to p4_setPrams()..."
    pf.p4_setPrams(self.cTree, -1)  # "-1" means do all parts
Ejemplo n.º 2
0
    def _commonCStuff(self, resetEmpiricalComps=True):
        """Allocate and set c-stuff, and setPrams."""
        if not self.data:
            if self.name:
                gm = ["Tree %s  (_commonCStuff)" % self.name]
            else:
                gm = ["Tree (_commonCStuff)"]
            gm.append(
                "This tree has no data attached.  Before doing an optimization, likelihood")
            gm.append(
                "calculation, or simulation, you need to do something like this:")
            gm.append("    theTree.data = theData")
            raise P4Error(gm)

        # print "self.cTree = %s" % self.cTree
        if not self.cTree:
            # This calls self.modelSanityCheck(), which calls
            # self.setEmpiricalComps()
            self._allocCStuff(resetEmpiricalComps=resetEmpiricalComps)
        # print "About to self.model.setCStuff()"
        self.model.setCStuff()
        # print "About to self.setCStuff()"
        self.setCStuff()
        # print "about to p4_setPrams()..."
        pf.p4_setPrams(self.cTree, -1)  # "-1" means do all parts
Ejemplo n.º 3
0
def optTest(self):
    self._commonCStuff()
    theStartTime = time.clock()
    doXfer = 0
    for i in range(1):
        if doXfer:
            self.model.setCStuff()
            self.setCStuff()
        pf.p4_setPrams(self.cTree, -1)
        self.logLike = pf.p4_treeLogLike(self.cTree, 0)

        if doXfer:
            # get the brLens
            brLens = pf.p4_getBrLens(self.cTree)
            for i in range(len(self.nodes)):
                n = self.nodes[i]
                if n != self.root:
                    n.br.len = brLens[i]

            # get the other free prams
            prams = pf.p4_getFreePrams(self.cTree)
            self.model.restoreFreePrams(prams)

    print "time %s seconds." % (time.clock() - theStartTime)
Ejemplo n.º 4
0
def optTest(self):
    self._commonCStuff()
    theStartTime = time.clock()
    doXfer = 0
    for i in range(1):
        if doXfer:
            self.model.setCStuff()
            self.setCStuff()
        pf.p4_setPrams(self.cTree, -1)
        self.logLike = pf.p4_treeLogLike(self.cTree, 0)

        if doXfer:
            # get the brLens
            brLens = pf.p4_getBrLens(self.cTree)
            for i in range(len(self.nodes)):
                n = self.nodes[i]
                if n != self.root:
                    n.br.len = brLens[i]

            # get the other free prams
            prams = pf.p4_getFreePrams(self.cTree)
            self.model.restoreFreePrams(prams)

    print("time %s seconds." % (time.clock() - theStartTime))