ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
259 stars 73 forks source link

class expressions read as 'rdfs:about' string from template #962

Closed reality closed 2 years ago

reality commented 2 years ago

We are trying to use class expressions to establish sc of axioms for classes in a template, e.g.

"('has atomic number' value ""2""^^xsd:nonNegativeInteger) and "('mass number' value ""4""^^xsd:nonNegativeInteger)"

in a column with "SC %" as the definition. In the file produced by robot, instead of having these class expression as subclassof axioms, the classes appear as subclasses of empty classes with an "rdfs:about" property of a string equivalent to the class expression in the template, e.g.:

image

In the OWL file, the classes look like this:

    <owl:Class rdf:about="(&apos;has atomic number&apos; value &quot;10&quot;^^xsd:nonNegativeInteger) and (&apos;mass number&apos; value &quot;20&quot;^^xsd:nonNegativeInteger)"/>

If I try to make a new axiom in Protege with the class expression as it appears in the file, it works fine, which implies that OWLAPI can parse it. I also tried removing the surrounding " from the axioms in the file, which didn't work. My guess would be some kind of encoding or processing of the quote symbols?

You can see the template here: https://github.com/Radiobiology-Informatics-Consortium/RBO/blob/luke-testing/src/templates/RBO_nuclei.tsv (and the owl file is also in that dir)

Thanks a lot in advance!

jamesaoverton commented 2 years ago

ROBOT has a QuotedEntityChecker which tries to handle quoted labels like Protege does during OWLAPI's Manchester parsing. We've seen lots of problems with quoting and unquoting for ROBOT templates because of differences in CSV flavours, Excel weirdness, quote characters in ontology term labels, etc. I've never seen anyone try to use a value expression in a ROBOT template. So you're right to suspect ROBOT's quotation handling.

But I did make this work. I started with the file you linked to, added a row for 'has atomic number', changed 'A definition' to 'A obo:definition' just so the file would be self-contained, and kept just one example row. I also had to add a closing quotation mark to the definition column for the example -- many of your definitions start with a double-quote but the matching double-quote is missing from the end of the cell.

Ontology ID Label   CLASS TYPE  Logical Type    Parent  Class Def   definition  Domain  Range
ID  LABEL   CLASS_TYPE  TYPE    CI  SC %    A obo:definition    DOMAIN  RANGE
obo:RBO_2000    has atomic number       data property               obo:RBO_00005001    xsd:nonNegativeInteger
obo:RBO_2001    mass number     data property               obo:RBO_00005001    xsd:nonNegativeInteger
obo:RBO_00000008    He-4 ion radiation  subclass    class   obo:RBO_00005001    "('has atomic number' value ""2""^^xsd:nonNegativeInteger) and ('mass number' value ""4""^^xsd:nonNegativeInteger)" "Atomic nuclei, each with 2 protons and 2 neutrons with kinetic energy imparted by natural or artificial means (such as by a particle accelerator)"

When I ran robot template -t rbo.tsv -o rbo.owl I saw a proper logical axiom for obo:RBO_00000008. So ROBOT can handle the value expressions, but the quoting is delicate.

jamesaoverton commented 2 years ago

One more note: The terrible rdfs:about value is ROBOT failing to interpret the Manchester expression as OWL logic and treating it as a URL for a class. That's one more thing I would handle better if I were rewriting the ROBOT template code.

reality commented 2 years ago

Thanks for the quick response. The quote/definition changes do not make any difference (but thanks for pointing it out). Also replacing the file with the snippet you gave above gives me the same problem,

<Class rdf:about="(&apos;has atomic number&apos; value &quot;2&quot;^^xsd:nonNegativeInteger) and (&apos;mass number&apos; value &quot;4&quot;^^xsd:nonNegativeInteger)"/>

using the command with 1.8.0-SNAPSHOT (though I get the same problem on 1.9.0-SNAPSHOT):

robot template --template ../templates/RBO_nuclei2.tsv --output ../templates/RBO_nuclei.owl -vvv

I get this output from -vvv:

2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for data property
2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for data property
2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for class
2022-01-14 15:56:38,704 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,705 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for data property
2022-01-14 15:56:38,705 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,710 INFO  org.obolibrary.robot.TemplateHelper - Parsing expression: obo:RBO_00005001
2022-01-14 15:56:38,714 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for data property
2022-01-14 15:56:38,714 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,715 INFO  org.obolibrary.robot.TemplateHelper - Parsing expression: obo:RBO_00005001
2022-01-14 15:56:38,715 WARN  org.obolibrary.robot.IOHelper - Could not create IRI for class
2022-01-14 15:56:38,715 WARN  org.obolibrary.robot.IOHelper - Cannot invoke "java.util.Map.keySet()" because "expanded" is null
2022-01-14 15:56:38,715 INFO  org.obolibrary.robot.TemplateHelper - Parsing expression: obo:RBO_00005001
2022-01-14 15:56:38,715 INFO  org.obolibrary.robot.TemplateHelper - Parsing expression: ('has atomic number' value "2"^^xsd:nonNegativeInteger) and ('mass number' value "4"^^xsd:nonNegativeInteger)
2022-01-14 15:56:38,717 DEBUG org.semanticweb.owlapi.utilities.Injector - Injecting object uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl@36676c1a
2022-01-14 15:56:38,717 DEBUG org.semanticweb.owlapi.utilities.Injector - Loading file META-INF/services/org.semanticweb.owlapi.model.OWLOntologyIRIMapper
2022-01-14 15:56:38,717 DEBUG org.semanticweb.owlapi.utilities.Injector - No files found for META-INF/services/org.semanticweb.owlapi.model.OWLOntologyIRIMapper
2022-01-14 15:56:38,717 DEBUG org.semanticweb.owlapi.utilities.Injector - Injecting values [[]] on method public void uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.setIRIMappers(java.util.Set).
2022-01-14 15:56:38,717 DEBUG org.semanticweb.owlapi.utilities.Injector - Injecting values [[org.semanticweb.owlapi.rio.RioJsonParserFactory@2dbf4cbd, org.semanticweb.owlapi.rio.RioBinaryRdfParserFactory@5b408dc3, org.semanticweb.owlapi.owlxml.parser.OWLXMLParserFactory@6d24ffa1, org.semanticweb.owlapi.rdf.turtle.parser.TurtleOntologyParserFactory@55e8ec2f, org.semanticweb.owlapi.rio.RioNQuadsParserFactory@7fc44dec, org.semanticweb.owlapi.rio.RioNTriplesParserFactory@7e3060d8, org.semanticweb.owlapi.rio.RioTrigParserFactory@7b64240d, org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxOntologyParserFactory@74cadd41, org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParserFactory@65a4798f, org.semanticweb.owlapi.rio.RioRDFXMLParserFactory@2692b61e, org.semanticweb.owlapi.krss2.parser.KRSS2OWLParserFactory@2e54db99, org.semanticweb.owlapi.rio.RioJsonLDParserFactory@4d098f9b, org.semanticweb.owlapi.rio.RioTrixParserFactory@62fad19, org.semanticweb.owlapi.functional.parser.OWLFunctionalSyntaxOWLParserFactory@4f2613d1, org.semanticweb.owlapi.rio.RioN3ParserFactory@20b5f2ac, org.semanticweb.owlapi.rio.RioTurtleParserFactory@47dbb1e2, org.semanticweb.owlapi.rio.RioRDFaParserFactory@293d0107, org.semanticweb.owlapi.oboformat.OBOFormatOWLAPIParserFactory@773f7880]] on method public void uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.setOntologyParsers(java.util.Set).
jamesaoverton commented 2 years ago

I tried a few different versions of ROBOT. My test file is working for me with 1.8.1 and later, but fails with 1.8.0. So now I suspect that the problem you're seeing is caused by PR #761 and fixed by PR #808.

Because of issue #952 it's hard to tell what "1.9.0-SNAPSHOT" really means. Can you please test using the latest released version of ROBOT: 1.8.3?

reality commented 2 years ago

That fixed it!! Thanks a lot. I wonder why I did not seem to get the MANCHESTER PARSE ERROR?

jamesaoverton commented 2 years ago

Ok, great. I think the lack of a Manchester parse error was part of the problem fixed by #808. Sorry for the trouble, but it's nice that it's already fixed.