ontobio icon indicating copy to clipboard operation
ontobio copied to clipboard

question about owl:DatatypeProperty

Open saramsey opened this issue 3 years ago • 14 comments

Hello Ontobio team,

I have a simple RDF Turtle file test.ttl that I want to load using Ontobio:

@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix owl:  <http://www.w3.org/2002/07/owl#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://foo.com/bar> a owl:Class ;
        skos:prefLabel """some node"""@en ;
        <http://foo.com/baz> """test property"""^^xsd:string ;
.

<http://foo.com/baz> a owl:DatatypeProperty ;
    rdfs:label """test label""";
    rdfs:comment """test comment""" .

When I convert it to OWL using robot,

./robot convert --input test.ttl --output test.owl

I get something reasonable, including my "test property" as shown here:

    <NamedIndividual rdf:about="http://foo.com/bar">
        <foo:baz rdf:datatype="http://www.w3.org/2001/XMLSchema#string">test property</foo:baz>
    </NamedIndividual>

But when I load that test.owl file into ontobio 2.1.2,

rm  -r -f ~/.cachier
python3
import ontobio
ont = ontobio.ontol_factory.OntologyFactory().create("test.owl", ignore_cache=True)

I don't see the property in the node:

>>> ont = ontobio.ontol_factory.OntologyFactory().create("test.owl", ignore_cache=True)
>>> ont
test.owl handle: test.owl meta: {'subsets': [], 'xrefs': [], 'basicPropertyValues': []}
>>> ont.nodes()
NodeView(('http://foo.com/baz', 'http://foo.com/bar'))
>>> import pprint
>>> pprint.pprint(ont.node("http://foo.com/bar"))
{'id': 'http://foo.com/bar',
 'meta': {'basicPropertyValues': [{'pred': 'http://www.w3.org/2004/02/skos/core#prefLabel',
                                   'val': 'some node'}]},
 'type': 'INDIVIDUAL'}

Is there a way to load an OWL file into Ontobio and to programmatically access a owl:DatatypeProperty field of a class?

saramsey avatar Jan 08 '21 05:01 saramsey

My setup:

  • macOS 10.14.6
  • python 3.7.4
  • ontobio 2.1.2
  • networkx 2.2

saramsey avatar Jan 08 '21 05:01 saramsey

tagging @cmungall and @deepakunni3

saramsey avatar Jan 11 '21 05:01 saramsey

@saramsey This is an interesting observation.

One thing to note here is that Ontobio uses owltools to parse OWL to create a JSON representation.

While technically owltools and robot should be the same, but there is something else at play here.

Using Robot, if I were to convert the test.ttl to test.json (a form Ontobio recognizes), I get an error.

robot convert -vvv --input test.ttl --output test.json -f json

