-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
def get_clade(species, clades_to_species): | ||
""" | ||
Checks for a list of species which clade matches best (fewest other species in the clade). | ||
:param species: list of species for which the best clade needs to be determined | ||
:param clades_to_species: dict with clade names (keys) and lists of species (values) | ||
:return: tuple of the clade name | ||
""" | ||
for c in sorted(clades_to_species.keys(), key=lambda k: len(clades_to_species[k])): | ||
cs = clades_to_species[c] | ||
if all([s in cs for s in species]): | ||
return c, cs | ||
else: | ||
return None, [] | ||
|
||
|
||
def is_duplication(set_one, set_two, clades_to_species): | ||
""" | ||
Check if two sets of species are shared or not | ||
:param set_one: | ||
:param set_two: | ||
:param clades_to_species: | ||
:return: | ||
""" | ||
_, species_one = get_clade(set_one, clades_to_species) | ||
_, species_two = get_clade(set_two, clades_to_species) | ||
|
||
return any([s in species_two for s in species_one]) |