geneontology / minerva

BSD 3-Clause "New" or "Revised" License
6 stars 8 forks source link

NullPointerException in ShexValidator when trying to report/handle ShEx non-conformant NOT individuals #399

Closed dustine32 closed 2 years ago

dustine32 commented 3 years ago

(@balhoff Sorry, this ticket's a mess. I just tried dumping out everything I looked at today)

Running ShEx validation on certain models throws a NullPointerException: str cannot be null error. Debugging, I can see it has to do with trying to getURI() on an axiom, then passing that result, which is null, into getCurie():

2021-07-26 17:07:00,790 INFO  (InferenceProvider:90) Running shex validation - model (enriched with superclass hierarchy) size:115
java.lang.NullPointerException: str cannot be null
    at org.semanticweb.owlapi.util.OWLAPIPreconditions.checkNotNull(OWLAPIPreconditions.java:98)
    at org.semanticweb.owlapi.model.IRI.create(IRI.java:216)
    at org.geneontology.minerva.validation.ShexValidator.getCurie(ShexValidator.java:866)
    at org.geneontology.minerva.validation.ShexValidator.getNodeTypes(ShexValidator.java:687)
    at org.geneontology.minerva.validation.ShexValidator.getUnmetConstraints(ShexValidator.java:782)
    at org.geneontology.minerva.validation.ShexValidator.getViolationForMismatch(ShexValidator.java:236)
    at org.geneontology.minerva.validation.ShexValidator.runShapeMapValidation(ShexValidator.java:178)
    at org.geneontology.minerva.server.inferences.MapInferenceProvider.create(MapInferenceProvider.java:91)
    at org.geneontology.minerva.server.inferences.InferenceProviderCreatorImpl.create(InferenceProviderCreatorImpl.java:112)
    at org.geneontology.minerva.server.inferences.CachingInferenceProviderCreatorImpl.create(CachingInferenceProviderCreatorImpl.java:60)
    at org.geneontology.minerva.cli.CommandLineInterface.validateGoCams(CommandLineInterface.java:1034)
    at org.geneontology.minerva.cli.CommandLineInterface.main(CommandLineInterface.java:394)
java.lang.NullPointerException
    at org.geneontology.minerva.validation.ValidationResultSet.<init>(ValidationResultSet.java:29)
    at org.geneontology.minerva.server.inferences.MapInferenceProvider.create(MapInferenceProvider.java:98)
    at org.geneontology.minerva.server.inferences.InferenceProviderCreatorImpl.create(InferenceProviderCreatorImpl.java:112)
    at org.geneontology.minerva.server.inferences.CachingInferenceProviderCreatorImpl.create(CachingInferenceProviderCreatorImpl.java:60)
    at org.geneontology.minerva.cli.CommandLineInterface.validateGoCams(CommandLineInterface.java:1034)
    at org.geneontology.minerva.cli.CommandLineInterface.main(CommandLineInterface.java:394)
2021-07-26 17:07:01,173 INFO  (CommandLineInterface:1165) done with validation

For any violating node, it will try SPARQL'ing out all types for that node, usually classes having URIs (e.g. GO:0003674). But in the case of a negated class (e.g. NOT GO:0060765), something like an axiom blank node ID is returned for these:

<http://model.geneontology.org/ZFIN_ZDB-GENE-030131-514/f8df1fb9-8e8e-4308-b005-d1177bb42178> a [ a owl:Class ;
            owl:complementOf GO:0060765 ],
        owl:NamedIndividual ;
    dc:contributor "GOC:zfin_curators" ;
    dc:date "2020-08-31" ;
    ns1:providedBy "http://zfin.org" .

image image That type value for the [ a owl:Class ; owl:complementOf GO:0060765 ] contrasts with the type value for a regular class: image

@balhoff I think the eventual goal with this ticket is to get the ShexValidator to handle reporting out node types that aren't URIs. But I could be wrong.

Some example ZFIN and MGI import models that trigger this error: ZFIN import model: ZFIN_ZDB-GENE-030131-514.ttl MGI import model: MGI_MGI_95499.ttl Manually created model w/ NOT: 5ce58dde00000102.ttl (does not trigger NPE because individuals of NOT class are considered conformant and so are not reported out)

Cmds to reproduce (download ttl, make journal, run ShEx) with dev branch https://github.com/geneontology/minerva/commit/fbcfbf9a7d0af3d74efbb0951538c9845c8c777d:

wget https://raw.githubusercontent.com/geneontology/zfin-go-cams/28ab23bf99219394a29ed207a370ad374422d3f8/models/ZFIN_ZDB-GENE-030131-514.ttl -P models/
rm -f blazegraph-dev.jnl
bin/minerva-cli.sh --import-owl-models -j blazegraph-dev.jnl -f models/
bin/minerva-cli.sh --validate-go-cams --shex -i blazegraph-dev.jnl -r shex_reports/ -ontojournal blazegraph-lego.jnl

Tagging @kltm @sierra-moxon

balhoff commented 2 years ago

Fixed by #433.