Giter VIP home page Giter VIP logo

owlapi's People

Contributors

ansell avatar b-gehrke avatar balhoff avatar cmungall avatar csnyulas avatar daltontc avatar dependabot[bot] avatar elenimikro avatar fanavarro avatar galigator avatar hkir-dev avatar ignazio1977 avatar kse-ct avatar lewismc avatar lorenzbuehmann avatar matthewhorridge avatar mnmercer avatar mrnolte avatar nicolasrouquette avatar phillipross avatar phillord-ncl avatar prakashsagadevan avatar radw2020 avatar reality avatar sesuncedu avatar silversteven avatar sszuev avatar stain avatar tayloj avatar tsarkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owlapi's Issues

IllegalArgumentException thrown when serializing to RDF/XML using JDK 7

With JDK 7 an exception is thrown when serializing to RDF/XML.

java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:868)
at java.util.TimSort.mergeAt(TimSort.java:485)
at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
at java.util.TimSort.sort(TimSort.java:223)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.coode.owlapi.rdf.model.RDFGraph.getSortedTriplesForSubject(RDFGraph.java:123)
at org.coode.owlapi.rdf.rdfxml.RDFXMLRenderer.render(RDFXMLRenderer.java:193)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntity(RDFRendererBase.java:302)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntities(RDFRendererBase.java:294)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderClasses(RDFRendererBase.java:258)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderInOntologySignatureEntities(RDFRendererBase.java:242)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderOntologyComponents(RDFRendererBase.java:230)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.render(RDFRendererBase.java:215)
at org.coode.owlapi.rdf.rdfxml.RDFXMLOntologyStorer.storeOntology(RDFXMLOntologyStorer.java:86)
at org.semanticweb.owlapi.util.AbstractOWLOntologyStorer.storeOntology(AbstractOWLOntologyStorer.java:94)
at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.saveOntology(

It occurred with a version of CHEBI.

I think the issue is at the end of the compareTo() method:

if (diff == 0) {
diff = 1;
}
return diff;

This means that 0 will never be returned, so suppose there are two elements which are equal, i.e., in a distance you'd expect to get 0: a.compareTo(b) returns 1, and b.compareTo(a) returns 1 as well. If this is extended to three elements, then it's clear this is not transitive if the elements are close enough that diff is 0 at the end of the method, because it'd look like:
a<b b<c c<a.

The exception depends on JDK 7, as in this version a check for this condition was introduced, while the previous JDKs would ignore the condition and accept the wrong sorting obtained as a result.

Update OBO parser to use oboformat 5.X (obo 1.4)

The current OBO parser refers to an old version of the OBO specs.

There is an updated parser for obo at
https://code.google.com/p/oboformat/

Current issues with this code:

  • it is packaged as a single maven module depending on OWLAPI distribution 3.4.3, which creates circular dependencies if we tried to include it as it is.
  • I could not find license notices telling me whether it would be fine to include it as an OWLAPI module.

I have made changes locally to try and address the above dependencies, and the code works without hitches.

Input with character = 0240 (octal) should fail parsing but is read in as an owl/xml file

This bug has to do with a problem loading a malformed RDF/XML file. The file can be downloaded from here

http://protege.stanford.edu/fileshare/tredmond/test1.owl

The problem with the file is that it has a single non-ascii character in the middle of it (octal 240) and therefore this file cannot be parsed as RDF. This character makes this file invalid as UTF-8 but I don't know if this fact is playing into the bug.

Unfortunately, what the OWL api succeeds in loading this file because it erroneously thinks that it can be parsed as OWL/XML.

Here is the code that I used to load the owl file (you will need to change the wired in pathname to run this):

package owl.io;

import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyManager;

public class LoadWithBadCharacter {

public static void main(String args[]) throws OWLOntologyCreationException {
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create("file:/home/redmond/work/Shared/ontologies/Test/test1.owl"));
    System.out.println("Ontology has " + ontology.getAxiomCount() + " axioms.");
    System.out.println("Ontology is in the " + manager.getOntologyFormat(ontology) + " format.");
}

}

