Skip to content

Commit

Permalink
Show association selection as association category (#733)
Browse files Browse the repository at this point in the history
Change up association table category count outputs to be based on the
association category, rather than counterpart category. This can
potentially be simplified by just generating labels from the association
categories, but for now this PR is going to make a smaller change.
Downstream, the UI needs a minor shift in the "sentence" structure of
the association table heading/controls.
  • Loading branch information
kevinschaper authored Jun 4, 2024
1 parent a9d9d64 commit 79ff82b
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 191 deletions.
14 changes: 3 additions & 11 deletions backend/src/monarch_py/implementations/solr/solr_query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ def build_association_query(
query.add_filter_query(" OR ".join([f'object:"{o}" OR object_closure:"{o}"' for o in object]))
if entity:
if direct:
query.add_filter_query(" OR ".join([f'subject:"{escape(e)}" OR object:"{escape(e)}"' for e in entity]))
query.add_filter_query(" OR ".join([f'subject:"{e}" OR object:"{e}"' for e in entity]))
else:
query.add_filter_query(
" OR ".join(
[
f'subject:"{escape(e)}" OR subject_closure:"{escape(e)}" OR object:"{escape(e)}" OR object_closure:"{escape(e)}"'
for e in entity
]
[f'subject:"{e}" OR subject_closure:"{e}" OR object:"{e}" OR object_closure:"{e}"' for e in entity]
)
)
if q:
Expand Down Expand Up @@ -91,12 +88,7 @@ def build_association_table_query(
]

query = build_association_query(
entity=entity,
category=[category],
q=q,
sort=sort,
offset=offset,
limit=limit,
entity=entity, category=[category], q=q, sort=sort, offset=offset, limit=limit, direct=False
)
return query

Expand Down
40 changes: 20 additions & 20 deletions backend/src/monarch_py/utils/association_type_mappings.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
- subject_label: Diseases
object_label: Phenotypes
- subject_label: Disease to Phenotype
object_label: Phenotype to Disease
category: "biolink:DiseaseToPhenotypicFeatureAssociation"
- subject_label: Genes
object_label: Phenotypes
- subject_label: Gene to Phenotype
object_label: Phenotype to Gene
category: "biolink:GeneToPhenotypicFeatureAssociation"
- subject_label: Interactions
object_label: Interactions
symmetric: true
category: "biolink:PairwiseGeneToGeneInteraction"
- subject_label: Genes
object_label: Pathways
- subject_label: Gene to Pathway
object_label: Pathway to Gene
category: "biolink:GeneToPathwayAssociation"
- subject_label: Genes
object_label: Anatomy
- subject_label: Gene Expression
object_label: Gene Expression
category: "biolink:GeneToExpressionSiteAssociation"
- subject_label: Orthologs
object_label: Orthologs
symmetric: true
category: "biolink:GeneToGeneHomologyAssociation"
- subject_label: Chemicals
object_label: Pathways
- subject_label: Chemical to Pathway
object_label: Pathway to Chemical
category: "biolink:ChemicalToPathwayAssociation"
- subject_label: Genes
object_label: Molecular Functions
- subject_label: Gene to Molecular Function
object_label: Molecular Function to Gene
category: "biolink:MacromolecularMachineToMolecularActivityAssociation"
- subject_label: Genes
object_label: Cellular Components
- subject_label: Gene to Cellular Component
object_label: Cellular Component to Gene
category: "biolink:MacromolecularMachineToCellularComponentAssociation"
- subject_label: Genes
object_label: Biological Processes
- subject_label: Gene to Biological Process
object_label: Biological Process to Gene
category: "biolink:MacromolecularMachineToBiologicalProcessAssociation"
- subject_label: Causal Genes
object_label: Causal Diseases
- subject_label: Causal Gene
object_label: Causal Disease
category: "biolink:CausalGeneToDiseaseAssociation"
- subject_label: "Correlated Genes"
object_label: "Correlated Diseases"
- subject_label: Correlated Gene
object_label: Correlated Disease
category: "biolink:CorrelatedGeneToDiseaseAssociation"
10 changes: 7 additions & 3 deletions backend/tests/fixtures/association_counts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
def association_counts():
return {
"items": [
{"label": "Phenotypes", "count": 3932, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 126, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 146, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
{
"label": "Phenotype to Disease",
"count": 3932,
"category": "biolink:DiseaseToPhenotypicFeatureAssociation",
},
{"label": "Causal Gene", "count": 126, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Gene", "count": 146, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
]
}
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_counts_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def association_counts_query():
'(category:"biolink:CorrelatedGeneToDiseaseAssociation") AND (object:"MONDO:0020121" OR object_closure:"MONDO:0020121")',
],
"filter_queries": [
'subject:"MONDO\\:0020121" OR subject_closure:"MONDO\\:0020121" OR object:"MONDO\\:0020121" OR object_closure:"MONDO\\:0020121"'
'subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121" OR object:"MONDO:0020121" OR object_closure:"MONDO:0020121"'
],
"query_fields": None,
"def_type": "edismax",
Expand Down
4 changes: 2 additions & 2 deletions 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": 2,
"QTime": 1,
"params": {
"facet.query": [
'(category:"biolink:DiseaseToPhenotypicFeatureAssociation") AND (subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121")',
Expand Down Expand Up @@ -39,7 +39,7 @@ def association_counts_response():
"facet_min_count": "1",
"start": "0",
"q.op": "AND",
"fq": 'subject:"MONDO\\:0020121" OR subject_closure:"MONDO\\:0020121" OR object:"MONDO\\:0020121" OR object_closure:"MONDO\\:0020121"',
"fq": 'subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121" OR object:"MONDO:0020121" OR object_closure:"MONDO:0020121"',
"rows": "20",
"facet": "true",
},
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_query_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def association_query_direct():
"object_taxon:NCBITaxon\\:2222",
"subject:TEST\\:0000001",
"object:TEST\\:0000002",
'subject:"TEST\\:0000005" OR object:"TEST\\:0000005"',
'subject:"TEST:0000005" OR object:"TEST:0000005"',
],
"query_fields": "subject subject_label^2 subject_label_t subject_closure subject_closure_label subject_closure_label_t predicate predicate_t object object_label^2 object_label_t object_closure object_closure_label object_closure_label_t publications has_evidence primary_knowledge_source aggregator_knowledge_source provided_by ",
"def_type": "edismax",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_query_indirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def association_query_indirect():
"object_taxon:NCBITaxon\\:2222",
'subject:"TEST:0000001" OR subject_closure:"TEST:0000001"',
'object:"TEST:0000002" OR object_closure:"TEST:0000002"',
'subject:"TEST\\:0000005" OR subject_closure:"TEST\\:0000005" OR object:"TEST\\:0000005" OR object_closure:"TEST\\:0000005"',
'subject:"TEST:0000005" OR subject_closure:"TEST:0000005" OR object:"TEST:0000005" OR object_closure:"TEST:0000005"',
],
"query_fields": "subject subject_label^2 subject_label_t subject_closure subject_closure_label subject_closure_label_t predicate predicate_t object object_label^2 object_label_t object_closure object_closure_label object_closure_label_t publications has_evidence primary_knowledge_source aggregator_knowledge_source provided_by ",
"def_type": "edismax",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/association_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def association_response():
"facet_min_count": "1",
"start": "0",
"q.op": "AND",
"fq": 'subject:"MONDO\\:0020121" OR subject_closure:"MONDO\\:0020121" OR object:"MONDO\\:0020121" OR object_closure:"MONDO\\:0020121"',
"fq": 'subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121" OR object:"MONDO:0020121" OR object_closure:"MONDO:0020121"',
"rows": "20",
"facet": "true",
},
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/fixtures/association_table_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def association_table_response():
return {
"responseHeader": {
"QTime": 1,
"QTime": 0,
"params": {
"mm": "100%",
"q": "*:*",
Expand All @@ -15,7 +15,7 @@ def association_table_response():
"q.op": "AND",
"fq": [
"category:biolink\\:DiseaseToPhenotypicFeatureAssociation",
'subject:"MONDO\\:0020121" OR subject_closure:"MONDO\\:0020121" OR object:"MONDO\\:0020121" OR object_closure:"MONDO\\:0020121"',
'subject:"MONDO:0020121" OR subject_closure:"MONDO:0020121" OR object:"MONDO:0020121" OR object_closure:"MONDO:0020121"',
],
"sort": "frequency_computed_sortable_float desc, evidence_count desc, subject_label asc, predicate asc, object_label asc, primary_knowledge_source asc",
"rows": "5",
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/fixtures/autocomplete_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def autocomplete_response():
return {
"responseHeader": {
"QTime": 1,
"QTime": 0,
"params": {
"mm": "100%",
"q": "fanc",
Expand Down
10 changes: 7 additions & 3 deletions backend/tests/fixtures/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ def node():
"url": "https://monarch-initiative.github.io/monarch-ingest/Sources/phenio/#",
},
"association_counts": [
{"label": "Phenotypes", "count": 3932, "category": "biolink:DiseaseToPhenotypicFeatureAssociation"},
{"label": "Causal Genes", "count": 126, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Genes", "count": 146, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
{
"label": "Phenotype to Disease",
"count": 3932,
"category": "biolink:DiseaseToPhenotypicFeatureAssociation",
},
{"label": "Causal Gene", "count": 126, "category": "biolink:CausalGeneToDiseaseAssociation"},
{"label": "Correlated Gene", "count": 146, "category": "biolink:CorrelatedGeneToDiseaseAssociation"},
],
"node_hierarchy": {
"super_classes": [
Expand Down
Loading

0 comments on commit 79ff82b

Please sign in to comment.