# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# NT_TO_INDEX = {nt: i for (i, nt) in INDEX_TO_NT.items()}
# 
# CODON_TO_AA = []
# 
# INDEX_TO_CODON = {}
# 
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_TRANSITION = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# 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)


import random
import unittest
import numpy
import scipy.linalg
import scipy.optimize
import sympy
import phydmslib.models
from phydmslib.constants import (N_CODON, NT_TO_INDEX, CODON_TO_AA,
                                 INDEX_TO_CODON, INDEX_TO_AA, CODON_SINGLEMUT,
                                 CODON_TRANSITION, CODON_NONSYN, N_NT,
                                 AA_TO_INDEX, N_AA)
"""Tests `phydmslib.models.ExpCM` class.

Written by Jesse Bloom.

Uses `sympy` to make sure attributes and derivatives of attributes
are correct for `ExpCM` implemented in `phydmslib.models`.
"""




class testExpCM(unittest.TestCase):
    """Tests ``ExpCM`` model."""

    def test_ExpCM(self):
        """Initialize `ExpCM`, test values, update, test again."""
        # create preferences
        random.seed(1)
        numpy.random.seed(1)
        self.nsites = 2
        self.prefs = []
        minpref = 0.01
        for _r in range(self.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)))

        # create initial ExpCM

# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# NT_TO_INDEX = {nt: i for (i, nt) in INDEX_TO_NT.items()}
# 
# CODON_TO_AA = []
# 
# INDEX_TO_CODON = {}
# 
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_TRANSITION = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# 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)


# Path: tests/test_expcm.py
import random
import unittest
import numpy
import scipy.linalg
import scipy.optimize
import sympy
import phydmslib.models
from phydmslib.constants import (N_CODON, NT_TO_INDEX, CODON_TO_AA,
                                 INDEX_TO_CODON, INDEX_TO_AA, CODON_SINGLEMUT,
                                 CODON_TRANSITION, CODON_NONSYN, N_NT,
                                 AA_TO_INDEX, N_AA)

"""Tests `phydmslib.models.ExpCM` class.

Written by Jesse Bloom.

Uses `sympy` to make sure attributes and derivatives of attributes
are correct for `ExpCM` implemented in `phydmslib.models`.
"""




class testExpCM(unittest.TestCase):
    """Tests ``ExpCM`` model."""

    def test_ExpCM(self):
        """Initialize `ExpCM`, test values, update, test again."""
        # create preferences
        random.seed(1)
        numpy.random.seed(1)
        self.nsites = 2
        self.prefs = []
        minpref = 0.01
        for _r in range(self.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)))

        # create initial ExpCM

        phi = numpy.random.dirichlet([2] * N_NT)