Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove equivalent class from node hierarchy (always empty) #295

Merged
merged 13 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ class Node(Entity):
class NodeHierarchy(ConfiguredBaseModel):

super_classes: List[Entity] = Field(default_factory=list)
equivalent_classes: List[Entity] = Field(default_factory=list)
sub_classes: List[Entity] = Field(default_factory=list)


Expand Down
9 changes: 0 additions & 9 deletions backend/src/monarch_py/datamodels/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ classes:
NodeHierarchy:
slots:
- super_classes
- equivalent_classes
- sub_classes
Results:
abstract: true
Expand Down Expand Up @@ -261,12 +260,6 @@ slots:
the object or in the object closure, the direction is backwards.
range: AssociationDirectionEnum
required: true
equivalent_classes:
range: Entity
multivalued: true
inlined: true
inlined_as_list: true
required: true
evidence_count:
description: count of supporting documents, evidence codes, and sources supplying evidence
range: integer
Expand Down Expand Up @@ -371,8 +364,6 @@ slots:
multivalued: true
qualifiers:
multivalued: true
relation:
range: string
score:
range: float
sex_qualifier:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ def get_entity(self, id: str, extra: bool) -> Union[Node, Entity]:

def _get_associated_entity(self, association: Association, this_entity: Entity) -> Entity:
"""Returns the id, name, and category of the other Entity in an Association given this_entity"""
if this_entity.id in association.subject_closure:
if this_entity.id == association.subject:
entity = Entity(
id=association.object,
name=association.object_label,
category=association.object_category,
)
elif this_entity.id in association.object_closure:
elif this_entity.id == association.object:
entity = Entity(
id=association.subject,
name=association.subject_label,
Expand Down Expand Up @@ -156,13 +156,15 @@ def _get_node_hierarchy(self, entity: Entity) -> NodeHierarchy:
NodeHierarchy: A NodeHierarchy object
"""

super_classes = self._get_associated_entities(entity, subject=entity.id, predicate="biolink:subclass_of")
equivalent_classes = self._get_associated_entities(entity, entity=entity.id, predicate="biolink:same_as")
sub_classes = self._get_associated_entities(entity, object=entity.id, predicate="biolink:subclass_of")
super_classes = self._get_associated_entities(
this_entity=entity, subject=entity.id, predicate="biolink:subclass_of"
)
sub_classes = self._get_associated_entities(
this_entity=entity, object=entity.id, predicate="biolink:subclass_of"
)

return NodeHierarchy(
super_classes=super_classes,
equivalent_classes=equivalent_classes,
sub_classes=sub_classes,
)

Expand Down
15 changes: 8 additions & 7 deletions backend/src/monarch_py/implementations/sql/sql_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ def _get_node_hierarchy(self, entity: Entity) -> NodeHierarchy:
NodeHierarchy: A NodeHierarchy object
"""

super_classes = self._get_associated_entities(entity, subject=entity.id, predicate="biolink:subclass_of")
equivalent_classes = self._get_associated_entities(entity, entity=entity.id, predicate="biolink:same_as")
sub_classes = self._get_associated_entities(entity, object=entity.id, predicate="biolink:subclass_of")
super_classes = self._get_associated_entities(
this_entity=entity, subject=entity.id, predicate="biolink:subclass_of"
)
sub_classes = self._get_associated_entities(
this_entity=entity, object=entity.id, predicate="biolink:subclass_of"
)

return NodeHierarchy(
super_classes=super_classes,
equivalent_classes=equivalent_classes,
sub_classes=sub_classes,
)

Expand Down Expand Up @@ -242,13 +244,12 @@ def get_associations(
"original_object": row["original_object"],
"category": row["category"],
"aggregator_knowledge_source": row["aggregator_knowledge_source"].split("|"),
"primary_knowledge_source": row["primary_knowledge_source"].split("|"),
"primary_knowledge_source": row["primary_knowledge_source"],
"publications": row["publications"].split("|"),
"qualifiers": row["qualifiers"].split("|"),
"provided_by": row["provided_by"],
"has_evidence": row["has_evidence"],
"has_evidence": row["has_evidence"].split("|"),
"stage_qualifier": row["stage_qualifier"],
"relation": row["relation"],
"negated": False if not row["negated"] else True,
"frequency_qualifier": row["frequency_qualifier"],
"onset_qualifier": row["onset_qualifier"],
Expand Down
18 changes: 15 additions & 3 deletions backend/tests/fixtures/association_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
def association_counts():
return {
"items": [
{"label": "Phenotypes", "count": 4011, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 121, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 147, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
{
"label": "Phenotypes",
"count": 4011,
"category": "biolink:DiseaseToPhenotypicFeatureAssociation",
},
{
"label": "Causal Genes",
"count": 121,
"category": "biolink:CausalGeneToDiseaseAssociation",
},
{
"label": "Correlated Genes",
"count": 147,
"category": "biolink:CorrelatedGeneToDiseaseAssociation",
},
]
}
Loading