Skip to content

Commit

Permalink
Fixed bug in attribute_type_id detection of attribute_type_id namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardBruskiewich committed Jun 16, 2023
1 parent d6d0824 commit 111360b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
8 changes: 0 additions & 8 deletions docs/validation_codes_dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,6 @@

**Description:** Non-Biolink CURIEs are tolerated, but not preferred, as term value for the attribute_type_id properties of edge attributes.

### warning.knowledge_graph.edge.attribute.type_id.unknown_prefix

**Message:** Edge has an attribute_type_id that has a CURIE prefix namespace unknown to Biolink

**Context:** edge_id, identifier

**Description:** The namespaces of 'attribute_type_id' terms may be incomplete with respect to Biolink Model version being used in the knowledge graph.

### warning.knowledge_graph.edge.attribute.type_id.deprecated

**Message:** Edge has a deprecated attribute_type_id
Expand Down
17 changes: 4 additions & 13 deletions reasoner_validator/biolink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,20 +571,11 @@ def validate_attributes(self, edge_id: str, edge: Dict):
infores == kp_source:
found_kp_knowledge_source = True

# if not a Biolink association_slot, at least,
# check if it is an id prefix known to Biolink.
# We won't call it a hard error, but issue a warning
elif not self.bmt.get_element_by_prefix(prefix):
# if not a Biolink 'association_slot', at least, check if the 'attribute_type_id' has a
# namespace (prefix) known to Biolink. We won't call it a hard error, but issue a warning
elif not self.bmt.get_element_by_prefix(attribute_type_id):
self.report(
code="warning.knowledge_graph.edge.attribute.type_id.unknown_prefix",
identifier=attribute_type_id,
edge_id=edge_id
)
# TODO: probably need to take a closer look at validating outlier terms here
# Maybe enumerations will help
else:
self.report(
code="info.knowledge_graph.edge.attribute.type_id.non_biolink_prefix",
code="warning.knowledge_graph.edge.attribute.type_id.non_biolink_prefix",
identifier=attribute_type_id,
edge_id=edge_id
)
Expand Down
6 changes: 0 additions & 6 deletions reasoner_validator/codes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ warning:
- edge_id
- identifier
$description: "Non-Biolink CURIEs are tolerated, but not preferred, as term value for the attribute_type_id properties of edge attributes."
unknown_prefix:
$message: "Edge has an attribute_type_id that has a CURIE prefix namespace unknown to Biolink"
$context:
- edge_id
- identifier
$description: "The namespaces of 'attribute_type_id' terms may be incomplete with respect to Biolink Model version being used in the knowledge graph."
deprecated:
$message: "Edge has a deprecated attribute_type_id"
$context:
Expand Down
22 changes: 18 additions & 4 deletions tests/test_biolink_compliance_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,12 +1030,27 @@ def test_pre_trapi_1_4_0_validate_missing_or_empty_attributes(query: Tuple):
"attributes": []
},
get_ara_test_case(),
# "Edge has empty attributes!"
# "Edge has empty attributes!" Allowed
""
),
(
# Query 3. EDAM-DATA:2526 ought to have an acceptable namespace
{
"attributes": [
{
"attribute_type_id": "EDAM-DATA:2526",
"value": "some-value"
}
]
},
get_ara_test_case(),
# "Edge has an acceptable namespace prefix
""
)
# CHEMBL.COMPOUND:CHEMBL112--biolink:occurs_together_in_literature_with->NCBIGene:762
]
)
def test_post_1_4_0_trapi_validate_missing_or_empty_attributes(query: Tuple):
def test_post_1_4_0_trapi_validate_attributes(query: Tuple):
validator = BiolinkValidator(
graph_type=TRAPIGraphType.Knowledge_Graph,
biolink_version=LATEST_BIOLINK_MODEL_VERSION,
Expand Down Expand Up @@ -2686,8 +2701,7 @@ def test_validate_biolink_curie_in_qualifiers(query: Tuple[str, Dict, str]):
},
# f"{KNOWLEDGE_GRAPH_PREFIX}: WARNING - Edge attribute_type_id 'foo:bar' " +
# f"has a CURIE prefix namespace unknown to Biolink!"
# TODO: Code for validating this is commented out pending a BMT repair of the test
"warning.knowledge_graph.edge.attribute.type_id.unknown_prefix"
"warning.knowledge_graph.edge.attribute.type_id.non_biolink_prefix"
),
( # Query 26: # An earlier Biolink Model won't recognize a category not found in its specified release
"1.8.2",
Expand Down

0 comments on commit 111360b

Please sign in to comment.