Here is the generated output:

Ontology has 0 axioms.
Ontology is in the OWL/XML format.

-Timothy

Event for ontology removals and signature changes

From Luigi Iannone:

It would be useful to get notifications whenever an ontology is removed from an OWLOntologyManager.

Ignazio: discussed with Matthew the introduction of an event for ontology signature changes as well. Should tie in with the use of an event bus

StreamDocumentSource buffer can be big

ReaderDocumentsource and StreamDocumentSource buffer the entire content in memory.

A similar issue arises with remote sources: parsing with multiple parsers will open a connection and download data for each parser tried.

stamp of quality and setAddMissingTypes

When I look at an OWL ontology formatted as RDF, I often look for the "Generated by the OWL API" line at the bottom as a stamp of quality. In particular, I don't usually expect to see such ontologies ending up as OWL 2 full. However setting the addMissintgTypes flag in the RDFOntologyFormat may result OWL 2 full ontologies because declarations needed for a reliable parse are missing. It would be nice if the generated by the OWL api message would include whether or not the addMissingTypes flag was set to false.

This came up because I was looking at an OWL 2 full ontology recently that had the "Generated by the OWL API" message at the bottom. This left me curious as to how this had happened.

-Timothy

Functional Syntax Parser does not support comments

This was posted on the Protege mailing list. The functional syntax allows comments but it seems like the OWL API parsers do not (not yet confirmed).


