Skip to content

Commit

Permalink
Adds causal_gene and causes_disease properties to the node page respo…
Browse files Browse the repository at this point in the history
…nse (#341)

Addresses #332

Shows causal g2d associations as a top level node property for genes and
diseases
  • Loading branch information
kevinschaper authored Sep 23, 2023
1 parent d41648a commit bab0314
Show file tree
Hide file tree
Showing 29 changed files with 16,389 additions and 6,097 deletions.
8 changes: 8 additions & 0 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ class Node(Entity):
description="""The label of the biolink taxon that the entity is in the closure of.""",
)
inheritance: Optional[Entity] = Field(None)
causal_gene: Optional[List[Entity]] = Field(
default_factory=list,
description="""A list of genes that are known to be causally associated with a disease""",
)
causes_disease: Optional[List[Entity]] = Field(
default_factory=list,
description="""A list of diseases that are known to be causally associated with a gene""",
)
external_links: Optional[List[ExpandedCurie]] = Field(
default_factory=list, description="""ExpandedCurie with id and url for xrefs"""
)
Expand Down
14 changes: 14 additions & 0 deletions backend/src/monarch_py/datamodels/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ classes:
- in_taxon
- in_taxon_label
- inheritance
- causal_gene
- causes_disease
- external_links
- provided_by_link
- association_counts
Expand Down Expand Up @@ -248,6 +250,18 @@ slots:
required: true
category:
multivalued: false
causal_gene:
description: >-
A list of genes that are known to be causally associated with a disease
range: Entity
multivalued: true
inlined_as_list: true
causes_disease:
description: >-
A list of diseases that are known to be causally associated with a gene
range: Entity
multivalued: true
inlined_as_list: true
count:
description: count of documents
range: integer
Expand Down
22 changes: 22 additions & 0 deletions backend/src/monarch_py/implementations/solr/solr_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ def get_entity(self, id: str, extra: bool) -> Optional[Union[Node, Entity]]:
)
if mode_of_inheritance_associations is not None and len(mode_of_inheritance_associations.items) == 1:
node.inheritance = self._get_associated_entity(mode_of_inheritance_associations.items[0], node)

if "biolink:Disease" == node.category:
node.causal_gene = [
self._get_associated_entity(association, node)
for association in self.get_associations(
object=id,
direct=True,
predicate="biolink:causes",
category="biolink:CausalGeneToDiseaseAssociation",
).items
]
if "biolink:Gene" == node.category:
node.causes_disease = [
self._get_associated_entity(association, node)
for association in self.get_associations(
subject=id,
direct=True,
predicate="biolink:causes",
category="biolink:CausalGeneToDiseaseAssociation",
).items
]

node.node_hierarchy = self._get_node_hierarchy(node)
node.association_counts = self.get_association_counts(id).items
node.external_links = (
Expand Down
9 changes: 2 additions & 7 deletions backend/tests/fixtures/association_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,13 @@ def association_counts():
"items": [
{
"label": "Phenotypes",
"count": 4011,
"count": 2166,
"category": "biolink:DiseaseToPhenotypicFeatureAssociation",
},
{
"label": "Causal Genes",
"count": 121,
"count": 124,
"category": "biolink:CausalGeneToDiseaseAssociation",
},
{
"label": "Correlated Genes",
"count": 147,
"category": "biolink:CorrelatedGeneToDiseaseAssociation",
},
]
}
Loading

0 comments on commit bab0314

Please sign in to comment.