# 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
        self.modelarg = 'ExpCM_{0}'.format(self.prefs)

        if not os.path.isdir(self.outdir):
            os.mkdir(self.outdir)

    def test_OnSimulatedData(self):
        """Run ``phydms`` on the simulated data."""
        random.seed(1)
        numpy.random.seed(1)
        partitions = phydmslib.simulate.pyvolvePartitions(self.model)
        evolver = pyvolve.Evolver(partitions=partitions,
                                  tree=pyvolve.read_tree(file=self.tree))
        simulateprefix = os.path.join(self.outdir, self.modelname)
        simulatedalignment = simulateprefix + '_simulatedalignment.fasta'
        info = simulateprefix + '_temp_info.txt'
        rates = simulateprefix + '_temp_ratefile.txt'
        evolver(seqfile=simulatedalignment, infofile=info, ratefile=rates)

        prefsbymethod = {}
        for fitprefsmethod in ['1', '2']:
            outprefix = simulateprefix + '_fitprefsmethod{0}'.format(
                    fitprefsmethod)
            subprocess.check_call(['phydms', simulatedalignment, self.tree,
                                   self.modelarg, outprefix,
                                   '--diffprefsbysite', '--brlen', 'scale',
                                   '--ncpus', '-1', '--diffprefsprior',
                                   'invquadratic,150,0.5'] +
                                  self.gammaomega_arg +
                                  ['--fitprefsmethod', fitprefsmethod])
            diffprefsbysitefile = outprefix + '_diffprefsbysite.txt'

# 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

        self.modelarg = 'ExpCM_{0}'.format(self.prefs)

        if not os.path.isdir(self.outdir):
            os.mkdir(self.outdir)

    def test_OnSimulatedData(self):
        """Run ``phydms`` on the simulated data."""
        random.seed(1)
        numpy.random.seed(1)
        partitions = phydmslib.simulate.pyvolvePartitions(self.model)
        evolver = pyvolve.Evolver(partitions=partitions,
                                  tree=pyvolve.read_tree(file=self.tree))
        simulateprefix = os.path.join(self.outdir, self.modelname)
        simulatedalignment = simulateprefix + '_simulatedalignment.fasta'
        info = simulateprefix + '_temp_info.txt'
        rates = simulateprefix + '_temp_ratefile.txt'
        evolver(seqfile=simulatedalignment, infofile=info, ratefile=rates)

        prefsbymethod = {}
        for fitprefsmethod in ['1', '2']:
            outprefix = simulateprefix + '_fitprefsmethod{0}'.format(
                    fitprefsmethod)
            subprocess.check_call(['phydms', simulatedalignment, self.tree,
                                   self.modelarg, outprefix,
                                   '--diffprefsbysite', '--brlen', 'scale',
                                   '--ncpus', '-1', '--diffprefsprior',
                                   'invquadratic,150,0.5'] +
                                  self.gammaomega_arg +
                                  ['--fitprefsmethod', fitprefsmethod])
            diffprefsbysitefile = outprefix + '_diffprefsbysite.txt'

            aas = ['dpi_{0}'.format(INDEX_TO_AA[a]) for a in range(N_AA)]