Skip to content

Edge/Node constraints#194

Open
rjawesome wants to merge 9 commits intomainfrom
edge-constraints
Open

Edge/Node constraints#194
rjawesome wants to merge 9 commits intomainfrom
edge-constraints

Conversation

@rjawesome
Copy link
Contributor

biothings/biothings_explorer#795

Note: for subclass edges, the constraint is applied to the underlying edge. Ie. if a subclass edge represents A--treats-->B--subclass-->C then the constraints are applied to the A->B edge (and A/B nodes).

Example Query:

{
  "message": {
    "query_graph": {
      "edges": {
        "e0": {
          "predicates": [
            "biolink:treats"
          ],
          "subject": "n0",
          "object": "n1",
          "attribute_constraints": [
            {
              "name": "evidence_count_constraint",
              "id": "biolink:evidence_count",
              "operator": ">",
              "value": 30
            }
          ]
        }
      },
      "nodes": {
        "n0": {
          "categories": [
            "biolink:ChemicalEntity"
          ],
          "constraints": [
            {
                "name": "syn",
                "id": "biolink:synonym",
                "operator": "matches",
                "value": ".*MG.*"
            },
            {
                "name": "xr",
                "id": "biolink:xref",
                "operator": "matches",
                "value": "DrugCentral:1.*"
            }
          ]
        },
        "n1": {
          "categories": [
            "biolink:DiseaseOrPhenotypicFeature"
          ],
          "ids": ["MONDO:0002050"]
        }
      }
    }
  }
}

@tokebe
Copy link
Member

tokebe commented Jul 26, 2024

@rjawesome Reviewed&tested and everything looks good. Hoping to get to dev today/monday.

Regarding your comment about node constraints possibly behaving weirdly with subclassing, could you explain what ambiguities arise?

@rjawesome
Copy link
Contributor Author

rjawesome commented Jul 26, 2024

@tokebe
Since the filtering for constraints occurs before subclass edges are created, constraints aren't applied to the subclass edge. Rather, the constraints are applied to the edge from the record (ie. the edge pointed to in the subclass edge's support graph).

ie. if a result contains the edge A-C-via_subclass which in the support graph points to the edge A-B and the edge B-subclass_of-C. the constraint is applied to A-B instead of A-C-via_subclass

@tokebe
Copy link
Member

tokebe commented Jul 26, 2024

Thanks! I think that'll probably be fine for now, since the majority of things being constrained on would be represented in A-B rather than A-C-via_subclass.

@rjawesome
Copy link
Contributor Author

@tokebe This PR should be good to go, with merge conflicts fixed, as well as working properly with subclassing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants