Skip to content

Commit

Permalink
Merge branch 'fix-completeness-score' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
alpae committed Sep 19, 2024
2 parents a06e4e3 + 6495533 commit 6aa6cbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 1 addition & 3 deletions FastOMA/_hog_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(self, input_instantiate, taxnomic_range:TreeNode, rhogid:str, msa:O
self._msa = MultipleSeqAlignment([only_protein])
self._subhogs = []
self._dubious_members = set()
self._num_species_tax_speciestree = 1 # at the leaf level, there is only one species in the species tree
# <<class 'Bio.Align.MultipleSeqAlignment'> instance (1 records of length 314) at 7f0e86c713d0>

elif msa and all(isinstance(x, HOG) for x in input_instantiate):
Expand All @@ -102,7 +101,6 @@ def __init__(self, input_instantiate, taxnomic_range:TreeNode, rhogid:str, msa:O
hog_members |= sub_hog.get_members()
self._members = hog_members # set.union(*tup) # this also include dubious_members
self._subhogs = list(input_instantiate) # full members of subhog, children
self._num_species_tax_speciestree = taxnomic_range.size
self._representatives = [r for r in representatives]
representatives_id = set(r.get_id() for r in representatives)
assert len(representatives_id) == len(self._representatives), "Non-unique ids among representatives"
Expand Down Expand Up @@ -337,7 +335,7 @@ def _sorter_key(sh):
#hog_elemnt = ET.Element('orthologGroup', attrib={"id": str(self._hogid)})
hog_elemnt = ET.Element('orthologGroup', attrib={"id": str(self._hogid)}, )
num_species_tax_hog = len(set([i.split("||")[1] for i in self._members])) # 'tr|H2MU14|H2MU14_ORYLA||ORYLA||1056022282'
completeness_score = round(num_species_tax_hog/self._num_species_tax_speciestree, 4)
completeness_score = round(num_species_tax_hog/self._tax_now.size, 4)
property_element = ET.SubElement(hog_elemnt, "score", attrib={"id": "CompletenessScore", "value": str(completeness_score)})
property_element = ET.SubElement(hog_elemnt, "property", attrib={"name": "TaxRange", "value": str(self._tax_now.name)})

Expand Down
8 changes: 3 additions & 5 deletions FastOMA/_utils_subhog.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,9 @@ def prepare_species_tree(rhog_i: List[SeqRecord], species_tree: Tree, rhogid: st
for n in species_tree.traverse():
n.add_feature("size", len(n))

first_common_ancestor_name = species_tree.get_common_ancestor(species_names_uniqe).name
species_tree.prune(species_names_uniqe, preserve_branch_length=True)
# todo check internal node with one child, we need to report for i or not ?
species_tree.name = first_common_ancestor_name
return species_tree, species_names_rhog, prot_names_rhog
mrca = species_tree.get_common_ancestor(species_names_uniqe)
mrca.prune(species_names_uniqe, preserve_branch_length=True)
return mrca, species_names_rhog, prot_names_rhog


def label_sd_internal_nodes(tree_out, threshold_dubious_sd):
Expand Down

0 comments on commit 6aa6cbd

Please sign in to comment.