Mercurial > repos > earlhaminst > ete
changeset 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 | dc32007a6b36 |
children | d40b9a7debe5 |
files | ete_gene_cnv.py ete_homology_classifier.py |
diffstat | 2 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ete_gene_cnv.py Tue Jun 07 08:58:05 2022 +0000 +++ b/ete_gene_cnv.py Thu Sep 01 16:11:32 2022 +0000 @@ -45,10 +45,10 @@ leaves_parts = [_.split("_") for _ in leaves] for i, leaf_parts in enumerate(leaves_parts): - if len(leaf_parts) != 2: + if len(leaf_parts) < 2: raise Exception("Leaf node '%s' is not in gene_species format" % leaves[i]) - leaves_species = [_[1] for _ in leaves_parts] + leaves_species = [_[-1] for _ in leaves_parts] species_counter = collections.Counter(leaves_species) # Assign to ref_species the first element of species_list which @@ -61,8 +61,8 @@ # Find the gene of the (first) leaf node for the ref_species for leaf_parts in leaves_parts: - if leaf_parts[1] == ref_species: - species_counter['gene'] = leaf_parts[0] + if leaf_parts[-1] == ref_species: + species_counter['gene'] = "_".join(leaf_parts[:-1]) break table.append(species_counter)
--- a/ete_homology_classifier.py Tue Jun 07 08:58:05 2022 +0000 +++ b/ete_homology_classifier.py Thu Sep 01 16:11:32 2022 +0000 @@ -29,7 +29,7 @@ # Genetree nodes are required to be in gene_species format leaves_list = [_ for _ in leaves_list if '_' in _] - species_list = [_.split("_")[1] for _ in leaves_list] + species_list = [_.split("_")[-1] for _ in leaves_list] species_dict = {} for species in species_list: @@ -51,8 +51,8 @@ for leaf2 in leaves_list[i + 1:]: id1 = leaf1.split(":")[1] if ":" in leaf1 else leaf1 id2 = leaf2.split(":")[1] if ":" in leaf2 else leaf2 - species1 = id1.split("_")[1] - species2 = id2.split("_")[1] + species1 = id1.split("_")[-1] + species2 = id2.split("_")[-1] if species1 == species2: homology_type = 'paralogs' else: