Beispiel #1
0
    def calcUnconstrainedLogLikelihood1(self):
        """Calculate likelihood under the multinomial model.

        This calculates the unconstrained (multinomial) log like
        without regard to character partitions.  The result is placed
        in the data variable unconstrainedLogLikelihood.  If there is
        more than one partition, it makes a new temporary alignment
        and puts all the sequences in one part in that alignment.  So
        it ultimately only works on one data partition.  If there is
        more than one alignment, there is possibly more than one
        datatype, and so this method will refuse to do it.  Note that
        the unconstrained log like of the combined data is not the sum
        of the unconstrained log likes of the separate partitions.

        See also calcUnconstrainedLogLikelihood2

        """

        if len(self.alignments) > 1:
            gm = ["Data.calcUnconstrainedLogLikelihood()"]
            gm.append(
                "This method is not implemented for more than one alignment.")
            raise Glitch, gm
        if self.nParts == 1:  # no problem
            self.unconstrainedLogLikelihood = pf.getUnconstrainedLogLike(
                self.parts[0].cPart)
        else:
            a = self.alignments[0]
            import copy
            newAlig = Alignment()
            newAlig.dataType = a.dataType
            newAlig.symbols = a.symbols
            newAlig.dim = a.dim
            newAlig.equates = a.equates
            newAlig.taxNames = a.taxNames
            for s in a.sequences:
                newAlig.sequences.append(copy.deepcopy(s))
            newAlig.checkLengthsAndTypes()
            newAlig._initParts()
            #newAlig.dump()
            self.unconstrainedLogLikelihood = pf.getUnconstrainedLogLike(
                newAlig.parts[0].cPart)
            del (newAlig)
Beispiel #2
0
    def calcUnconstrainedLogLikelihood1(self):
        """Calculate likelihood under the multinomial model.

        This calculates the unconstrained (multinomial) log like
        without regard to character partitions.  The result is placed
        in the data variable unconstrainedLogLikelihood.  If there is
        more than one partition, it makes a new temporary alignment
        and puts all the sequences in one part in that alignment.  So
        it ultimately only works on one data partition.  If there is
        more than one alignment, there is possibly more than one
        datatype, and so this method will refuse to do it.  Note that
        the unconstrained log like of the combined data is not the sum
        of the unconstrained log likes of the separate partitions.

        See also calcUnconstrainedLogLikelihood2

        """

        if len(self.alignments) > 1:
            gm = ["Data.calcUnconstrainedLogLikelihood()"]
            gm.append("This method is not implemented for more than one alignment.")
            raise Glitch, gm
        if self.nParts == 1:  # no problem
            self.unconstrainedLogLikelihood = pf.getUnconstrainedLogLike(self.parts[0].cPart)
        else:
            a = self.alignments[0]
            import copy
            newAlig = Alignment()
            newAlig.dataType = a.dataType
            newAlig.symbols = a.symbols
            newAlig.dim = a.dim
            newAlig.equates = a.equates
            newAlig.taxNames = a.taxNames
            for s in a.sequences:
                newAlig.sequences.append(copy.deepcopy(s))
            newAlig.checkLengthsAndTypes()
            newAlig._initParts()
            #newAlig.dump()
            self.unconstrainedLogLikelihood = pf.getUnconstrainedLogLike(newAlig.parts[0].cPart)
            del(newAlig)