Skip to content

Commit

Permalink
Merge pull request #51 from monarch-initiative/49-add-handling-for-mi…
Browse files Browse the repository at this point in the history
…ssing-term-labels

49 add handling for missing term labels
  • Loading branch information
yaseminbridges authored Dec 18, 2024
2 parents 18e0fd4 + d31b705 commit 742cef3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "phenotype2phenopacket"
version = "0.6.9"
version = "0.6.10"
description = ""
authors = ["Yasemin Bridges <[email protected]>"]
readme = "README.md"
Expand Down
8 changes: 4 additions & 4 deletions src/phenotype2phenopacket/utils/phenopacket_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,17 @@ def get_parents_of_terms(self, phenotype_entry: dict, steps: int) -> dict:
"""
term_id = phenotype_entry["hpo_id"]
rels = self.ontology.entity_alias_map(term_id)
term = "".join(rels[(list(rels.keys())[0])])
term = "".join(rels[(list(rels.keys())[0])]) if rels else ""
if term.startswith("Abnormality of"):
return phenotype_entry
for _i in range(steps):
parents = self.ontology.hierarchical_parents(term_id)
if not parents:
warnings.warn(f"No parents found for term {term}", stacklevel=2)
warnings.warn(f"No parents found for term {term_id}", stacklevel=2)
return phenotype_entry
parent = self.secret_rand.choice(parents)
rels = self.ontology.entity_alias_map(parent)
term = "".join(rels[(list(rels.keys())[0])])
term = "".join(rels[(list(rels.keys())[0])]) if rels else ""
if (
term.startswith("Abnormality of")
or term_id == "HP:0000118"
Expand Down Expand Up @@ -632,7 +632,7 @@ def create_onset(self, phenotype_annotation_entry: dict) -> TimeElement:
rels = self.human_phenotype_ontology.entity_alias_map(
phenotype_annotation_entry["onset"]
)
term = "".join(rels[(list(rels.keys())[0])])
term = "".join(rels[(list(rels.keys())[0])]) if rels else None
return TimeElement(
ontology_class=OntologyClass(id=phenotype_annotation_entry["onset"], label=term)
)
Expand Down

0 comments on commit 742cef3

Please sign in to comment.