Mercurial > repos > earlhaminst > ete
comparison ete_homology_classifier.py @ 13:ed74587a13c8 draft
planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/ete commit 23b3c7c09a7d391b576e3b19f8b34dd63d636bdc
author | earlhaminst |
---|---|
date | Thu, 01 Sep 2022 16:11:32 +0000 |
parents | f1eca1158f21 |
children |
comparison
equal
deleted
inserted
replaced
12:dc32007a6b36 | 13:ed74587a13c8 |
---|---|
27 | 27 |
28 leaves_list = genetree.get_leaf_names() | 28 leaves_list = genetree.get_leaf_names() |
29 # Genetree nodes are required to be in gene_species format | 29 # Genetree nodes are required to be in gene_species format |
30 leaves_list = [_ for _ in leaves_list if '_' in _] | 30 leaves_list = [_ for _ in leaves_list if '_' in _] |
31 | 31 |
32 species_list = [_.split("_")[1] for _ in leaves_list] | 32 species_list = [_.split("_")[-1] for _ in leaves_list] |
33 | 33 |
34 species_dict = {} | 34 species_dict = {} |
35 for species in species_list: | 35 for species in species_list: |
36 count = "one" | 36 count = "one" |
37 if species in species_dict: | 37 if species in species_dict: |
49 # stores relevant homology types in dict | 49 # stores relevant homology types in dict |
50 for i, leaf1 in enumerate(leaves_list): | 50 for i, leaf1 in enumerate(leaves_list): |
51 for leaf2 in leaves_list[i + 1:]: | 51 for leaf2 in leaves_list[i + 1:]: |
52 id1 = leaf1.split(":")[1] if ":" in leaf1 else leaf1 | 52 id1 = leaf1.split(":")[1] if ":" in leaf1 else leaf1 |
53 id2 = leaf2.split(":")[1] if ":" in leaf2 else leaf2 | 53 id2 = leaf2.split(":")[1] if ":" in leaf2 else leaf2 |
54 species1 = id1.split("_")[1] | 54 species1 = id1.split("_")[-1] |
55 species2 = id2.split("_")[1] | 55 species2 = id2.split("_")[-1] |
56 if species1 == species2: | 56 if species1 == species2: |
57 homology_type = 'paralogs' | 57 homology_type = 'paralogs' |
58 else: | 58 else: |
59 homology_type = species_dict[species1] + "-to-" + species_dict[species2] | 59 homology_type = species_dict[species1] + "-to-" + species_dict[species2] |
60 homologies[homology_type].append((id1, id2)) | 60 homologies[homology_type].append((id1, id2)) |