def setUp(self):
random.seed(<NUM_LIT:1>)<EOL>scipy.random.seed(<NUM_LIT:1>)<EOL>self.underflowfreq = <NUM_LIT:1><EOL>self.newick = ('<STR_LIT>')<EOL>tempfile = '<STR_LIT>'<EOL>with open(tempfile, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(self.newick)<EOL><DEDENT>self.tree = Bio.Phylo.read(tempfile, '<STR_LIT>')<EOL>os.remove(tempfile)<EOL>pyvolvetree = pyvolve.read_tree(tree=self.newick)<EOL>self.nsites = <NUM_LIT:50><EOL>self.nseqs = self.tree.count_terminals()<EOL>e_pw = scipy.ndarray((<NUM_LIT:3>, N_NT), dtype='<STR_LIT:float>')<EOL>e_pw.fill(<NUM_LIT>)<EOL>yngkp_m0 = phydmslib.models.YNGKP_M0(e_pw, self.nsites)<EOL>partitions = phydmslib.simulate.pyvolvePartitions(yngkp_m0)<EOL>alignment = '<STR_LIT>'<EOL>info = '<STR_LIT>'<EOL>rates = '<STR_LIT>'<EOL>evolver = pyvolve.Evolver(partitions=partitions, tree=pyvolvetree)<EOL>evolver(seqfile=alignment, infofile=info, ratefile=rates)<EOL>self.alignment = [(s.description, str(s.seq)) for s in Bio.SeqIO.parse(<EOL>alignment, '<STR_LIT>')]<EOL>for f in [alignment, info, rates]:<EOL><INDENT>os.remove(f)<EOL><DEDENT>assert len(self.alignment[<NUM_LIT:0>][<NUM_LIT:1>]) == self.nsites * <NUM_LIT:3><EOL>assert len(self.alignment) == self.nseqs<EOL>prefs = []<EOL>minpref = <NUM_LIT><EOL>g = scipy.random.dirichlet([<NUM_LIT:5>] * N_NT)<EOL>for r in range(self.nsites):<EOL><INDENT>rprefs = scipy.random.dirichlet([<NUM_LIT:0.5>] * N_AA)<EOL>rprefs[rprefs < minpref] = minpref<EOL>rprefs /= rprefs.sum()<EOL>prefs.append(dict(zip(sorted(AA_TO_INDEX.keys()), rprefs)))<EOL><DEDENT>if self.MODEL == phydmslib.models.ExpCM:<EOL><INDENT>self.model = phydmslib.models.ExpCM(prefs)<EOL><DEDENT>elif self.MODEL == phydmslib.models.ExpCM_empirical_phi:<EOL><INDENT>self.model = phydmslib.models.ExpCM_empirical_phi(prefs, g)<EOL><DEDENT>elif self.MODEL == phydmslib.models.ExpCM_empirical_phi_divpressure:<EOL><INDENT>divpressure = scipy.random.uniform(-<NUM_LIT:1>, <NUM_LIT:5>, self.nsites)<EOL>divpressure /= max(abs(divpressure))<EOL>self.model = phydmslib.models.ExpCM_empirical_phi_divpressure(<EOL>prefs, g, divpressure)<EOL><DEDENT>elif self.MODEL == phydmslib.models.YNGKP_M0:<EOL><INDENT>e_pw = scipy.random.uniform(<NUM_LIT>, <NUM_LIT>, size=(<NUM_LIT:3>, N_NT))<EOL>e_pw = e_pw / e_pw.sum(axis=<NUM_LIT:1>, keepdims=True)<EOL>self.model = phydmslib.models.YNGKP_M0(e_pw, self.nsites)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(self.MODEL))<EOL><DEDENT>if self.DISTRIBUTIONMODEL is None:<EOL><INDENT>pass<EOL><DEDENT>elif (self.DISTRIBUTIONMODEL == <EOL>phydmslib.models.GammaDistributedOmegaModel):<EOL><INDENT>self.model = self.DISTRIBUTIONMODEL(self.model, ncats=<NUM_LIT:4>)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(<EOL>self.DISTRIBUTIONMODEL))<EOL><DEDENT>
Set up parameters for test.