Skip to content

Commit

Permalink
Search in descriptions & link to GARD and Orphanet (#679)
Browse files Browse the repository at this point in the history
Mostly I wanted the search in description, but then I found myself
chasing down doing _something_ so that we'll have GARD & Orphanet links
working in the UI
  • Loading branch information
kevinschaper authored Apr 22, 2024
1 parent fbdda4c commit ac4e7b4
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 222 deletions.
12 changes: 9 additions & 3 deletions backend/src/monarch_py/implementations/solr/solr_query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,20 @@ def blank_search_boost() -> str:
return f"product({boost})"


def entity_query_fields():
def autocomplete_query_fields():
"""
Shared query field list between search and autocomplete,
since the field list and boosts are currently the same
Fields and boosts used for autocomplete
"""
return "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac"


def entity_query_fields():
"""
Fields and boosts used for entity search, includes autocomplete fields and expands upon them beyond pure name fields
"""
return f"{autocomplete_query_fields()} description_t"


def association_search_query_fields():
"""
Shared field list for free text search on associations (e.g. for the association table)
Expand Down
2 changes: 2 additions & 0 deletions backend/src/monarch_py/service/curie_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
# this is a magic keyword that represents the "merged" context from Chris M's algorithm
# (https://github.com/linkml/prefixmaps/blob/main/src/prefixmaps/data/merged.csv)
converter = load_converter("merged")
converter.add_prefix("GARD", "https://rarediseases.info.nih.gov/diseases/")
converter.add_prefix("Orphanet", "https://www.orpha.net/en/disease/detail/", merge=True)
10 changes: 9 additions & 1 deletion backend/src/monarch_py/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ def set_log_level(log_level: str):

def get_links_for_field(field: List[str]) -> List[ExpandedCurie]:
# TODO should be able to remove curie.replace("PMID", "PUBMED")) since the converter should handle prefix synonyms
return [ExpandedCurie(id=curie, url=converter.expand(curie.replace("PMID", "PUBMED"))) for curie in field]
expanded_curies = [ExpandedCurie(id=curie, url=get_link_for_curie(curie)) for curie in field]
return expanded_curies


def get_link_for_curie(curie: str) -> ExpandedCurie:
url = converter.expand(curie.replace("PMID", "PUBMED"))
if curie.startswith("GARD:"):
url += "/index"
return url


def get_provided_by_link(provided_by: str) -> ExpandedCurie:
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_counts_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def association_counts_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 1,
"params": {
"facet.query": [
'(category:"biolink:DiseaseToPhenotypicFeatureAssociation") AND (subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121")',
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/autocomplete_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def autocomplete_query():
"facet_fields": [],
"facet_queries": [],
"filter_queries": [],
"query_fields": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac",
"query_fields": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac description_t",
"def_type": "edismax",
"q_op": "AND",
"mm": "100%",
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/fixtures/autocomplete_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
def autocomplete_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 1,
"params": {
"mm": "100%",
"q": "fanc",
"defType": "edismax",
"facet_min_count": "1",
"qf": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac",
"qf": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac description_t",
"start": "0",
"q.op": "AND",
"boost": 'product(if(termfreq(category,"biolink:PhenotypicFeature"),1.1,1),if(termfreq(category,"biolink:Disease"),1.3,1),if(and(termfreq(in_taxon,"NCBITaxon:9606"),termfreq(category,"biolink:Gene")),1.1,1),if(termfreq(deprecated,"true"),0.1,1))',
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/fixtures/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ def node():
{"id": "DOID:9884", "url": "http://purl.obolibrary.org/obo/DOID_9884"},
{"id": "ICD10CM:G71.0", "url": "https://icd.codes/icd10cm/G71.0"},
{"id": "NCIT:C84910", "url": "http://purl.obolibrary.org/obo/NCIT_C84910"},
{"id": "Orphanet:98473", "url": None},
{"id": "Orphanet:98473", "url": "https://www.orpha.net/en/disease/detail/98473"},
{"id": "SCTID:73297009", "url": "http://identifiers.org/snomedct/73297009"},
{"id": "UMLS:C0026850", "url": "http://identifiers.org/umls/C0026850"},
{"id": "MESH:D009136", "url": "http://identifiers.org/mesh/D009136"},
],
"external_links": [
{"id": "DOID:9884", "url": "http://purl.obolibrary.org/obo/DOID_9884"},
{"id": "GARD:7922", "url": None},
{"id": "GARD:7922", "url": "https://rarediseases.info.nih.gov/diseases/7922/index"},
{"id": "ICD10CM:G71.0", "url": "https://icd.codes/icd10cm/G71.0"},
{"id": "ICD9:359.1", "url": None},
{"id": "MESH:D009136", "url": "http://identifiers.org/mesh/D009136"},
{"id": "MedDRA:10028356", "url": None},
{"id": "NCIT:C84910", "url": "http://purl.obolibrary.org/obo/NCIT_C84910"},
{"id": "Orphanet:98473", "url": None},
{"id": "Orphanet:98473", "url": "https://www.orpha.net/en/disease/detail/98473"},
{"id": "SCTID:73297009", "url": "http://identifiers.org/snomedct/73297009"},
{"id": "UMLS:C0026850", "url": "http://identifiers.org/umls/C0026850"},
],
Expand Down
14 changes: 7 additions & 7 deletions backend/tests/fixtures/object_formatted.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/tests/fixtures/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def search():
return {
"limit": 20,
"offset": 0,
"total": 101,
"total": 117,
"items": [
{
"id": "MONDO:0019391",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/search_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def search_query():
"facet_fields": [],
"facet_queries": [],
"filter_queries": ["name:*"],
"query_fields": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac",
"query_fields": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac description_t",
"def_type": "edismax",
"q_op": "AND",
"mm": "100%",
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/fixtures/search_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
def search_response():
return {
"responseHeader": {
"QTime": 0,
"QTime": 3,
"params": {
"mm": "100%",
"q": "fanconi",
"defType": "edismax",
"facet_min_count": "1",
"qf": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac",
"qf": "id^100 name^10 name_t^5 name_ac symbol^10 symbol_t^5 symbol_ac synonym synonym_t synonym_ac description_t",
"start": "0",
"q.op": "AND",
"boost": 'product(if(termfreq(category,"biolink:PhenotypicFeature"),1.1,1),if(termfreq(category,"biolink:Disease"),1.3,1),if(and(termfreq(in_taxon,"NCBITaxon:9606"),termfreq(category,"biolink:Gene")),1.1,1),if(termfreq(deprecated,"true"),0.1,1))',
Expand All @@ -21,7 +21,7 @@ def search_response():
},
},
"response": {
"num_found": 101,
"num_found": 117,
"start": 0,
"docs": [
{
Expand Down
6 changes: 3 additions & 3 deletions frontend/fixtures/node.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"id": "Orphanet:98473",
"url": null
"url": "https://www.orpha.net/en/disease/detail/98473"
},
{
"id": "SCTID:73297009",
Expand All @@ -70,7 +70,7 @@
},
{
"id": "GARD:7922",
"url": null
"url": "https://rarediseases.info.nih.gov/diseases/7922/index"
},
{
"id": "ICD10CM:G71.0",
Expand All @@ -94,7 +94,7 @@
},
{
"id": "Orphanet:98473",
"url": null
"url": "https://www.orpha.net/en/disease/detail/98473"
},
{
"id": "SCTID:73297009",
Expand Down
Loading

0 comments on commit ac4e7b4

Please sign in to comment.