# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_TRANSITION = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# ALMOST_ZERO = 1.0e-6
# 
# CODON_NT_INDEX = numpy.full((3, N_CODON), -1, dtype='int')
# 
# STOP_CODON_TO_NT_INDICES = []
# 
# N_STOP = 0
# 
# N_NT = len(INDEX_TO_NT)
# 
# N_AA = len(INDEX_TO_AA)
# 
# INDEX_TO_NT = dict(enumerate('ACGT'))
# 
# CODON_NT_MUT = numpy.full((N_NT, N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NT_COUNT = numpy.zeros((N_NT, N_CODON), dtype='int')
# 
# CODON_TO_AA = []
# 
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# CODON_NT = numpy.full((3, N_NT, N_CODON), False, dtype='bool')


import copy
import six
import abc
import warnings
import numpy
import scipy.misc
import scipy.optimize
import scipy.linalg
import scipy.stats
import scipy.special
    import doctest
from phydmslib.numutils import (broadcastMatrixMultiply,
                                broadcastMatrixVectorMultiply,
                                broadcastGetCols)
from phydmslib.constants import (N_CODON, CODON_NONSYN, CODON_TRANSITION,
                                 CODON_SINGLEMUT, ALMOST_ZERO, CODON_NT_INDEX,
                                 STOP_CODON_TO_NT_INDICES, N_STOP, N_NT, N_AA,
                                 INDEX_TO_NT, CODON_NT_MUT, CODON_NT_COUNT,
                                 CODON_TO_AA, INDEX_TO_AA, AA_TO_INDEX,
                                 CODON_NT)
                a fixed-preference `ExpCM` prior to initializing this model.
        """
        self.prior = prior
        if self.prior is None:
            pass
        elif (isinstance(self.prior, tuple) and len(self.prior) == 3 and
                self.prior[0] == 'invquadratic'):
            assert all((isinstance(c, (float, int)) and c > 0 for c
                        in self.prior[1:])),\
              ("Invalid C values in elements in prior: {0}".format(self.prior))
        else:
            raise ValueError("Invalid prior: {0}".format(self.prior))

        # PARAMTYPES must be instance attribute as zeta value depends on nsites
        self.PARAMTYPES = copy.deepcopy(ExpCM.PARAMTYPES)
        self.PARAMTYPES['zeta'] = (numpy.ndarray, (len(prefs) * (N_AA - 1),))

        self.beta = 1.0
        _checkParam('beta', origbeta, self.PARAMLIMITS, self.PARAMTYPES)
        self._origbeta = origbeta

        # _aa_for_x[x][y] is the x amino acid in indexing of codon matrices
        # _aa_for_y[x][y] is the y amino acid in indexing of codon matrices
        self._aa_for_y = numpy.tile(CODON_TO_AA, (N_CODON, 1))
        self._aa_for_x = self._aa_for_y.transpose()

        super(ExpCM_fitprefs, self).__init__(prefs, kappa=kappa, omega=omega,
                                             beta=self.beta, mu=mu, phi=phi,
                                             freeparams=freeparams)
        assert (self.PARAMTYPES['zeta'][1] == self.zeta.shape

# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# CODON_NONSYN = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_TRANSITION = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_SINGLEMUT = numpy.full((N_CODON, N_CODON), False, dtype='bool')
# 
# ALMOST_ZERO = 1.0e-6
# 
# CODON_NT_INDEX = numpy.full((3, N_CODON), -1, dtype='int')
# 
# STOP_CODON_TO_NT_INDICES = []
# 
# N_STOP = 0
# 
# N_NT = len(INDEX_TO_NT)
# 
# N_AA = len(INDEX_TO_AA)
# 
# INDEX_TO_NT = dict(enumerate('ACGT'))
# 
# CODON_NT_MUT = numpy.full((N_NT, N_CODON, N_CODON), False, dtype='bool')
# 
# CODON_NT_COUNT = numpy.zeros((N_NT, N_CODON), dtype='int')
# 
# CODON_TO_AA = []
# 
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}
# 
# CODON_NT = numpy.full((3, N_NT, N_CODON), False, dtype='bool')


# Path: phydmslib/models.py
import copy
import six
import abc
import warnings
import numpy
import scipy.misc
import scipy.optimize
import scipy.linalg
import scipy.stats
import scipy.special
    import doctest
from phydmslib.numutils import (broadcastMatrixMultiply,
                                broadcastMatrixVectorMultiply,
                                broadcastGetCols)
from phydmslib.constants import (N_CODON, CODON_NONSYN, CODON_TRANSITION,
                                 CODON_SINGLEMUT, ALMOST_ZERO, CODON_NT_INDEX,
                                 STOP_CODON_TO_NT_INDICES, N_STOP, N_NT, N_AA,
                                 INDEX_TO_NT, CODON_NT_MUT, CODON_NT_COUNT,
                                 CODON_TO_AA, INDEX_TO_AA, AA_TO_INDEX,
                                 CODON_NT)

                a fixed-preference `ExpCM` prior to initializing this model.
        """
        self.prior = prior
        if self.prior is None:
            pass
        elif (isinstance(self.prior, tuple) and len(self.prior) == 3 and
                self.prior[0] == 'invquadratic'):
            assert all((isinstance(c, (float, int)) and c > 0 for c
                        in self.prior[1:])),\
              ("Invalid C values in elements in prior: {0}".format(self.prior))
        else:
            raise ValueError("Invalid prior: {0}".format(self.prior))

        # PARAMTYPES must be instance attribute as zeta value depends on nsites
        self.PARAMTYPES = copy.deepcopy(ExpCM.PARAMTYPES)
        self.PARAMTYPES['zeta'] = (numpy.ndarray, (len(prefs) * (N_AA - 1),))

        self.beta = 1.0
        _checkParam('beta', origbeta, self.PARAMLIMITS, self.PARAMTYPES)
        self._origbeta = origbeta

        # _aa_for_x[x][y] is the x amino acid in indexing of codon matrices
        # _aa_for_y[x][y] is the y amino acid in indexing of codon matrices
        self._aa_for_y = numpy.tile(CODON_TO_AA, (N_CODON, 1))
        self._aa_for_x = self._aa_for_y.transpose()

        super(ExpCM_fitprefs, self).__init__(prefs, kappa=kappa, omega=omega,
                                             beta=self.beta, mu=mu, phi=phi,
                                             freeparams=freeparams)
        assert (self.PARAMTYPES['zeta'][1] == self.zeta.shape

                == (self.nsites * (N_AA - 1),))