biothings / biothings_explorer

TRAPI service for BioThings Explorer
https://explorer.biothings.io
Apache License 2.0
10 stars 11 forks source link

discuss TRAPI 1.3 constraints: 3 types #482

Open colleenXu opened 2 years ago

colleenXu commented 2 years ago

This is for brainstorming these "constraint"/post-query filtering behaviors (we can make other issues once we have a concrete idea of the requirements and logic/behavior we want).

The stuff below was previously in #450 posts but has been moved here and edited.


Issues:


QNode.constraints

QEdge.attribute_constraints

QEdge.qualifier_constraints

colleenXu commented 2 years ago

These are quick example queries I wrote to test some TRAPI 1.3 code. I want to do some more thinking / writing before using these as examples / showing these to others in Translator.

(for example I think the QEdge.qualifier_constraints example needs valid biolink-model 3.0 predicates...)

QNode constraints (chem must be above stage 1 clinical trial) trying to find chem that regulate the gene's expression ``` { "message": { "query_graph": { "nodes": { "creativeQuerySubject": { "categories":["biolink:ChemicalEntity"], "constraints": [{ "id": "biolink:drug_regulatory_status_world_wide", "name": "clinical trial level", "operator": ">", "value": 1 }] }, "nA": { "categories":["biolink:DiseaseOrPhenotypicFeature"], "is_set": true }, "creativeQueryObject": { "ids":["MONDO:0005147"], "categories":["biolink:DiseaseOrPhenotypicFeature"], "name": "type 1 dm" } }, "edges": { "eA": { "subject": "creativeQuerySubject", "object": "nA", "predicates": ["biolink:treats"] }, "eB": { "subject": "nA", "object": "creativeQueryObject", "predicates": ["biolink:subclass_of"] } } } } } ```
QEdge attribute_constraints (not semmeddb as knowledge source) trying not to use semmeddb on one of the edges. ``` { "message": { "query_graph": { "nodes": { "creativeQuerySubject": { "categories":["biolink:ChemicalEntity"] }, "nA": { "categories":["biolink:DiseaseOrPhenotypicFeature"], "is_set": true }, "creativeQueryObject": { "ids":["MONDO:0005147"], "categories":["biolink:DiseaseOrPhenotypicFeature"], "name": "type 1 dm" } }, "edges": { "eA": { "subject": "creativeQuerySubject", "object": "nA", "predicates": ["biolink:treats"], "attribute_constraints": [{ "id": "biolink:knowledge_source", "name": "knowledge source", "not": true, "operator": "==", "value": "infores:semmeddb" }] }, "eB": { "subject": "nA", "object": "creativeQueryObject", "predicates": ["biolink:subclass_of"] } } } } } ```
QEdge qualifier_constraints (Gene expression) trying to find chem that regulate the gene's expression ``` { "message": { "query_graph": { "nodes": { "creativeQuerySubject": { "categories":["biolink:ChemicalEntity"] }, "nA": { "categories":["biolink:Gene"], "is_set": true }, "creativeQueryObject": { "ids":["MONDO:0007035"], "categories":["biolink:DiseaseOrPhenotypicFeature"], "name": "acanth" } }, "edges": { "eA": { "subject": "creativeQuerySubject", "object": "nA", "predicates": ["biolink:regulates"], "qualifier_constraints": [{ "qualifier_set": [ { "qualifier_type_id": "object_aspect_qualifier", "qualifier_value": "expression" }] }] }, "eB": { "subject": "nA", "object": "creativeQueryObject", "predicates": ["biolink:causes"] } } } } } ```
colleenXu commented 2 years ago

Note that PRs-merging / discussion is still happening over qualifier constraints. https://github.com/NCATSTranslator/ReasonerAPI/pull/364

EDIT: Found this issue that may be useful for tracking changes https://github.com/NCATSTranslator/ReasonerAPI/issues/357

colleenXu commented 2 years ago

Recording an exercise I did during the Sept 2022 Relay: trying to convert the following question to TRAPI

Question: "What are compounds that significantly reduce CHRNA1 expression while increasing CHRNA1 expression in myocytes?"

basic TRAPI 1.3 with Biolink 2.4.8, using QEdge.attribute-constraints ``` { "message": { "query_graph": { "nodes": { "gene": { "ids": ["NCBIGene:1134"], "name": "CHRNA1" }, "chemical": { "categories": ["biolink:ChemicalEntity"], "name": "compounds" } }, "edges": { "decreases_expression": { "subject": "chemical", "object": "gene", "predicates": ["biolink:decreases_expression_of"] }, "increases_expression": { "subject": "chemical", "object": "gene", "predicates": ["biolink:increases_expression_of"], "attribute_constraints": [{ "id": "biolink:expression_site", "name": "increasing CHRNA1 expression in myocytes", "operator": "==", "value": "CL:0000187" }] } } } } } ```
TRAPI 1.3 with Biolink 3.0.2 qualifiers...seems very hard to compose ``` { "message": { "query_graph": { "nodes": { "gene": { "ids": ["NCBIGene:1134"], "name": "CHRNA1" }, "chemical": { "categories": ["biolink:ChemicalEntity"], "name": "compounds" } }, "edges": { "decreases_expression": { "subject": "chemical", "object": "gene", "predicates": ["biolink:affects"], "qualifier_constraints": [{ "qualifier_set": [ { "qualifier_type_id": "object_direction_qualifier", "qualifier_value": "decreased" }, { "qualifier_type_id": "object_aspect_qualifier", "qualifier_value": "expression" } ] }] }, "increases_expression": { "subject": "chemical", "object": "gene", "predicates": ["biolink:affects"], "qualifier_constraints": [{ "qualifier_set": [ { "qualifier_type_id": "object_direction_qualifier", "qualifier_value": "increased" }, { "qualifier_type_id": "object_aspect_qualifier", "qualifier_value": "expression" }, { "qualifier_type_id": "anatomical_context_qualifier", "qualifier_value": "CL:0000187" } ] }] } } } } } ```

I also noticed the use of qualified predicate in the biolink-model, but I don't remember seeing this field in TRAPI 1.3...

Also what are qualifier sets for (should the "object" stuff and anatomical context stuff be separate sets?)?

colleenXu commented 2 years ago

Putting here as food for thought: Is there a case for multiple kinds of constraints in 1 query? Or multiple constraints of the same type in 1 query?

colleenXu commented 2 years ago

Putting here as notes:

colleenXu commented 1 year ago

Note that the latest implementation rules were released in TRAPI v1.3.0 Sept 1st: https://github.com/NCATSTranslator/ReasonerAPI/blob/v1.3.0/ImplementationRules.md. It has info on QNode constraints, QEdge attribute_constraints (on resource allow/denylist), and QEdge qualifier_constraints.

andrewsu commented 1 year ago

what (if anything) in this ticket is still relevant?

colleenXu commented 1 year ago

@andrewsu

Here's my opinions (but I didn't dig super deep). My recommendations are in the bottom section of this comment.

QNode.constraints: based on console logs, BTE is running defunct code related to this (any logs about "constraints"). So I think we need to address this

QEdge.attribute_constraints: I think this effort is now defunct, and we may not want to implement this. However, we may want to implement the guideline for properties on QEdges.

QEdge.qualifier_constraints: We've implemented this, and it's done as far as I can tell.


So....my recommendations are: close this issue, and open 1-2 new issues