cmungall / obo-shapes

Experiments using RDF shapes to constrain the structure of ontologies
0 stars 0 forks source link

Attempting to combine CLOSED with inheritance fails #1

Open cmungall opened 5 years ago

cmungall commented 5 years ago

I want to make a schema to see if my ontology follows a certain defined pattern, e.g. only a subset of annotation properties used.

My desired semantics are like a UML model, i.e. everything should be closed

I have a base class, declared closed:

https://github.com/cmungall/obo-shapes/blob/31b1741fdde50382afec998accb6493a471cb74a/obo-basic.shex#L12-L16

Then if I make a subshape:

https://github.com/cmungall/obo-shapes/blob/31b1741fdde50382afec998accb6493a471cb74a/obo-basic.shex#L18-L21

However, I want to prohibit random triples in my ontology like this:

https://github.com/cmungall/obo-shapes/blob/31b1741fdde50382afec998accb6493a471cb74a/tests/t01.ttl#L17

However, when I put the CLOSED keyword in OboClass and I pass in a valid ttl I get:

$ make test
shexeval -A tests/t01.ttl obo-basic.shex
Errors:
  Focus: http://purl.obolibrary.org/obo/GO_0000001
  Start: http://purl.obolibrary.org/obo/shapes/OboClass
  Reason:   Testing obo:GO_0000001 against shape http://purl.obolibrary.org/obo/shapes/OboClass
    Unmatched triples in CLOSED shape:
        <http://purl.obolibrary.org/obo/GO_0000001> <http://www.w3.org/2000/01/rdf-schema#comment> foo .
        <http://purl.obolibrary.org/obo/GO_0000001> <http://www.w3.org/2000/01/rdf-schema#label> c1 .

  Focus: http://purl.obolibrary.org/obo/GO_0000002
  Start: http://purl.obolibrary.org/obo/shapes/OboClass
  Reason:   Testing obo:GO_0000002 against shape http://purl.obolibrary.org/obo/shapes/OboClass
    Unmatched triples in CLOSED shape:
        <http://purl.obolibrary.org/obo/GO_0000002> <http://www.w3.org/2000/01/rdf-schema#comment> bar .
        <http://purl.obolibrary.org/obo/GO_0000002> <http://www.w3.org/2000/01/rdf-schema#label> c2 .

any tips @hsolbrig?

cmungall commented 5 years ago

Related discussion: https://github.com/geneontology/GO_Shapes/issues/14

https://github.com/shexSpec/shex/issues/50

cmungall commented 5 years ago

OK, I figured out that I can do what I want with EXTENDS - but this is not yet supported in pyshex

here is an example:

https://rawgit.com/shexSpec/shex.js/extends/packages/shex-webapp/doc/shex-simple.html?schema=%3CA%3E%20CLOSED%20%7B%20%3Cp1%3E%20%40%3CFoo%3E%20%7D%0A%3CB%3E%20CLOSED%20EXTENDS%20%40%3CA%3E%20%7B%20%3Cp1%3E%20%40%3CBar%3E%20%7D%0A%3CFoo%3E%20%5B1%5D%0A%3CBar%3E%20%5B2%5D%0A&data=%3Cn1%3E%20%3Cp1%3E%201%2C%202%20.&manifestURL=..%2Fexamples%2Fmanifest.json&shape-map=%3Cn1%3E%40%3CB%3E&interface=appinfo&regexpEngine=threaded-val-nerr

hsolbrig commented 5 years ago

Here is the same non-extends equivalent

https://rawgit.com/shexSpec/shex.js/extends/packages/shex-webapp/doc/shex-simple.html?schema=%3CA%3E%20CLOSED%20%7B%20%3Cp1%3E%20%40%3CFoo%3E%20%7D%0A%3CB%3E%20CLOSED%20EXTENDS%20%40%3CA%3E%20%7B%20%3Cp1%3E%20%40%3CBar%3E%20%7D%0A%3CFoo%3E%20%5B1%5D%0A%3CBar%3E%20%5B2%5D%0A&data=%3Cn1%3E%20%3Cp1%3E%201%2C%202%20.&manifestURL=..%2Fexamples%2Fmanifest.json&shape-map=%3Cn1%3E%40%3CB%3E&interface=appinfo&regexpEngine=threaded-val-nerr

Harold Solbrig

