# 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)
                                kappa=self.kappa,
                                omega=self.omega,
                                phi=self.phi)
        self.realmodel = phydmslib.models.ExpCM(self.realprefs,
                                                kappa=self.kappa,
                                                omega=self.omega,
                                                mu=10.0,
                                                phi=self.phi)

        treefile = os.path.abspath(
            os.path.join(os.path.dirname(__file__),
                         "./NP_data/NP_tree.newick"))
        self.tree = Bio.Phylo.read(treefile, "newick")
        self.tree.root_at_midpoint()

        # simulate alignment using realmodel
        evolver = pyvolve.Evolver(
            partitions=phydmslib.simulate.pyvolvePartitions(self.realmodel),
            tree=pyvolve.read_tree(file=treefile))
        alignmentfile = "_temp_fitprefs_simulatedalignment.fasta"
        info = "_temp_info.txt"
        rates = "_temp_ratefile.txt"
        evolver(seqfile=alignmentfile, infofile=info, ratefile=rates)
        self.alignment = phydmslib.file_io.ReadCodonAlignment(alignmentfile,
                                                              True)
        assert len(self.alignment[0][1]) == nsites * 3
        for f in [alignmentfile, info, rates]:
            os.remove(f)
        self.codoncounts = {r: {INDEX_TO_CODON[c]: 0 for c in range(N_CODON)}
                            for r in range(nsites)}

# 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)

                                kappa=self.kappa,
                                omega=self.omega,
                                phi=self.phi)
        self.realmodel = phydmslib.models.ExpCM(self.realprefs,
                                                kappa=self.kappa,
                                                omega=self.omega,
                                                mu=10.0,
                                                phi=self.phi)

        treefile = os.path.abspath(
            os.path.join(os.path.dirname(__file__),
                         "./NP_data/NP_tree.newick"))
        self.tree = Bio.Phylo.read(treefile, "newick")
        self.tree.root_at_midpoint()

        # simulate alignment using realmodel
        evolver = pyvolve.Evolver(
            partitions=phydmslib.simulate.pyvolvePartitions(self.realmodel),
            tree=pyvolve.read_tree(file=treefile))
        alignmentfile = "_temp_fitprefs_simulatedalignment.fasta"
        info = "_temp_info.txt"
        rates = "_temp_ratefile.txt"
        evolver(seqfile=alignmentfile, infofile=info, ratefile=rates)
        self.alignment = phydmslib.file_io.ReadCodonAlignment(alignmentfile,
                                                              True)
        assert len(self.alignment[0][1]) == nsites * 3
        for f in [alignmentfile, info, rates]:
            os.remove(f)
        self.codoncounts = {r: {INDEX_TO_CODON[c]: 0 for c in range(N_CODON)}
                            for r in range(nsites)}

        self.aacounts = {r: {a: 0 for a in range(N_AA)} for r in range(nsites)}