# HG changeset patch # User earlhaminst # Date 1662048692 0 # Node ID ed74587a13c8b8d54be66251c6cccd905e5c7f1a # Parent dc32007a6b36c4be29835882d6a0541495df1f6a planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/ete commit 23b3c7c09a7d391b576e3b19f8b34dd63d636bdc diff -r dc32007a6b36 -r ed74587a13c8 ete_gene_cnv.py --- 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) diff -r dc32007a6b36 -r ed74587a13c8 ete_homology_classifier.py --- 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: