Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding qualifiers to MetaEdge fixes #342 #387

Merged
merged 19 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
dc8dec2
add qualifiers object to the MetaEdge object
sierra-moxon Jan 9, 2023
9d827de
move type of association from string to BiolinkEntity to take advanta…
sierra-moxon Jan 9, 2023
b29904e
update test infrastructure to work with the latest reasoner-validator
sierra-moxon Jan 9, 2023
2b96079
Merge branch 'master' into mkg_qualifiers
sierra-moxon Jan 9, 2023
4639b96
clean up spacing in description
sierra-moxon Jan 9, 2023
ba25a70
Merge branch 'mkg_qualifiers' of https://github.com/sierra-moxon/Reas…
sierra-moxon Jan 9, 2023
1fabe2e
clean up spacing in description
sierra-moxon Jan 9, 2023
5a652fc
clean up spacing in description
sierra-moxon Jan 9, 2023
82da50b
clean up spacing
sierra-moxon Jan 9, 2023
e10288f
commiting to show issue of new schema, failing tests even when testin…
sierra-moxon Jan 9, 2023
f42e778
comment out metakg tests, waiting on issue 56 in reasoner-validator
sierra-moxon Jan 9, 2023
f1c5966
revert line length
sierra-moxon Jan 26, 2023
127ac4a
make association nullable, add to the description that a non-null ass…
sierra-moxon Jan 26, 2023
9e60bc0
update the version in the spec to 1.4.0-rc1
sierra-moxon Jan 26, 2023
fd30a1a
update the version in the spec to 1.4.0-dev
sierra-moxon Jan 26, 2023
d76e67f
add CURIE constraint to qualifier_type
sierra-moxon Jan 27, 2023
c578b08
add CURIE constraint to qualifier_type_id in MetaQualifier
sierra-moxon Jan 27, 2023
5038ac7
add qualifier_type_id required to MetaQualifier
sierra-moxon Feb 23, 2023
f478dc2
Merge branch '1.4' into mkg_qualifiers
edeutsch Mar 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion TranslatorReasonerAPI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ info:
url: https://github.com/NCATSTranslator/translator_extensions/blob/\
production/x-translator/
x-trapi:
version: 1.3.0
version: 1.4.0-dev
asyncquery: REPLACE-WITH-true-IF-/asyncquery-IS-IMPLEMENTED-ELSE-false
operations:
- LIST-ALL-SUPPORTED-OPERATION-IDS-HERE-OR-REMOVE-THIS-SECTION
Expand Down Expand Up @@ -1273,11 +1273,50 @@ components:
items:
$ref: '#/components/schemas/MetaAttribute'
nullable: true
qualifiers:
description: >-
Qualifiers that are possible to be found on this edge type.
items:
$ref: '#/components/schemas/MetaQualifier'
nullable: true
type: array
association:
type: object
$ref: '#/components/schemas/BiolinkEntity'
description: >-
The Biolink association type (entity) that this edge represents.
Associations are classes in Biolink
that represent a relationship between two entities.
For example, the association 'gene interacts with gene'
is represented by the Biolink class,
'biolink:GeneToGeneAssociation'. If association
is filled out, then the testing harness can
help validate that the qualifiers are being used
correctly.
example: biolink:ChemicalToGeneAssociation
required:
- subject
- predicate
- object
additionalProperties: false
MetaQualifier:
type: object
properties:
qualifier_type_id:
edeutsch marked this conversation as resolved.
Show resolved Hide resolved
$ref: '#/components/schemas/CURIE'
description: >-
The CURIE of the qualifier type.
example: biolink:subject_aspect_qualifier
nullable: false
applicable_values:
type: array
description: >-
The list of values that are possible for this qualifier.
items:
type: string
example: [expression, activity, abundance, degradation]
required:
- qualifier_type_id
MetaAttribute:
type: object
properties:
Expand Down
61 changes: 61 additions & 0 deletions examples/MetaKnowledgeGraph/metaedge_with_qualifiers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"nodes": {
"biolink:MolecularActivity": {
"id_prefixes": [
"RHEA",
"REACT",
"GO",
"UMLS"
]
},
"biolink:SmallMolecule": {
"id_prefixes": [
"CHEBI",
"CHEMBL.COMPOUND",
"UMLS",
"UNII",
"PUBCHEM.COMPOUND",
"DRUGBANK",
"MESH",
"KEGG.COMPOUND",
"HMDB",
"CAS",
"KEGG.DRUG"
]
}
},
"edges": [
{
"subject": "biolink:ChemicalEntity",
"predicate": "biolink:affects",
"object": "biolink:Gene",
"knowledge_types": [
"lookup"
],
"association": "biolink:ChemicalToGeneAssociation",
"qualifiers": [
{
"qualifier_type_id": "biolink:subject_aspect_qualifier",
"applicable_values": [
"expression",
"abundance"
]
},
{
"qualifier_type_id": "biolink:subject_aspect_qualifier",
"applicable_values": [
"expression",
"abundance",
"activity"
]
},
{
"qualifier_type_id": "biolink:qualified_predicate",
"applicable_values": [
"biolink:causes"
]
}
]
}
]
}
31 changes: 30 additions & 1 deletion tests/test_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def test_valid():
jsonschema.validate(spec, openapi_schema)


def test_examples():
def test_message_examples():
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(dir_path, '..', 'TranslatorReasonerAPI.yaml')) as f:
spec = yaml.load(f, Loader=yaml.SafeLoader)
print(spec)
dir_path_json = os.path.join(dir_path, '../examples/Message')
for filename in os.listdir(dir_path_json):
full_path = os.path.join(dir_path_json, filename)
Expand All @@ -36,6 +37,7 @@ def test_examples():
example = json.load(f)
trapi_version_locally = spec['info']['x-trapi']['version']
validator = TRAPISchemaValidator(trapi_version=trapi_version_locally)
print(validator.trapi_version)
try:
validator.validate(
instance=example,
Expand All @@ -45,3 +47,30 @@ def test_examples():
print(validator.to_dict(), file=stderr)
raise ValueError('TRAPI example is not valid against the trapi_version specified!')


def metakg_examples(): # def test_metakg_examples():
mtest_directory('../examples/MetaKnowledgeGraph', 'MetaKnowledgeGraph')
mtest_directory('../examples/Message', 'Message')


def mtest_directory(json_path, object_to_validate):
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(dir_path, '..', 'TranslatorReasonerAPI.yaml')) as f:
spec = yaml.load(f, Loader=yaml.SafeLoader)
dir_path_json = os.path.join(dir_path, json_path)
for filename in os.listdir(dir_path_json):
full_path = os.path.join(dir_path_json, filename)
file_extension = pathlib.Path(full_path).suffix
if file_extension == '.json':
with open(full_path) as f:
example = json.load(f)
trapi_version_locally = spec['info']['x-trapi']['version']
validator = TRAPISchemaValidator(trapi_version=trapi_version_locally)
try:
validator.validate(
instance=example,
component=object_to_validate
)
except ValidationError:
print(validator.to_dict(), file=stderr)
raise ValueError('TRAPI example is not valid against the trapi_version specified!')