def setUp(self):
scipy.random.seed(<NUM_LIT:1>)<EOL>random.seed(<NUM_LIT:1>)<EOL>nsites = <NUM_LIT:1><EOL>minpref = <NUM_LIT><EOL>self.prefs = []<EOL>self.realprefs = []<EOL>for r in range(nsites):<EOL><INDENT>rprefs = scipy.random.dirichlet([<NUM_LIT:0.5>] * N_AA)<EOL>rprefs[rprefs < minpref] = minpref<EOL>rprefs /= rprefs.sum()<EOL>self.prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))<EOL>scipy.random.shuffle(rprefs)<EOL>self.realprefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))<EOL><DEDENT>self.kappa = <NUM_LIT><EOL>self.omega = <NUM_LIT><EOL>self.phi = scipy.random.dirichlet([<NUM_LIT:5>] * N_NT)<EOL>self.model = self.MODEL(self.prefs,<EOL>prior=None, kappa=self.kappa, omega=self.omega, phi=self.phi)<EOL>self.realmodel = phydmslib.models.ExpCM(self.realprefs,<EOL>kappa=self.kappa, omega=self.omega, mu=<NUM_LIT>, phi=self.phi)<EOL>treefile = os.path.abspath(os.path.join(os.path.dirname(__file__),<EOL>'<STR_LIT>'))<EOL>self.tree = Bio.Phylo.read(treefile, '<STR_LIT>')<EOL>self.tree.root_at_midpoint()<EOL>evolver = pyvolve.Evolver(<EOL>partitions=phydmslib.simulate.pyvolvePartitions(self.realmodel),<EOL>tree=pyvolve.read_tree(file=treefile))<EOL>alignmentfile = '<STR_LIT>'<EOL>info = '<STR_LIT>'<EOL>rates = '<STR_LIT>'<EOL>evolver(seqfile=alignmentfile, infofile=info, ratefile=rates)<EOL>self.alignment = phydmslib.file_io.ReadCodonAlignment(alignmentfile, True)<EOL>assert len(self.alignment[<NUM_LIT:0>][<NUM_LIT:1>]) == nsites * <NUM_LIT:3><EOL>for f in [alignmentfile, info, rates]:<EOL><INDENT>os.remove(f)<EOL><DEDENT>self.codoncounts = dict([(r, dict([(INDEX_TO_CODON[c], <NUM_LIT:0>)<EOL>for c in range(N_CODON)])) for r in range(nsites)])<EOL>self.aacounts = dict([(r, dict([(a, <NUM_LIT:0>) for a in range(N_AA)]))<EOL>for r in range(nsites)])<EOL>for (head, seq) in self.alignment:<EOL><INDENT>self.codoncounts[r][seq] += <NUM_LIT:1><EOL>self.aacounts[r][CODON_TO_AA[CODON_TO_INDEX[seq]]] += <NUM_LIT:1><EOL><DEDENT>self.tl = phydmslib.treelikelihood.TreeLikelihood(self.tree,<EOL>self.alignment, self.model)<EOL>
Set up for tests.