Skip to content

Commit

Permalink
make has_evidence multivalued & primary_knowledge_source single value…
Browse files Browse the repository at this point in the history
…d, plus at typo fix (#226)

Fixes two schema bugs affecting the evidence display
  • Loading branch information
kevinschaper authored Jul 15, 2023
1 parent d05abbe commit 73303b5
Show file tree
Hide file tree
Showing 22 changed files with 4,384 additions and 12,060 deletions.
10 changes: 5 additions & 5 deletions backend/src/monarch_py/datamodels/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ class Association(ConfiguredBaseModel):
default_factory=list,
description="""Field containing object name and the names of all of it's ancestors""",
)
primary_knowledge_source: Optional[List[str]] = Field(default_factory=list)
primary_knowledge_source: Optional[str] = Field(None)
aggregator_knowledge_source: Optional[List[str]] = Field(default_factory=list)
category: Optional[str] = Field(None)
negated: Optional[bool] = Field(None)
provided_by: Optional[str] = Field(None)
publications: Optional[List[str]] = Field(default_factory=list)
qualifiers: Optional[List[str]] = Field(default_factory=list)
frequency_qualifier: Optional[str] = Field(None)
has_evidence: Optional[str] = Field(None)
has_evidence: Optional[List[str]] = Field(default_factory=list)
onset_qualifier: Optional[str] = Field(None)
sex_qualifier: Optional[str] = Field(None)
stage_qualifier: Optional[str] = Field(None)
Expand Down Expand Up @@ -218,15 +218,15 @@ class DirectionalAssociation(Association):
default_factory=list,
description="""Field containing object name and the names of all of it's ancestors""",
)
primary_knowledge_source: Optional[List[str]] = Field(default_factory=list)
primary_knowledge_source: Optional[str] = Field(None)
aggregator_knowledge_source: Optional[List[str]] = Field(default_factory=list)
category: Optional[str] = Field(None)
negated: Optional[bool] = Field(None)
provided_by: Optional[str] = Field(None)
publications: Optional[List[str]] = Field(default_factory=list)
qualifiers: Optional[List[str]] = Field(default_factory=list)
frequency_qualifier: Optional[str] = Field(None)
has_evidence: Optional[str] = Field(None)
has_evidence: Optional[List[str]] = Field(default_factory=list)
onset_qualifier: Optional[str] = Field(None)
sex_qualifier: Optional[str] = Field(None)
stage_qualifier: Optional[str] = Field(None)
Expand Down Expand Up @@ -352,7 +352,7 @@ class HistoBin(FacetValue):

class Node(Entity):
"""
UI conatiner class extending Entity with additional information
UI container class extending Entity with additional information
"""

in_taxon: Optional[str] = Field(None, description="""The biolink taxon that the entity is in the closure of.""")
Expand Down
5 changes: 3 additions & 2 deletions backend/src/monarch_py/datamodels/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ classes:
slots:
- id
Node:
description: UI conatiner class extending Entity with additional information
description: UI container class extending Entity with additional information
is_a: Entity
slots:
- in_taxon
Expand Down Expand Up @@ -280,6 +280,7 @@ slots:
description: The long form name of an entity
range: string
has_evidence:
multivalued: true
range: string
highlight:
description: matching text snippet containing html tags
Expand Down Expand Up @@ -340,7 +341,7 @@ slots:
range: string
required: true
primary_knowledge_source:
multivalued: true
range: string
provided_by:
range: string
publications:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
from monarch_py.implementations.solr.solr_query_utils import (
build_association_counts_query,
build_association_query,
build_association_table_query,
build_autocomplete_query,
build_histopheno_query,
build_search_query,
build_association_table_query,
)
from monarch_py.interfaces.association_interface import AssociationInterface
from monarch_py.interfaces.entity_interface import EntityInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
AssociationCountList,
AssociationDirectionEnum,
AssociationResults,
AssociationTableResults,
DirectionalAssociation,
Entity,
FacetField,
Expand All @@ -15,7 +16,6 @@
HistoPheno,
SearchResult,
SearchResults,
AssociationTableResults,
)
from monarch_py.datamodels.solr import HistoPhenoKeys, SolrQueryResult
from monarch_py.utils.association_type_utils import get_association_type_mapping_by_query_string
Expand Down
24 changes: 12 additions & 12 deletions backend/src/monarch_py/implementations/solr/solr_query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,25 @@ def build_association_query(
query.q = f"*{q}*"
query.query_fields = "subject subject_label predicate object object_label"
if sort:
query.sort = ', '.join(sort)
query.sort = ", ".join(sort)
if facet_fields:
query.facet_fields = facet_fields
if facet_queries:
query.facet_queries = facet_queries
return query


def build_association_table_query(entity: str,
category: str,
q: str = None,
offset: int = 0,
limit: int = 5,
sort: List[str] = None) -> SolrQuery:
def build_association_table_query(
entity: str, category: str, q: str = None, offset: int = 0, limit: int = 5, sort: List[str] = None
) -> SolrQuery:
if sort is None:
sort = ['evidence_count desc',
'subject_label asc',
'predicate asc',
'object_label asc',
'primary_knowledge_source asc']
sort = [
"evidence_count desc",
"subject_label asc",
"predicate asc",
"object_label asc",
"primary_knowledge_source asc",
]

query = build_association_query(
entity=[entity],
Expand All @@ -90,6 +89,7 @@ def build_association_table_query(entity: str,
)
return query


def build_association_counts_query(entity: str) -> SolrQuery:
subject_query = f'AND (subject:"{entity}" OR subject_closure:"{entity}")'
object_query = f'AND (object:"{entity}" OR object_closure:"{entity}")'
Expand Down
Loading

0 comments on commit 73303b5

Please sign in to comment.