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


import random
import unittest
import copy
import os
import phydmslib.models
import phydmslib.file_io
import phydmslib.simulate
import phydmslib.treelikelihood
import pyvolve
import numpy
import Bio
from phydmslib.constants import (CODON_TO_INDEX, CODON_TO_AA, N_NT, N_AA,
                                 INDEX_TO_CODON, AA_TO_INDEX, N_CODON)
"""Tests `TreeLikelihood` with `ExpCM_fitprefs` and `ExpCM_fitprefs2`.

Written by Jesse Bloom.
"""




class test_TreeLikelihood_ExpCM_fitprefs(unittest.TestCase):
    """Test `ExpCM_fitprefs` in `TreeLikelihood`."""

    MODEL = phydmslib.models.ExpCM_fitprefs

    def setUp(self):
        """Set up for tests."""
        numpy.random.seed(1)
        random.seed(1)

        nsites = 1
        minpref = 0.001
        self.prefs = []
        self.realprefs = []
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.5] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs /= rprefs.sum()
            self.prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))
            numpy.random.shuffle(rprefs)

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


# Path: tests/test_treelikelihood_fitprefs.py
import random
import unittest
import copy
import os
import phydmslib.models
import phydmslib.file_io
import phydmslib.simulate
import phydmslib.treelikelihood
import pyvolve
import numpy
import Bio
from phydmslib.constants import (CODON_TO_INDEX, CODON_TO_AA, N_NT, N_AA,
                                 INDEX_TO_CODON, AA_TO_INDEX, N_CODON)

"""Tests `TreeLikelihood` with `ExpCM_fitprefs` and `ExpCM_fitprefs2`.

Written by Jesse Bloom.
"""




class test_TreeLikelihood_ExpCM_fitprefs(unittest.TestCase):
    """Test `ExpCM_fitprefs` in `TreeLikelihood`."""

    MODEL = phydmslib.models.ExpCM_fitprefs

    def setUp(self):
        """Set up for tests."""
        numpy.random.seed(1)
        random.seed(1)

        nsites = 1
        minpref = 0.001
        self.prefs = []
        self.realprefs = []
        for _r in range(nsites):
            rprefs = numpy.random.dirichlet([0.5] * N_AA)
            rprefs[rprefs < minpref] = minpref
            rprefs /= rprefs.sum()
            self.prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))
            numpy.random.shuffle(rprefs)

            self.realprefs.append(dict(zip(sorted(AA_TO_INDEX.keys()),