# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# 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)
# 
# CODON_TO_INDEX = {}


import os
import re
import math
import unittest
import random
import copy
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX,
                                 N_AA, CODON_TO_INDEX)

    # use approach here to run multiple tests:
    # http://stackoverflow.com/questions/17260469/instantiate-python-unittest-testcase-with-arguments
    MODEL = phydmslib.models.ExpCM
    DISTRIBUTIONMODEL = None

    def setUp(self):
        """Set up parameters for test."""
        random.seed(1)
        numpy.random.seed(1)

        # define tree
        self.newick = "((node1:0.2,node2:0.3)node4:0.3,node3:0.5)node5:0.04;"
        tempfile = "_temp.tree"
        with open(tempfile, "w") as f:
            f.write(self.newick)
        self.tree = Bio.Phylo.read(tempfile, "newick")
        os.remove(tempfile)
        self.brlen = {}
        for (name, brlen) in re.findall(
            r"(?P<name>node\d):(?P<brlen>\d+\.\d+)", self.newick
        ):
            if name != self.tree.root.name:
                i = name[-1]  # node number
                self.brlen[int(i)] = float(brlen)

        # simulate alignment with pyvolve
        pyvolvetree = pyvolve.read_tree(tree=self.newick)
        self.nsites = 60
        self.nseqs = self.tree.count_terminals()

# Path: phydmslib/constants.py
# N_CODON = len(CODON_TO_INDEX)
# 
# 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)
# 
# CODON_TO_INDEX = {}


# Path: tests/test_treelikelihood.py
import os
import re
import math
import unittest
import random
import copy
import numpy
import scipy.optimize
import Bio.Phylo
import phydmslib.models
import phydmslib.treelikelihood
import phydmslib.simulate
import pyvolve
from phydmslib.constants import (N_CODON, N_NT, AA_TO_INDEX,
                                 N_AA, CODON_TO_INDEX)


    # use approach here to run multiple tests:
    # http://stackoverflow.com/questions/17260469/instantiate-python-unittest-testcase-with-arguments
    MODEL = phydmslib.models.ExpCM
    DISTRIBUTIONMODEL = None

    def setUp(self):
        """Set up parameters for test."""
        random.seed(1)
        numpy.random.seed(1)

        # define tree
        self.newick = "((node1:0.2,node2:0.3)node4:0.3,node3:0.5)node5:0.04;"
        tempfile = "_temp.tree"
        with open(tempfile, "w") as f:
            f.write(self.newick)
        self.tree = Bio.Phylo.read(tempfile, "newick")
        os.remove(tempfile)
        self.brlen = {}
        for (name, brlen) in re.findall(
            r"(?P<name>node\d):(?P<brlen>\d+\.\d+)", self.newick
        ):
            if name != self.tree.root.name:
                i = name[-1]  # node number
                self.brlen[int(i)] = float(brlen)

        # simulate alignment with pyvolve
        pyvolvetree = pyvolve.read_tree(tree=self.newick)
        self.nsites = 60
        self.nseqs = self.tree.count_terminals()

        e_pw = numpy.ndarray((3, N_NT), dtype="float")