From 00cd2e359dbcc88763d952e1604ae6d8e3cd1d53 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Thu, 26 Mar 2026 15:47:48 -0400 Subject: [PATCH 1/2] add specification for attribute constraints --- .../qedge_constraints_specification.md | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/ImplementationGuidance/Specifications/qedge_constraints_specification.md b/ImplementationGuidance/Specifications/qedge_constraints_specification.md index 97f8906..1b74755 100644 --- a/ImplementationGuidance/Specifications/qedge_constraints_specification.md +++ b/ImplementationGuidance/Specifications/qedge_constraints_specification.md @@ -107,8 +107,62 @@ The matched Edge's `primary_knowledge_source` should NOT be `infores:semmeddb` o ## Attributes -Format didn't change in TRAPI 2.0, see docs for details. +Each attribute constraint object constrains a specific attribute type. Multiple attribute constraints together represent an AND relationship, such that all attribute constraints must be met. +Every attribute constraint must supply a `name`, `id`, `value`, and `operator`: + +- `name`: For human use, this just specifies the intent of the constraint. +- `id`: This targets the constraint to attributes with a specific `attribute_type_id`. +- `value`: Provides a value with which the targeted attribute types must agree. +- `operator`: Provides the relationship to the `value` that targeted attributes must fulfill. + +Additionally, `not` allows the operator relationship to be inverted. + +In the most simple case, the operator `===` requires that edges must have an attribute exactly matching the given value: + +```json +{ + "name": "Must have the exact given publication list", + "id": "biolink:publications", + "operator": "===", + "value": ["PMID:1234", "PMID:4567"] +} +``` + +would only allow edges that have the `attribute_type_id` 'biolink:publications', where the attribute value is exactly `["PMID:1234", "PMID:4567"]`. + +`"not": true` would make this operator mean 'not exactly equal to'. + +Other operators exist which provide specific expressions, detailed below: + +### `==` "Equals" + +The operator `==` means 'is equal to', in a very broad sense. It is applied list-wise for both the constraint value, and the value of attributes being compared, in an OR fashion, such that any equality fulfills it. + +To give a few examples of matching cases, consider the following constraint == value pairs: + +- `1 == 1` +- `1 == [1, 2, 3]` +- `[1, 2, 3] == 1` +- `[1, 2, 3] == [3, 4, 5]` + +All following operators follow this same list-wise comparison logic. + +`not` would make this operator mean 'not equal to, in any comparison.' + +### `>` "Greater than" + +The operator `>` means "greater than", and the same list-wise logic applies. `not` makes this operator mean 'less than or equal to' for all comparisons. + +### `<` "Less than" + +The operator `<` means "less than", and the same list-wise logic applies. `not` makes this operator mean 'greater than or equal to' for all comparisons. + +### `matches` "Matches by regular expression" + +The operator `matches` invokes a regular expression for the comparison (again, following the list-wise comparison, meaning a list of regular expressions may be supplied), using python-like regex syntax. + +`not` means that no regex match is found for all comparisons. ## Full Examples From 8f54e584ae7f7df567faf0fe152e55879606becc Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Thu, 26 Mar 2026 16:27:24 -0400 Subject: [PATCH 2/2] clarify list-wise comparisons --- .../qedge_constraints_specification.md | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/ImplementationGuidance/Specifications/qedge_constraints_specification.md b/ImplementationGuidance/Specifications/qedge_constraints_specification.md index 1b74755..0b1eced 100644 --- a/ImplementationGuidance/Specifications/qedge_constraints_specification.md +++ b/ImplementationGuidance/Specifications/qedge_constraints_specification.md @@ -107,7 +107,7 @@ The matched Edge's `primary_knowledge_source` should NOT be `infores:semmeddb` o ## Attributes -Each attribute constraint object constrains a specific attribute type. Multiple attribute constraints together represent an AND relationship, such that all attribute constraints must be met. +Attribute constraints are presented as a list of attribute constraint objects. Each attribute constraint object constrains a specific attribute type. Multiple attribute constraints together represent an AND relationship, such that all attribute constraints must be met. Every attribute constraint must supply a `name`, `id`, `value`, and `operator`: @@ -118,6 +118,8 @@ Every attribute constraint must supply a `name`, `id`, `value`, and `operator`: Additionally, `not` allows the operator relationship to be inverted. +### `===` "Strict equality" + In the most simple case, the operator `===` requires that edges must have an attribute exactly matching the given value: ```json @@ -137,32 +139,50 @@ Other operators exist which provide specific expressions, detailed below: ### `==` "Equals" -The operator `==` means 'is equal to', in a very broad sense. It is applied list-wise for both the constraint value, and the value of attributes being compared, in an OR fashion, such that any equality fulfills it. +The operator `==` means 'is equal to'. `not` would make this operator mean 'not equal to, in any comparison.' -To give a few examples of matching cases, consider the following constraint == value pairs: +### `>` "Greater than" -- `1 == 1` -- `1 == [1, 2, 3]` -- `[1, 2, 3] == 1` -- `[1, 2, 3] == [3, 4, 5]` +The operator `>` means "greater than". `not` makes this operator mean 'less than or equal to' for all comparisons. -All following operators follow this same list-wise comparison logic. +### `<` "Less than" -`not` would make this operator mean 'not equal to, in any comparison.' +The operator `<` means "less than". `not` makes this operator mean 'greater than or equal to' for all comparisons. -### `>` "Greater than" +### `matches` "Matches by regular expression" -The operator `>` means "greater than", and the same list-wise logic applies. `not` makes this operator mean 'less than or equal to' for all comparisons. +The operator `matches` invokes a regular expression for the comparison, using python-like regex syntax. `not` means that no regex match is found for all comparisons. -### `<` "Less than" +### List-wise comparison -The operator `<` means "less than", and the same list-wise logic applies. `not` makes this operator mean 'greater than or equal to' for all comparisons. +The operators `==`, `>`, `<`, and `matches` all are compared list-wise. Let's look at this using `==` as an example. -### `matches` "Matches by regular expression" +In the most basic case, simple equality satisfies the operator (each example shall be constraint value == attribute value): + +- `1 == 1` constraint met! +- `1 == 2` constraint failed. + +However, if the constraint value is a list, each item in the list may be compared against the attribute value: + +- `[1, 2, 3] == 1` constraint met! +- `[1, 2, 3] == 2` constraint met! +- `[1, 2, 3] == 3` constraint met! +- `[1, 2, 3] == 4` constraint failed. + +Similarly, if the attribute value is a list, each item may be compared against the constraint: + +- `1 == [1, 2, 3]` constraint met! +- `2 == [1, 2, 3]` constraint met! +- `3 == [1, 2, 3]` constraint met! +- `4 == [1, 2, 3]` constraint failed. + +Finally, both may be lists, in which case every pair must be compared: + +- `[1, 2, 3] == [3, 4, 5]` constraint met! +- `[1, 2, 3] == [4, 6, 6]` constraint failed. -The operator `matches` invokes a regular expression for the comparison (again, following the list-wise comparison, meaning a list of regular expressions may be supplied), using python-like regex syntax. +The only operator for which this behavior is not held is `===` (strict equality), it exists to allow exact list comparison. -`not` means that no regex match is found for all comparisons. ## Full Examples