# Path: phydmslib/constants.py
# ALMOST_ZERO = 1.0e-6
# 
# CODON_TO_INDEX = {}
# 
# N_CODON = len(CODON_TO_INDEX)


import copy
import warnings
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
    import doctest
from phydmslib.numutils import broadcastMatrixVectorMultiply
from phydmslib.constants import ALMOST_ZERO, CODON_TO_INDEX, N_CODON
                        self._dLshape[param] = (len(paramvalue),
                                                self.nsites, N_CODON)
                else:
                    raise ValueError("Cannot handle param: {0}, {1}".format(
                            param, paramvalue))
        tipnodes = []
        internalnodes = []
        self.tips = numpy.zeros((self.ntips, self.nsites), dtype='int')
        self.gaps = []
        self.descendants = []
        self._t = numpy.full((self.nnodes - 1,), -1, dtype='float')
        for node in self._tree.find_clades(order='postorder'):
            if node.is_terminal():
                tipnodes.append(node)
            else:
                internalnodes.append(node)
        for (n, node) in enumerate(tipnodes + internalnodes):
            if node != self._tree.root:
                assert n < self.nnodes - 1
                self._t[n] = node.branch_length
            if node.is_terminal():
                assert n < self.ntips
                self.descendants.append([])
                seq = alignment_d[node.name]
                nodegaps = []
                for r in range(self.nsites):
                    codon = seq[3 * r:3 * r + 3]
                    if codon == '---':
                        nodegaps.append(r)
                    elif codon in CODON_TO_INDEX:

# Path: phydmslib/constants.py
# ALMOST_ZERO = 1.0e-6
# 
# CODON_TO_INDEX = {}
# 
# N_CODON = len(CODON_TO_INDEX)


# Path: phydmslib/treelikelihood.py
import copy
import warnings
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
    import doctest
from phydmslib.numutils import broadcastMatrixVectorMultiply
from phydmslib.constants import ALMOST_ZERO, CODON_TO_INDEX, N_CODON

                        self._dLshape[param] = (len(paramvalue),
                                                self.nsites, N_CODON)
                else:
                    raise ValueError("Cannot handle param: {0}, {1}".format(
                            param, paramvalue))
        tipnodes = []
        internalnodes = []
        self.tips = numpy.zeros((self.ntips, self.nsites), dtype='int')
        self.gaps = []
        self.descendants = []
        self._t = numpy.full((self.nnodes - 1,), -1, dtype='float')
        for node in self._tree.find_clades(order='postorder'):
            if node.is_terminal():
                tipnodes.append(node)
            else:
                internalnodes.append(node)
        for (n, node) in enumerate(tipnodes + internalnodes):
            if node != self._tree.root:
                assert n < self.nnodes - 1
                self._t[n] = node.branch_length
            if node.is_terminal():
                assert n < self.ntips
                self.descendants.append([])
                seq = alignment_d[node.name]
                nodegaps = []
                for r in range(self.nsites):
                    codon = seq[3 * r:3 * r + 3]
                    if codon == '---':
                        nodegaps.append(r)
                    elif codon in CODON_TO_INDEX:

                        self.tips[n][r] = CODON_TO_INDEX[codon]