From: Chris Mungall notifications@github.com Reply-To: cmungall/obo-shapes reply@reply.github.com Date: Thursday, July 11, 2019 at 3:17 PM To: cmungall/obo-shapes obo-shapes@noreply.github.com Cc: Harold Solbrig solbrig@jhu.edu, Mention mention@noreply.github.com Subject: Re: [cmungall/obo-shapes] Attempting to combine CLOSED with inheritance fails (#1)

OK, I figured out that I can do what I want with EXTENDS - but this is not yet supported in pyshex

here is an example:

https://rawgit.com/shexSpec/shex.js/extends/packages/shex-webapp/doc/shex-simple.html?schema=%3CA%3E%20CLOSED%20%7B%20%3Cp1%3E%20%40%3CFoo%3E%20%7D%0A%3CB%3E%20CLOSED%20EXTENDS%20%40%3CA%3E%20%7B%20%3Cp1%3E%20%40%3CBar%3E%20%7D%0A%3CFoo%3E%20%5B1%5D%0A%3CBar%3E%20%5B2%5D%0A&data=%3Cn1%3E%20%3Cp1%3E%201%2C%202%20.&manifestURL=..%2Fexamples%2Fmanifest.json&shape-map=%3Cn1%3E%40%3CB%3E&interface=appinfo&regexpEngine=threaded-val-nerr

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/cmungall/obo-shapes/issues/1?email_source=notifications&email_token=AADFRNT5ZFTPO7FEONMW3ZTP66IL7A5CNFSM4IAUYDWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZX3PRY#issuecomment-510638023, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AADFRNVTLA7LS6TICJFZFTDP66IL7ANCNFSM4IAUYDWA.

hsolbrig commented 5 years ago

Here is the current idiom I’m using in biolinkml. Note that the presence of type arcs complicates the picture slightly, so it isn’t obvious that Extends will actually work in this situation. The general idea is that represents the set of triples in the class with the type arc being optional. The motivation for the optional type arc within the triple set is driven more by a lexical constraint – I have not been able to figure out how to express:

CLOSED { ( $ ( & ) ; rdf:type [ ] ) } In the ShEx Grammar Concrete leaf node: CLOSED { ( $ ( & ; rdf:type [ ] ? ) ; rdf:type [ ] ) } Concrete parent node ( CLOSED { ( $ ( & ; rdf:type [ ] ? ) ; rdf:type [ ] ) } OR @ OR @ OR @ ) Or a bit more fleshed out example: ( CLOSED { ( $ ( & ; rdf:type [ ] ? ; & ; rdf:type [ ] ? ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ; @ * ) ; rdf:type [ ] ) } OR @ OR @ OR @ ) Abstract parent node ( @ OR @ OR @ ) { ( $ rdf:type . * ; rdf:type [ ] ? ) } { ( $ ( & ; rdf:type [ ] ? ; @ ? ; @ ? ; @ ? ; @ ? ) ; rdf:type [ ] ? ) } Harold Solbrig Assistant Professor Johns Hopkins University | Division of General Internal Medicine 2024 E Monument St | Suite 1-200 | Baltimore, MD 21287 +1 (507) 319-2628 | solbrig@jhu.edu Harold Solbrig From: Chris Mungall Reply-To: cmungall/obo-shapes Date: Thursday, July 11, 2019 at 3:17 PM To: cmungall/obo-shapes Cc: Harold Solbrig , Mention Subject: Re: [cmungall/obo-shapes] Attempting to combine CLOSED with inheritance fails (#1) OK, I figured out that I can do what I want with EXTENDS - but this is not yet supported in pyshex here is an example: https://rawgit.com/shexSpec/shex.js/extends/packages/shex-webapp/doc/shex-simple.html?schema=%3CA%3E%20CLOSED%20%7B%20%3Cp1%3E%20%40%3CFoo%3E%20%7D%0A%3CB%3E%20CLOSED%20EXTENDS%20%40%3CA%3E%20%7B%20%3Cp1%3E%20%40%3CBar%3E%20%7D%0A%3CFoo%3E%20%5B1%5D%0A%3CBar%3E%20%5B2%5D%0A&data=%3Cn1%3E%20%3Cp1%3E%201%2C%202%20.&manifestURL=..%2Fexamples%2Fmanifest.json&shape-map=%3Cn1%3E%40%3CB%3E&interface=appinfo®expEngine=threaded-val-nerr — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.