def calculate_region(arg): prot, start, win, nseqs, trop_dict = arg fname = 'phyliptrees/%s-%i-%i.tree' % (prot, start, win) if os.path.exists(fname): contree = dendropy.Tree.get_from_path(fname, 'nexus') treeset = dendropy.TreeList.get_from_path(fname + 'set', 'nexus') else: alphabet = generic_protein if prot != 'LTR' else generic_dna contree = TreeingTools.phylip_tree(nseqs, alphabet=alphabet) treeset = dendropy.TreeList([contree]) contree.write_to_path(fname, 'nexus') treeset.write_to_path(fname + 'set', 'nexus') try: bats_res = TreeingTools.run_bats(treeset, trop_dict, nreps = 1000) except: bats_res = None try: dmat = TreeingTools.get_pairwise_distances(contree) benj_res = TreeingTools.check_distance_pvals(dmat, trop_dict, nreps = 50) except: benj_res = None return prot, win, start, bats_res, benj_res
def test_phylip_tree(): seqs = tree_seqs() tree, _ = TreeingTools.phylip_tree(seqs, alphabet=generic_dna) for tst in check_tree(tree): yield tst