2021-01-11 13:30:10,064 DEBUG org.obolibrary.robot.IOHelper - Saving ontology Ontology(OntologyID(Anonymous-2)) [Axioms: 6 Logical Axioms: 1] First 20 axioms: {AnnotationAssertion(rdfs:label <http://foo.com/baz> "test label") AnnotationAssertion(rdfs:comment <http://foo.com/baz> "test comment") AnnotationAssertion(<http://www.w3.org/2004/02/skos/core#prefLabel> <http://foo.com/bar> "some node"@en) DataPropertyAssertion(<http://foo.com/baz> <http://foo.com/bar> "test property"^^xsd:string) Declaration(Class(<http://foo.com/bar>)) Declaration(DataProperty(<http://foo.com/baz>)) } as OboGraphs JSON Syntax with to IRI file:/Users/deepak.unni3/GIT/ontobio-master/test.json
2021-01-11 13:30:10,070 DEBUG org.obolibrary.robot.ExceptionHelper - {} missing exception message.
java.lang.NullPointerException
	at org.geneontology.obographs.owlapi.FromOwl.getNodeId(FromOwl.java:717)
	at org.geneontology.obographs.owlapi.FromOwl.generateGraph(FromOwl.java:515)
	at org.geneontology.obographs.owlapi.FromOwl.generateGraphDocument(FromOwl.java:110)
	at org.obolibrary.robot.IOHelper.saveOntologyFile(IOHelper.java:1121)
	at org.obolibrary.robot.IOHelper.saveOntology(IOHelper.java:583)
	at org.obolibrary.robot.IOHelper.saveOntology(IOHelper.java:524)
	at org.obolibrary.robot.ConvertCommand.execute(ConvertCommand.java:167)
	at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
	at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
	at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
	at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:55)
null
java.lang.NullPointerException
	at org.geneontology.obographs.owlapi.FromOwl.getNodeId(FromOwl.java:717)
	at org.geneontology.obographs.owlapi.FromOwl.generateGraph(FromOwl.java:515)
	at org.geneontology.obographs.owlapi.FromOwl.generateGraphDocument(FromOwl.java:110)
	at org.obolibrary.robot.IOHelper.saveOntologyFile(IOHelper.java:1121)
	at org.obolibrary.robot.IOHelper.saveOntology(IOHelper.java:583)
	at org.obolibrary.robot.IOHelper.saveOntology(IOHelper.java:524)
	at org.obolibrary.robot.ConvertCommand.execute(ConvertCommand.java:167)
	at org.obolibrary.robot.CommandManager.executeCommand(CommandManager.java:248)
	at org.obolibrary.robot.CommandManager.execute(CommandManager.java:192)
	at org.obolibrary.robot.CommandManager.main(CommandManager.java:139)
	at org.obolibrary.robot.CommandLineInterface.main(CommandLineInterface.java:55)

Now if I were to convert test.ttl to test.owl then it works as demonstrated above by @saramsey

And when I convert this derived test.owl to test.json,

robot convert --input test.owl --output test.json -f json

I get the following:

{
  "graphs" : [ {
    "nodes" : [ {
      "id" : "http://foo.com/baz",
      "meta" : {
        "comments" : [ "test comment" ]
      },
      "type" : "PROPERTY",
      "lbl" : "test label"
    }, {
      "id" : "http://foo.com/bar",
      "meta" : {
        "basicPropertyValues" : [ {
          "pred" : "http://www.w3.org/2004/02/skos/core#prefLabel",
          "val" : "some node"
        } ]
      },
      "type" : "INDIVIDUAL"
    } ],
    "edges" : [ ],
    "meta" : {
      "subsets" : [ ],
      "xrefs" : [ ],
      "basicPropertyValues" : [ ]
    },
    "equivalentNodesSets" : [ ],
    "logicalDefinitionAxioms" : [ ],
    "domainRangeAxioms" : [ ],
    "propertyChainAxioms" : [ ]
  } ]
}

While I see the owl:DatatypeProperty, it ends up as a node in the graph instead of a property on the node with IRI http://foo.com/bar.

@cmungall Thoughts?

deepakunni3 avatar Jan 11 '21 21:01 deepakunni3

It's correct for http://foo.com/baz to show up as a "node", since in this graph view, all entities are nodes, even properties. But I'm not sure how the triple should show up. Normally if you're linking objects, like with subClassOf, you would see an entry in the edges list: {'a', 'subClassOf, 'b'}` or similar, for example. It may be different because this is a datatype property.

dougli1sqrd avatar Jan 13 '21 21:01 dougli1sqrd

Thanks, @dougli1sqrd and @deepakunni3. Is the current behavior of ontobio on this example input (i.e., not showing any edge in the resulting ontobio object, corresponding to the datatype property) expected?

saramsey avatar Jan 14 '21 17:01 saramsey

@dougli1sqrd Agreed. We expect to see the dataTypeProperty as a node.

@saramsey No, the behavior is definitely not expected.

What we should be seeing is a proper edge that links http://foo.com/bar to test_property where the predicate is http://foo.com/baz. But "test property" is a string, having a direct edge doesn't make sense. So this should be a node property on node http://foo.com/bar.

deepakunni3 avatar Jan 14 '21 21:01 deepakunni3

Yeah should this be in one of the meta fields?

dougli1sqrd avatar Jan 20 '21 01:01 dougli1sqrd

Thanks for your replies, @deepakunni3 and @dougli1sqrd!

Great, a node property (in the ontobio object model) would be ideal for us. Any sense of how light or heavy a lift it will be, to make this change to owltools/ontobio?

saramsey avatar Jan 21 '21 19:01 saramsey

Hi ontobio team, just checking back on this-- do you think this is a feasible fix? Would the fix be in owltools or in ontobio?

saramsey avatar Feb 16 '21 05:02 saramsey

@cmungall Any recommendations on this?

Are only a selected set of properties end up in meta field of a node in OBOGraphs?

deepakunni3 avatar Feb 16 '21 20:02 deepakunni3

Hi @deepakunni3 @cmungall, do you have any updates on the status / feasibility of this fix? a few more issues that stem from this have cropped up on our end, so I thought I'd check back in :)

kvarforl avatar Mar 10 '21 17:03 kvarforl

a few things going on here. Looks like something unrelated to ontobio for ttl->rdfxml conversion? both owltools and robot are wrappers to the owlapi, but they may use different versions? if there is a bug it should be reported on the appropriate tracker.

but I think the question here is about the obograph spec. yes, this should be clarified, and yes we should make DPs nodes as we do for OPs. Can you add to obographs?

cmungall avatar Mar 10 '21 18:03 cmungall

a few things going on here. Looks like something unrelated to ontobio for ttl->rdfxml conversion? both owltools and robot are wrappers to the owlapi, but they may use different versions? if there is a bug it should be reported on the appropriate tracker.

but I think the question here is about the obograph spec. yes, this should be clarified, and yes we should make DPs nodes as we do for OPs. Can you add to obographs?

Thank you @cmungall ! For DPs, can there also be a triple (or alternately, a property on the DP node) that indicates the "parent" node for which it is a owlDatatypeProperty ?

saramsey avatar Mar 10 '21 20:03 saramsey

yes, it should have these edges

On Wed, Mar 10, 2021 at 12:16 PM Stephen A. Ramsey @.***> wrote:

a few things going on here. Looks like something unrelated to ontobio for ttl->rdfxml conversion? both owltools and robot are wrappers to the owlapi, but they may use different versions? if there is a bug it should be reported on the appropriate tracker.

but I think the question here is about the obograph spec. yes, this should be clarified, and yes we should make DPs nodes as we do for OPs. Can you add to obographs?

Thank you @cmungall https://github.com/cmungall ! For DPs, can there also be a triple (or alternately, a property on the DP node) that indicates the "parent" node that it is associated with?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/biolink/ontobio/issues/507#issuecomment-796027525, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAMMONVSDDGITF74R2NZGTTC7AR5ANCNFSM4VZ7BICA .

cmungall avatar Mar 11 '21 03:03 cmungall