# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# N_NT = len(INDEX_TO_NT)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_AA = len(INDEX_TO_AA)
# 
# CODON_TO_INDEX = {}


import os
import re
import math
import unittest
import random
import copy
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX,
                                 N_AA, CODON_TO_INDEX)

    def test_Likelihood(self):
        """Tests likelihood."""
        random.seed(1)
        numpy.random.seed(1)

        if self.DISTRIBUTIONMODEL:
            return  # test doesn't work for DistributionModel
        mus = [0.5, 1.5]
        partials_by_mu = {}
        siteloglik_by_mu = {}
        loglik_by_mu = {}
        for mu in mus:
            model = copy.deepcopy(self.model)
            model.updateParams({"mu": mu})
            tl = phydmslib.treelikelihood.TreeLikelihood(self.tree,
                                                         self.alignment,
                                                         model)
            # Here we are doing the multiplication hand-coded for the
            # tree defined in `setUp`. This calculation would be wrong
            # if the tree in `setUp` were to be changed.
            M = {}
            for (node, t) in self.brlen.items():
                M[node] = model.M(t / model.branchScale)
            # compute partials at root node
            partials = numpy.zeros(shape=(self.nsites, N_CODON))
            siteloglik = numpy.zeros(shape=(self.nsites,))
            loglik = 0.0
            for r in range(self.nsites):
                for y in range(N_CODON):

# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# N_NT = len(INDEX_TO_NT)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# N_AA = len(INDEX_TO_AA)
# 
# CODON_TO_INDEX = {}


# Path: tests/test_treelikelihood.py
import os
import re
import math
import unittest
import random
import copy
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX,
                                 N_AA, CODON_TO_INDEX)


    def test_Likelihood(self):
        """Tests likelihood."""
        random.seed(1)
        numpy.random.seed(1)

        if self.DISTRIBUTIONMODEL:
            return  # test doesn't work for DistributionModel
        mus = [0.5, 1.5]
        partials_by_mu = {}
        siteloglik_by_mu = {}
        loglik_by_mu = {}
        for mu in mus:
            model = copy.deepcopy(self.model)
            model.updateParams({"mu": mu})
            tl = phydmslib.treelikelihood.TreeLikelihood(self.tree,
                                                         self.alignment,
                                                         model)
            # Here we are doing the multiplication hand-coded for the
            # tree defined in `setUp`. This calculation would be wrong
            # if the tree in `setUp` were to be changed.
            M = {}
            for (node, t) in self.brlen.items():
                M[node] = model.M(t / model.branchScale)
            # compute partials at root node
            partials = numpy.zeros(shape=(self.nsites, N_CODON))
            siteloglik = numpy.zeros(shape=(self.nsites,))
            loglik = 0.0
            for r in range(self.nsites):
                for y in range(N_CODON):

                    for x in range(N_CODON):