Examples of OWLOntology


Examples of org.semanticweb.owlapi.model.OWLOntology

public class RelationShorthandTest extends OboFormatTestBasics {

    @Test
    public void testConvert() {
        // PARSE TEST FILE, CONVERT TO OWL, AND WRITE TO OWL FILE
        OWLOntology ontology = convert(parseOBOFile("relation_shorthand_test.obo"));
        // TEST CONTENTS OF OWL ONTOLOGY
        Set<OWLSubClassOfAxiom> scas = ontology
                .getAxioms(AxiomType.SUBCLASS_OF);
        boolean ok = false;
        for (OWLSubClassOfAxiom sca : scas) {
            OWLClassExpression sup = sca.getSuperClass();
            if (sup instanceof OWLObjectSomeValuesFrom) {
                OWLObjectProperty p = (OWLObjectProperty) ((OWLObjectSomeValuesFrom) sup)
                        .getProperty();
                OWLClass v = (OWLClass) ((OWLObjectSomeValuesFrom) sup)
                        .getFiller();
                if (p.getIRI().toString()
                        .equals("http://purl.obolibrary.org/obo/BFO_0000051")
                        && v.getIRI()
                                .toString()
                                .equals("http://purl.obolibrary.org/obo/GO_0004055")) {
                    ok = true;
                }
            }
        }
        assertTrue(ok);
        scas = ontology.getAxioms(AxiomType.SUBCLASS_OF);
        ok = false;
        for (OWLSubClassOfAxiom sca : scas) {
            OWLClassExpression sup = sca.getSuperClass();
            if (sup instanceof OWLObjectSomeValuesFrom) {
                OWLObjectProperty p = (OWLObjectProperty) ((OWLObjectSomeValuesFrom) sup)
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

@SuppressWarnings("javadoc")
public class XPBridgeFileTest extends OboFormatTestBasics {

    @Test
    public void testConvertXPs() {
        OWLOntology owlOnt = convertOBOFile("xptest.obo");
        assertNotNull(owlOnt);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

        return roundTripOBODoc(obodoc, isExpectRoundtrip);
    }

    public List<Diff> roundTripOBODoc(@Nonnull OBODoc obodoc,
            boolean isExpectRoundtrip) throws Exception {
        OWLOntology oo = convert(obodoc);
        OBODoc obodoc2 = convert(oo);
        obodoc2.check();
        writeOBO(obodoc2);
        List<Diff> diffs = OBODocDiffer.getDiffs(obodoc, obodoc2);
        if (isExpectRoundtrip) {
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

        return diffs;
    }

    public boolean roundTripOWLFile(String fn, boolean isExpectRoundtrip)
            throws IOException, OWLOntologyCreationException {
        OWLOntology oo = parseOWLFile(fn);
        return roundTripOWLOOntology(oo, isExpectRoundtrip);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

        OWLAPIOwl2Obo bridge = new OWLAPIOwl2Obo(
                OWLManager.createOWLOntologyManager());
        OBODoc obodoc = bridge.convert(oo);
        writeOBO(obodoc);
        obodoc.check();
        OWLOntology oo2 = convert(obodoc);
        writeOWL(oo2);
        boolean ok = compareOWLOntologiesPartial(oo, oo2, isExpectRoundtrip,
                bridge.getUntranslatableAxioms());
        return ok || !isExpectRoundtrip;
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

    }

    @Test
    public void shouldContainExpectedAnnotation() {
        OBODoc oboFile = parseOBOFile(file);
        OWLOntology o = convert(oboFile);
        IRI expected = IRI
                .create("http://purl.obolibrary.org/obo/GO_0042062%3A");
        assertEquals(18, o.getAnnotationAssertionAxioms(expected).size());
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

    @Test(expected = OWLOntologyRenameException.class)
    public void testRenameToExistingOntology()
            throws OWLOntologyCreationException {
        IRI ontologyAIRI = IRI("http://www.semanticweb.org/ontologies/ontologyA");
        OWLOntology onto = m.createOntology(ontologyAIRI);
        m.addAxiom(onto,
                df.getOWLDeclarationAxiom(Class(IRI("urn:test:testclass"))));
        IRI ontologyBIRI = IRI("http://www.semanticweb.org/ontologies/ontologyB");
        OWLOntology ontologyB = m.createOntology(ontologyBIRI);
        m.applyChange(new SetOntologyID(ontologyB, new OWLOntologyID(
                of(ontologyAIRI), absent())));
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

        // it is expected that only one implementation of
        // OWLOntologyManagerFactory will be available, but if there is more
        // than one, no harm done
        try {
            for (OWLOntologyManagerFactory f : ontologyManagerFactories) {
                OWLOntology ontology = f.get()
                        .loadOntologyFromOntologyDocument(source);
                new RioRenderer(ontology, getRDFHandler(), getRDFFormat()
                        .getOWLFormat()).render();
                return;
            }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

    @Test
    public void testrun() throws Exception {
        OWLOntologyManager m = OWLManager.createOWLOntologyManager();
        m.getIRIMappers().add(new AutoIRIMapper(new File("."), false));
        OWLOntology o = m.loadOntologyFromOntologyDocument(getClass()
                .getResourceAsStream("/pizza.owl"));
        m.addAxiom(o, DF.getOWLDeclarationAxiom(DF.getOWLClass(iri)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLClass(string, prefixmanager)));
        m.addAxiom(o, DF.getOWLEquivalentClassesAxiom(DF.getOWLClass(iri), c));
        m.addAxiom(o, DF.getOWLDisjointClassesAxiom(DF.getOWLClass(iri), c));
        m.addAxiom(o, DF.getOWLSubObjectPropertyOfAxiom(op, op));
        m.addAxiom(o, DF.getOWLSubPropertyChainOfAxiom(
                listowlobjectpropertyexpression, op));
        m.addAxiom(o, DF.getOWLEquivalentObjectPropertiesAxiom(setop));
        m.addAxiom(o, DF.getOWLDisjointObjectPropertiesAxiom(setop));
        m.addAxiom(o, DF.getOWLInverseObjectPropertiesAxiom(op, op));
        m.addAxiom(o, DF.getOWLObjectPropertyDomainAxiom(op, c));
        m.addAxiom(o, DF.getOWLObjectPropertyRangeAxiom(op, c));
        m.addAxiom(o, DF.getOWLFunctionalObjectPropertyAxiom(op));
        m.addAxiom(o,
                DF.getOWLAnnotationAssertionAxiom(ap, as, owlannotationvalue));
        m.applyChange(new AddImport(o, DF.getOWLImportsDeclaration(iri)));
        m.addAxiom(o, DF.getOWLAnnotationPropertyDomainAxiom(ap, iri));
        m.addAxiom(o, DF.getOWLAnnotationPropertyRangeAxiom(ap, iri));
        m.addAxiom(o, DF.getOWLSubAnnotationPropertyOfAxiom(ap, ap));
        m.addAxiom(o, DF.getOWLInverseFunctionalObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLReflexiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLIrreflexiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLSymmetricObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLAsymmetricObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLTransitiveObjectPropertyAxiom(op));
        m.addAxiom(o, DF.getOWLSubDataPropertyOfAxiom(dp, dp));
        m.addAxiom(o, DF.getOWLEquivalentDataPropertiesAxiom(setdp));
        m.addAxiom(o, DF.getOWLDisjointDataPropertiesAxiom(setdp));
        m.addAxiom(o, DF.getOWLDataPropertyDomainAxiom(dp, c));
        m.addAxiom(o, DF.getOWLDataPropertyRangeAxiom(dp, dr));
        m.addAxiom(o, DF.getOWLFunctionalDataPropertyAxiom(dp));
        m.addAxiom(o, DF.getOWLHasKeyAxiom(c, setowlpropertyexpression));
        m.addAxiom(o, DF.getOWLDatatypeDefinitionAxiom(owldatatype, dr));
        m.addAxiom(o, DF.getOWLSameIndividualAxiom(setowlindividual));
        m.addAxiom(o, DF.getOWLDifferentIndividualsAxiom(setowlindividual));
        m.addAxiom(o, DF.getOWLClassAssertionAxiom(c, ai));
        m.addAxiom(o, DF.getOWLObjectPropertyAssertionAxiom(op, ai, ai));
        m.addAxiom(o, DF.getOWLNegativeObjectPropertyAssertionAxiom(op, ai, ai));
        m.addAxiom(o, DF.getOWLDataPropertyAssertionAxiom(dp, ai, owlliteral));
        m.addAxiom(o,
                DF.getOWLNegativeDataPropertyAssertionAxiom(dp, ai, owlliteral));
        m.addAxiom(
                o,
                DF.getOWLInverseObjectPropertiesAxiom(op,
                        DF.getOWLObjectInverseOf(op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLDataExactCardinality(1, dp)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataMaxCardinality(1, dp)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataMinCardinality(1, dp)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectExactCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectMaxCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectMinCardinality(1, op)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDatatype(string, prefixmanager)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyAssertionAxiom(dp, ai,
                        DF.getOWLLiteral(string, owldatatype)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDataOneOf(owlliteral)));
        m.addAxiom(o,
                DF.getOWLDataPropertyRangeAxiom(dp, DF.getOWLDataUnionOf(dr)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(dp,
                        DF.getOWLDataIntersectionOf(dr)));
        m.addAxiom(o,
                DF.getOWLDataPropertyRangeAxiom(dp, DF
                        .getOWLDatatypeRestriction(owldatatype, owlfacet,
                                owlliteral)));
        m.addAxiom(
                o,
                DF.getOWLDataPropertyRangeAxiom(
                        dp,
                        DF.getOWLDatatypeRestriction(owldatatype,
                                DF.getOWLFacetRestriction(owlfacet, 1))));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(
                        c,
                        DF.getOWLObjectIntersectionOf(c,
                                DF.getOWLClass(string, prefixmanager))));
        m.addAxiom(o, DF.getOWLSubClassOfAxiom(c,
                DF.getOWLDataSomeValuesFrom(dp, dr)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLDataAllValuesFrom(dp, dr)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLDataHasValue(dp, owlliteral)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectComplementOf(DF.getOWLClass(iri))));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectOneOf(DF.getOWLNamedIndividual(iri))));
        m.addAxiom(o, DF.getOWLSubClassOfAxiom(c,
                DF.getOWLObjectAllValuesFrom(op, c)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectSomeValuesFrom(op, c)));
        m.addAxiom(o,
                DF.getOWLSubClassOfAxiom(c, DF.getOWLObjectHasValue(op, ai)));
        m.addAxiom(
                o,
                DF.getOWLSubClassOfAxiom(c,
                        DF.getOWLObjectUnionOf(DF.getOWLClass(iri))));
        m.addAxiom(
                o,
                DF.getOWLAnnotationAssertionAxiom(iri,
                        DF.getOWLAnnotation(ap, owlannotationvalue)));
        m.addAxiom(o, DF.getOWLAnnotationAssertionAxiom(DF
                .getOWLNamedIndividual(iri).getIRI(), DF.getOWLAnnotation(ap,
                owlannotationvalue)));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream stream = new ObjectOutputStream(out);
        stream.writeObject(m);
        stream.flush();
        // System.out.println(out.toString());
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        ObjectInputStream inStream = new ObjectInputStream(in);
        OWLOntologyManager copy = (OWLOntologyManager) inStream.readObject();
        for (OWLOntology onto : copy.getOntologies()) {
            OWLOntology original = m.getOntology(onto.getOntologyID()
                    .getOntologyIRI().get());
            assertEquals("Troubles with ontology " + onto.getOntologyID(),
                    original.getAxioms(), onto.getAxioms());
        }
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLOntology

    }

    /** @return current ontology from walker */
    @Nonnull
    public OWLOntology getCurrentOntology() {
        OWLOntology ontology = walker.getOntology();
        if (ontology == null) {
            throw new OWLRuntimeException(
                    "No current ontology; is the walker being used outside of an ontology visit?");
        }
        return ontology;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.