# Path: phydmslib/constants.py
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}


import os
import unittest
import subprocess
import random
import pandas
import scipy.stats
import phydmslib.file_io
import phydmslib.models
import phydmslib.simulate
import matplotlib
import matplotlib.pyplot as plt
import pyvolve
import numpy
from phydmslib.constants import INDEX_TO_AA, N_AA, AA_TO_INDEX
"""

matplotlib.use('pdf')


class test_DiffPrefsBySiteExpCM(unittest.TestCase):
    """Tests ``--diffprefsbysite`` to ``phydms`` for `ExpCM`."""

    gammaomega_arg = []

    def setUp(self):
        """Set up test."""
        random.seed(1)
        numpy.random.seed(1)
        self.tree = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                    './NP_data/NP_tree.newick'))
        self.align = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                     './NP_data/NP_alignment.fasta'))
        self.prefs = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                     './NP_data/NP_prefs.tsv'))
        self.nsites = len(phydmslib.file_io
                          .ReadCodonAlignment(self.align, True)[0][1]) // 3
        prefs = phydmslib.file_io.readPrefs(self.prefs, minpref=0.005)
        aas = [INDEX_TO_AA[a] for a in range(N_AA)]
        self.shuffledsites = random.sample(sorted(prefs.keys()), 10)
        self.targetaas = {r: random.choice(aas) for r in self.shuffledsites}
        prefs = [prefs[r] for r in sorted(prefs.keys())]
        hipref = 0.9
        lowpref = (1.0 - hipref) / (N_AA - 1)
        for r in self.shuffledsites:

# Path: phydmslib/constants.py
# INDEX_TO_AA = dict(enumerate('ACDEFGHIKLMNPQRSTVWY'))
# 
# N_AA = len(INDEX_TO_AA)
# 
# AA_TO_INDEX = {aa: i for (i, aa) in INDEX_TO_AA.items()}


# Path: tests/test_diffprefsbysite.py
import os
import unittest
import subprocess
import random
import pandas
import scipy.stats
import phydmslib.file_io
import phydmslib.models
import phydmslib.simulate
import matplotlib
import matplotlib.pyplot as plt
import pyvolve
import numpy
from phydmslib.constants import INDEX_TO_AA, N_AA, AA_TO_INDEX

"""

matplotlib.use('pdf')


class test_DiffPrefsBySiteExpCM(unittest.TestCase):
    """Tests ``--diffprefsbysite`` to ``phydms`` for `ExpCM`."""

    gammaomega_arg = []

    def setUp(self):
        """Set up test."""
        random.seed(1)
        numpy.random.seed(1)
        self.tree = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                    './NP_data/NP_tree.newick'))
        self.align = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                     './NP_data/NP_alignment.fasta'))
        self.prefs = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                     './NP_data/NP_prefs.tsv'))
        self.nsites = len(phydmslib.file_io
                          .ReadCodonAlignment(self.align, True)[0][1]) // 3
        prefs = phydmslib.file_io.readPrefs(self.prefs, minpref=0.005)
        aas = [INDEX_TO_AA[a] for a in range(N_AA)]
        self.shuffledsites = random.sample(sorted(prefs.keys()), 10)
        self.targetaas = {r: random.choice(aas) for r in self.shuffledsites}
        prefs = [prefs[r] for r in sorted(prefs.keys())]
        hipref = 0.9
        lowpref = (1.0 - hipref) / (N_AA - 1)
        for r in self.shuffledsites:

            rprefs = [lowpref] * N_AA