This is a bit understandable because the discussion of comments in the OWL functional syntax was not complete in the First Edition of the OWL functional syntax.  However, the current version does state that comments are part of the OWL functional syntax, so Protege should allow them.'''

IRITest fails on openJDK 6

Spurred by failures in Travis, I tried openjdk 6 locally in a Linux VM.

The errors in Travis canot be replicated, but I get failures for IRITest - the concurrent tests fail to terminate within 60 seconds.

OMN writer generates unparsable file when axioms are duplicated with annotations

Input:

Ontology(<http://x.org/>
Declaration(Class(<http://x.org/c>))
AnnotationAssertion(<http://x.org/p> <http://x.org/c> "v1")
AnnotationAssertion(<http://x.org/p> <http://x.org/c> "orifice")
AnnotationAssertion(Annotation(<http://x.org/p2> "foo") <http://x.org/p> <http://x.org/c> "v1")
)

Output:

...
Class: <http://x.org/c>

    Annotations: 
        <http://x.org/p> "v1",
        ,

            Annotations: <http://x.org/p2> "foo"
        <http://x.org/p> "v1",
        <http://x.org/p> "orifice"

Note: in creating a minimal ontology to reproduce this error I observed various arbitrary but deterministic changes in behavior. E.g. changing the strings in the above sometimes eliminates the issue.

Note also that going via RDF/XML eliminates the error in this particular case (by losing the unannotated axiom - is that a bug too, not clear about spec here). However, there are larger examples in which rdf/xml->omn produces the same kind of error.

Allow stricter parsing/saving of ontologies, fixing profile violations.

Edited by Ignazio
(WAS: Invalid RDFXML output - rdf:Description is forbidden as a property element)

I am parsing an OWL ontology and I am dumping the content of it (and the closure of imports) into RDFXML. The RDFXML that generates seems to be invalid (see line 829).

Another RDFXML parser (raptor) throws the following error when trying to parse the output:

owlapi.xrdf:829 - rdf:Description is forbidden as a property element.

The original OWL file can be downloaded from here:

http://bioportal.bioontology.org/ontologies/CPO

    808     <Class rdf:about="http://phenomebrowser.net/cellphenotype.owl#C3PO:000000015">
    809         <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">phosphopyruvate hydratase complex phenotype</rdfs:    809 label>
    810         <equivalentClass>
    811             <Restriction>
    812                 <onProperty rdf:resource="http://phenomebrowser.net/ro2.owl#phenotype-of"/>
    813                 <someValuesFrom>
    814                     <Restriction>
    815                         <onProperty rdf:resource="http://phenomebrowser.net/ro2.owl#has-part"/>
    816                         <someValuesFrom>
    817                             <Restriction>
    818                                 <onProperty rdf:resource="http://phenomebrowser.net/ro2.owl#part-of"/>
    819                                 <someValuesFrom rdf:resource="http://purl.obolibrary.org/obo/GO_0000015"/>
    820                             </Restriction>
    821                         </someValuesFrom>
    822                     </Restriction>
    823                 </someValuesFrom>
    824             </Restriction>
    825         </equivalentClass>
    826         <rdfs:subClassOf rdf:resource="http://phenomebrowser.net/cellphenotype.owl#C3PO:000000000"/>
    827         <rdfs:subClassOf rdf:resource="http://phenomebrowser.net/cellphenotype.owl#C3PO:000043234"/>
    828         <rdfs:subClassOf rdf:resource="http://phenomebrowser.net/cellphenotype.owl#C3PO:000044445"/>
    829         <rdf:Description rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Any observable characteristic of phosphopyruv    829 ate hydratase complex.</rdf:Description>
    830     </Class>

Immutable OWLOntology implementation

The only implementation of OWLOntology interface, OWLOntologyImpl also implements OWLMutableOntology. So while OWL API methods which change ontology check if the provided ontology is a MutableOWLOntology, it is not really possible to obtain an immutable OWLOntology object without writing a wrapper around the provided implementation.

Ignazio: this would tie nicely with Matthew's idea of distinguishing ontologies from ontology documents.

No warning for missing xml:base causes unexpected import

The following code

public class TestCommonImport01 {

    /**
     * @param args
     * @throws OWLOntologyCreationException 
     */
    public static void main(String[] args) throws OWLOntologyCreationException {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        manager.loadOntologyFromOntologyDocument(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/actingfor.owl"));
        manager.loadOntologyFromOntologyDocument(IRI.create("http://ontologydesignpatterns.org/ekp/Airline.owl"));
    }
}

run against the latest OWL api (pulled from git)

 Exception in thread "main" org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology:  Cause: Ontology already exists. OntologyID(OntologyIRI())
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1259)
    at org.coode.owlapi.rdfxml.parser.TPImportsHandler.handleTriple(TPImportsHandler.java:89)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.handleStreaming(OWLRDFConsumer.java:1750)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.statementWithResourceValue(OWLRDFConsumer.java:1709)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.statementWithResourceValue(RDFParser.java:468)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser$EmptyPropertyElement.startElement(RDFParser.java:907)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser$PropertyElementList.startElement(RDFParser.java:800)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.startElement(RDFParser.java:208)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser$1.startElement(RDFXMLParser.java:91)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2717)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.parse(RDFParser.java:135)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:119)
    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:206)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:827)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:765)
    at owl.TestCommonImport01.main(TestCommonImport01.java:17)
Caused by: org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException: Ontology already exists. OntologyID(OntologyIRI())
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:838)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:747)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1222)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1253)
    ... 27 more
Caused by: org.semanticweb.owlapi.model.OWLOntologyRenameException: Could not rename ontology. An ontology with this ID already exists: OntologyID(OntologyIRI())
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.checkForOntologyIDChange(OWLOntologyManagerImpl.java:571)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.enactChangeApplication(OWLOntologyManagerImpl.java:460)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.applyChanges(OWLOntologyManagerImpl.java:481)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.applyChange(OWLOntologyManagerImpl.java:523)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.applyChange(OWLRDFConsumer.java:965)
    at org.coode.owlapi.rdfxml.parser.TypeOntologyHandler.handleTriple(TypeOntologyHandler.java:72)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.handleStreaming(OWLRDFConsumer.java:1730)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.statementWithResourceValue(OWLRDFConsumer.java:1709)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.statementWithResourceValue(RDFParser.java:468)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser$NodeElement.startElement(RDFParser.java:747)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser$NodeElementList.startElement(RDFParser.java:685)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.startElement(RDFParser.java:208)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser$1.startElement(RDFXMLParser.java:91)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:506)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:766)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:353)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2717)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.parse(RDFParser.java:135)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:119)
    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:206)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:827)
    ... 30 more

Unfortunately as described, this issue might have a temporal aspect to it: today the code might fail as described and tomorrow it might work. The problem is that the issue is not as simple as the fact that the two ontologies have a common import. I tried the following code (loading two files into the same ontology manager with a common import) and nothing bad happened:

public class TestCommonImport03 {
    public static final String PREFIX = "http://protegebug.org/TestCommonImport.owl";
    public static final OWLClass A;
    public static final OWLAxiom AXIOM;
    static {
        OWLDataFactory factory = OWLManager.getOWLDataFactory();
        A = factory.getOWLClass(IRI.create(PREFIX + "#A"));
        AXIOM = factory.getOWLEquivalentClassesAxiom(A, factory.getOWLThing());
    }

    public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
        File[] importingFiles = createFiles();
        testLoad(importingFiles);
    }
    
    private static File[] createFiles() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException {
        List changes = new ArrayList();
        
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLDataFactory factory = manager.getOWLDataFactory();
        File importedFile = File.createTempFile("TCI-Imported", ".owl");
        IRI importedIRI = IRI.create(importedFile.toURI());
        OWLOntology importedOntology = manager.createOntology(importedIRI);
        OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(importedIRI);
        changes.add(new AddAxiom(importedOntology, AXIOM));
        
        File importingFile1 = File.createTempFile("TCI-Importing", ".owl");
        OWLOntology ontology1 = manager.createOntology(IRI.create(importingFile1.toURI()));
        changes.add(new AddImport(ontology1, importDeclaration));
        File importingFile2 = File.createTempFile("TCI-Importing", ".owl");
        OWLOntology ontology2 = manager.createOntology(IRI.create(importingFile2.toURI()));
        changes.add(new AddImport(ontology2, importDeclaration));
        manager.applyChanges(changes);
        
        manager.saveOntology(importedOntology);
        manager.saveOntology(ontology1);
        manager.saveOntology(ontology2);
        return new File[] { importingFile1, importingFile2 };
    }
    
    private static void testLoad(File[] importingFiles) throws OWLOntologyCreationException {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        for (File f : importingFiles) {
            System.out.println("loading file: " + f);
            OWLOntology ontology = manager.loadOntologyFromOntologyDocument(IRI.create(f.toURI()));
            System.out.println("A is in the ontology? " + ontology.containsEntityInSignature(A, false));
            System.out.println("A is in the imports closure? " + ontology.containsEntityInSignature(A, true));
        }
    }

}

Parsing error with owlapi 3.4.5 - Informed Consent Permission Ontology

The Informed Consent Permission Ontology from BioPortal throws a nullpointer when opening it with protege4 or trying to parse it with the owlapi-3.4.5

You can download the ontology with release date 01/27/2013 from here

http://bioportal.bioontology.org/ontologies/49703

This ontology opens correctly with protege3.

java.lang.NullPointerException
    at org.semanticweb.owlapi.model.NodeID.isAnonymousNodeIRI(NodeID.java:99)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser$3.isAnonymousNode(RDFXMLParser.java:103)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.isAnonymousNode(OWLRDFConsumer.java:878)
    at org.coode.owlapi.rdfxml.parser.AbstractClassExpressionTranslator.isAnonymous(AbstractClassExpressionTranslator.java:96)
    at org.coode.owlapi.rdfxml.parser.NamedClassTranslator.matchesLax(NamedClassTranslator.java:66)
    at org.coode.owlapi.rdfxml.parser.AbstractClassExpressionTranslator.matches(AbstractClassExpressionTranslator.java:80)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.translateClassExpressionInternal(OWLRDFConsumer.java:2003)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.translateClassExpression(OWLRDFConsumer.java:1983)
    at org.coode.owlapi.rdfxml.parser.SWRLAtomListItemTranslator.translate(SWRLAtomListItemTranslator.java:98)
    at org.coode.owlapi.rdfxml.parser.SWRLAtomListItemTranslator.translate(SWRLAtomListItemTranslator.java:66)
    at org.coode.owlapi.rdfxml.parser.OptimisedListTranslator.translateList(OptimisedListTranslator.java:87)
    at org.coode.owlapi.rdfxml.parser.OptimisedListTranslator.translateList(OptimisedListTranslator.java:143)
    at org.coode.owlapi.rdfxml.parser.OptimisedListTranslator.translateToSet(OptimisedListTranslator.java:149)
    at org.coode.owlapi.rdfxml.parser.SWRLRuleTranslator.translateRule(SWRLRuleTranslator.java:100)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.consumeSWRLRules(OWLRDFConsumer.java:1585)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.endModel(OWLRDFConsumer.java:1452)
    at org.semanticweb.owlapi.rdf.syntax.RDFParser.parse(RDFParser.java:136)
    at org.coode.owlapi.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:119)
    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:206)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:829)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:782)
    at org.stanford.ncbo.oapiwrapper.OntologyParser.findMasterFile(OntologyParser.java:184)
    at org.stanford.ncbo.oapiwrapper.OntologyParser.internalParse(OntologyParser.java:133)
    at org.stanford.ncbo.oapiwrapper.OntologyParser.parse(OntologyParser.java:115)
    at org.stanford.ncbo.oapiwrapper.OntologyParserCommand.main(OntologyParserCommand.java:51)

GZipStreamDocumentSource.isReaderAvailable should not always return false

There is an implementation in GZipStreamDocumentSource for getReader(). This implies that isReaderAvailable should not always return false. It should return the same value as isInputStreamAvailable(), which checks whether the file exists.

On a broader note, it is possible to extend GZipStreamDocumentSource to work directly from an InputStream in-memory to avoid having to serialise GZIP streams to load them directly into OWLAPI? (It seems like a misnomer to refer to it as a Stream document source when it is implemented as a File document source. ;) )

Null anonymous individual parsing ObjectHasValue from OWL/XML

I end up with the following exception when reading a (previously rendered) ontology containing anonymous individuals:
java.lang.IllegalArgumentException: individual cannot be null

For instance when loading:

    <SubClassOf>
        <Class IRI="http://test.com/test#M"/>
        <ObjectHasValue>
            <ObjectProperty IRI="http://test.com/test#r1"/>
            <AnonymousIndividual nodeID="_:ano1"/>
        </ObjectHasValue>
    </SubClassOf>

IRI.create(String,String) uses different algorithm to IRI.create(String)

IRI.create(String,String) relies on the implementor using the same algorithm as IRI.create(String), which is trivially not the case for some parsers and will not in general be the case.

The simplest way to fix the bug would be to have IRI.create(String,String) temporarily create a new string to call IRI(String) that will split the string consistently and then call IRI(String,String) for caching the prefix.

This was reported by Heiko Dietze on the maining list.

parse exceptions structure

Matthew in a comment:
For 4.0 the extension of SAXException should definitely be changed. We could also consider non-checked exceptions I suppose.

Tool for detecting axioms that can't be saved in a format

feature request n. 54 from sourceforge (Timothy Redmond)

It would be nice to have some way to check whether an ontology can be saved in its entirety in a particular format. Currently the format that I know has an issue (well LaTeX doesn't count...) is the Manchester OWL Syntax format. It can't support entity annotations when the entity is not declared and GCI's. Are these the only two cases where the Manchester OWL Syntax will lose axioms on a save? A utility could know this and supply the needed information.

Some context for this issue can be found in the mail thread:
https://mailman.stanford.edu/pipermail/p4-feedback/2011-May/003881.html

Default prefix manager in prefix ontology format objects cannot be overriden

The prefix mapper current has an inbuilt Comparator attached to a TreeMap that at least one user would like to override to change to return the prefixes in a different order.

Is there any code that depends on the iterator for the TreeMap returning the prefixes in string-length order rather than plain lexical ordering? For example, does anything iterate through to find the longest match and relies on the current Comparator implementation.

If there isn't it shouldn't be too difficult to expose the ability to set the prefix manager.

add Collection get...(Collection c) style methods

Performance is bad for things like getSignature(),
getAxioms()... because of defensive copies. adding methods where a
collection is passed in and returned allows to, e.g., pass in a list
and not do any defensive copying for just listing all entities in a
signature.

Another approach is to add push visitors, i.e., a method to accept a
visitor to be run on every element in an internal collection.

update: see guava filters for ideas

TravisCI version4 build fails to complete javadoc generation for JDK6

The TravisCI build for version4 fails when it tries to complete the javadoc generation for JDK6:

[ERROR] Exit code: 1 - /home/travis/build/ansell/owlapi/distribution/target/distro-javadoc-sources/guava-14.0.1-sources/com/google/common/base/Preconditions.java:24: cannot find symbol
[ERROR] symbol : class Nullable
[ERROR] location: package javax.annotation
[ERROR] import javax.annotation.Nullable;

The cause seems to be that the jsr305 annotations are not included by default, according the guava website. It is not clear why it succeeds on Java7, but a fix should be to explicitly add the jsr305 annotations as maven dependencies wherever guava is used.

https://code.google.com/p/guava-libraries/wiki/UseGuavaInYourBuild

RDFGraph.getSortedTriplesForSubject throws exception in Java7

I received an exception that in general indicates that the Comparator.compare method is not consistent with the basic contract. These exceptions are only generated in Java-7 (but can be avoided using a system property if need be, although that wouldn't fix the issue).

The exception was generated with a stacktrace that goes through my OpenRDF Sesame Rio renderer, but the error is likely to be in RDFRendererBase.TripleComparator.

Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeLo(TimSort.java:747)
at java.util.TimSort.mergeAt(TimSort.java:483)
at java.util.TimSort.mergeCollapse(TimSort.java:410)
at java.util.TimSort.sort(TimSort.java:214)
at java.util.TimSort.sort(TimSort.java:173)
at java.util.Arrays.sort(Arrays.java:659)
at java.util.Collections.sort(Collections.java:217)
at org.coode.owlapi.rdf.model.RDFGraph.getSortedTriplesForSubject(RDFGraph.java:130)
at org.semanticweb.owlapi.rio.RioRenderer.render(RioRenderer.java:189)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntity(RDFRendererBase.java:340)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderEntities(RDFRendererBase.java:332)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderNamedIndividuals(RDFRendererBase.java:291)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderInOntologySignatureEntities(RDFRendererBase.java:281)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.renderOntologyComponents(RDFRendererBase.java:268)
at org.coode.owlapi.rdf.renderer.RDFRendererBase.render(RDFRendererBase.java:253)

The most interesting piece of code in the comparator, to me, seems to be the following if statement near the end:

        if (diff == 0) {
            diff = 1;
        }

Does anyone know why equal elements are defined as after? It should be up to the sorter to keep elements from moving if they are equal, which seems to be what that statement does.

investigate variables as IRIs

SPARQL DL might require some way to represent variables. Maybe cross pollination with OPPL? Or a scheme to represent variables as IRIs?

OWLLiteral uses rdf:PlainLiteral for language literals instead of rdf:langString

OWLLiteral currently has a contract to use the datatype rdf:PlainLiteral for language literals. The current RDF-1.1 drafts however define the datatype of language literals to be rdf:langString.

If version 4 is going to be compatible with RDF-1.1 then it should be using rdf:langString.

Some of the javadoc seems to imply that rdf:langString will appear in Turtle/N-Triples as a datatype in addition to the language. In RDF-1.1 it is still not allowed to have a datatype in the Turtle document if you have a language. The parser/interpreter needs to infer rdf:langString internally for language literals.

PlainLiterals in RDF-1.1 should be typed as xsd:string internally, but I think that works properly currently.

IRI.equals() bug

Reported on the OWL API mailing list.

I have a couple of questions regarding class IRI. Consider the following snippet:

IRI i1 = IRI.create("urn:us:gov:ic:cvenum:pubsxml:country:fips:digraph:v1:YO");
IRI i2 = IRI.create("urn:us:gov:ic:cvenum:pubsxml:country:fips:digraph:v1:", "YO");
System.out.println(i1.equals(i2));

IRI s1 = IRI.create("http://www.w3.org/2004/02/skos/core#related");
IRI s2 = IRI.create("http://www.w3.org/2004/02/skos/core#", "related");
System.out.println(s1.equals(s2));

The key point is that the pairs of IRIs are created using the one- and two-string variants of create(). Executing this code yields the output:

false

trying to read an ontology from a web page url hangs

This test hangs forever:

    @Test(expected = UnloadableImportException.class)
    public void shouldThrowExceptionWithDefaultImportsconfig()
            throws OWLOntologyCreationException {
        String input = "<?xml version=\"1.0\"?>\n"
                + "<rdf:RDF xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n"
                + "     xmlns:owl=\"http://www.w3.org/2002/07/owl#\"\n"
                + "     xmlns:xsd=\"http://www.w3.org/2001/XMLSchema#\"\n"
                + "     xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n"
                + "    <owl:Ontology rdf:about=\"http://www.semanticweb.org/fake/ontologies/2012/8/1\">\n"
                + "        <owl:imports rdf:resource=\"http://www.bbc.co.uk/news/\"/>\n"
                + "    </owl:Ontology>\n" + "</rdf:RDF>";
        OWLOntologyManager manager = Factory.getManager();
        manager.loadOntologyFromOntologyDocument(
                new StringDocumentSource(input));
    }

stamp of quality and user edits

At a first guess, I think that this feature request may be tricky to implement and it may be too much effort for the benefit.

When I look at an OWL ontology formatted as RDF, I often look for the "Generated by the OWL API" line at the bottom as a stamp of quality. However even if the OWL API generated a perfectly good ontology, it is possible that a user will use some sort of text editor to modify the ontology and will forget to update the comment at the bottom of the file.

It would be nice if the OWL api included a checksum of the data above the "generated by the OWL API" comment. A user who wants to see if the ontology has been modified since it was written by the OWL api can remove the last line of the OWL file and see if the checksums match. This will not prevent malicious behavior but it will usually allow a user to see if an ontology as seen by the user was actually output from the OWL API.

When I think about this it seems that it might be a bit tricky to implement. I think that it would have to be done at the byte level as opposed to the character level. This might involve somehow hooking in an input stream at in the IO channel
This came up because I was looking at an OWL 2 full ontology recently
that had the "Generated by the OWL API" message at the bottom. This
left me curious as to how this had happened.

Additional OWLPrimitive interface

It would be nice to have an interface that covers OWLEntity, IRI and OWLLiteral (and probably OWLAnonymousIndividual), which marks these objects as primitive objects. Add a visitor for visiting primitive objects as well.

Solve queries

I'm trying to use this class to solve some queries in dl query but it doesn't give me answers. It works perfectly, when I type an entity to get a result or when I use the tab in protege.
But I'm having trouble using the properties and entities together.

Like "propertie some Entity".

I would appreciate your help.

Consider moving primitive (OWLEntity and OWLLiteral) implementations to the model package

It's a pain creating different kinds of entities and literals. For one, a reference to a data factory is needed. The following interfaces:

OWLClass
OWLObjectProperty
OWLDataProperty
OWLAnnotationProperty
OWLNamedIndividual
OWLLiteral

and possibly others, could be turned into abstract classes with static factory methods. (IRI is already like this). So we would then have OWLClass.get(IRI) in client code rather than dataFactory.getOWLClass(IRI) - we don't need a reference to a data factory.

Actual wiring might somehow be done with dependency injection.

Tomcat ThreadLocal memory leak warning

What is the best way to remove the IRI ThreadLocal to avoid memory leaks?

I am receiving the following warnings when I reload a context in Tomcat-7.

May 20, 2013 3:39:08 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/podd] created a ThreadLocal with key of type [org.semanticweb.owlapi.model.IRI$1](value [org.semanticweb.owlapi.model.IRI$1@62a11cb0]) and a value of type [org.semanticweb.owlapi.util.WeakCache](value [org.semanticweb.owlapi.util.WeakCache@3f629966]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
May 20, 2013 3:39:08 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/podd] created a ThreadLocal with key of type [uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryInternalsImpl$1](value [uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryInternalsImpl$1@6245180c]) and a value of type [org.semanticweb.owlapi.util.WeakCache](value [org.semanticweb.owlapi.util.WeakCache@262dee3b]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
May 20, 2013 3:39:08 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/podd] created a ThreadLocal with key of type [org.semanticweb.owlapi.model.IRI$1](value [org.semanticweb.owlapi.model.IRI$1@62a11cb0]) and a value of type [org.semanticweb.owlapi.util.WeakCache](value [org.semanticweb.owlapi.util.WeakCache@11737712]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
May 20, 2013 3:39:08 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/podd] created a ThreadLocal with key of type [org.semanticweb.owlapi.model.IRI$1](value [org.semanticweb.owlapi.model.IRI$1@62a11cb0]) and a value of type [org.semanticweb.owlapi.util.WeakCache](value [org.semanticweb.owlapi.util.WeakCache@338e47b1]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
May 20, 2013 3:39:08 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/podd] created a ThreadLocal with key of type [org.semanticweb.owlapi.model.IRI$1](value [org.semanticweb.owlapi.model.IRI$1@62a11cb0]) and a value of type [org.semanticweb.owlapi.util.WeakCache](value [org.semanticweb.owlapi.util.WeakCache@4204cfe8]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

Consider extension points

We have a kind of axiom that is not OWL proper, i.e., SWRLRule.
There are also a few specs/proposals/recommendations that describe other kind of axioms, e.g., for representation of mathematical equations. Currently these cannot be represented in the OWL API without massive changes, e.g., parsers and visitors.
We might consider a change where there is a generic kind of axiom, ExtensionAxiom or some similar name, which plugs into all general visitors in place of SWRLRule, and allows for an SWRL-agnostic application to implement all visitor interfaces without bothering with unsupported/uninteresting features. At the same time, other tooling would be able to pass around SWRL rules and other kinds of axioms which can be represented within an ontology. Adding other kinds of axioms would then be straightforward and bear little impact on code that does not care, making for a nice separation of scopes.

import closure flags on OWLOntology

Reported by Thomas:

getAxioms()
getAxiomCount()

I think the latter two should come with such a variant too, i.e.:

getAxioms(boolean includeImportsClosure)
getAxiomCount(boolean includeImportsClosure)

That's a feature request now. ;-)

Ignazio: I believe this should be part of a larger reorganization and a paradigm change: imported ontologies should always be included in any search, unless explicitly excluded.

Adding an import does not load the imported ontology

From StackOverflow question

I have an ontology and I use the OWL API to import another ontology,

OWLImportsDeclaration importDeclaraton = Factory.getOWLImportsDeclaration(IRI.create("file:/path/to/ontology.owl"));

ontology.getOWLOntologyManager().applyChange(new AddImport(ontology, importDeclaraton));

The new ontology contain some abox assertions in it, however, when I query the ontology for its abox axioms, there is nothing in it.

System.out.println(ontology.getABoxAxioms(true)); 

returns []

missing method in owlindividual

They class/interface OWLIndividual has the following boolean methods:

  • hasObjectPropertyValue( )
  • hasNegativeObjectPropertyValue( )
  • hasNegativeDataPropertyValue( )

but there is no method named

  • hasDataPropertyValue( )

Pellet uses ManchesterOWLSyntaxEditorParser function that was removed in 3.4.8

Pellet directly uses the parseConstant function from ManchesterOWLSyntaxEditorParser that was removed in 3.4.8 as part of 4725924 The relevant code in Pellet is [1]

It is possible to undo the hiding of this API in a future release, particularly as it was marked as a patch release. (I was under the impression that API removals were prohibited by your policies before version 4. If not, it would be good to start following something like SemVer , as this isn't the only case where the API in 3.4.8 is incompatible with previous 3.4.x releases and previous 3.x releases [2])

[1] https://github.com/clarkparsia/pellet/blob/master/cli/src/pellet/PelletExplain.java#L590
[2] http://semver.org/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.