Package org.obolibrary.obo2owl

Source Code of org.obolibrary.obo2owl.LoadAnonymousTestCase

package org.obolibrary.obo2owl;

import static org.junit.Assert.assertEquals;
import static org.semanticweb.owlapi.apibinding.OWLFunctionalSyntaxFactory.*;
import static org.semanticweb.owlapi.vocab.OWL2Datatype.XSD_STRING;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import org.junit.Test;
import org.semanticweb.owlapi.api.test.baseclasses.TestBase;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.StringDocumentSource;
import org.semanticweb.owlapi.model.MissingImportHandlingStrategy;
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration;
import org.semanticweb.owlapi.model.OWLOntologyManager;

@SuppressWarnings("javadoc")
public class LoadAnonymousTestCase extends TestBase {

    @Test
    public void shouldLoad() throws OWLOntologyCreationException {
        OWLOntologyManager rootOntologyManager = OWLManager
                .createOWLOntologyManager();
        String input = "format-version: 1.2\n"
                + "date: 27:06:2013 17:08\n"
                + "saved-by: gkoutos\n"
                + "auto-generated-by: OBO-Edit 2.3\n"
                + "subsetdef: abnormal_slim \"Abnormal/normal slim\"\n"
                + "subsetdef: absent_slim \"Absent/present slim\"\n"
                + "subsetdef: attribute_slim \"Attribute slim\"\n"
                + "subsetdef: cell_quality \"cell_quality\"\n"
                + "subsetdef: disposition_slim \"Disposition slim\"\n"
                + "subsetdef: mpath_slim \"Pathology slim\"\n"
                + "subsetdef: prefix_slim \"prefix slim\"\n"
                + "subsetdef: relational_slim \"Relational slim: types of quality that require an additional entity in order to exist\"\n"
                + "subsetdef: scalar_slim \"Scalar slim\"\n"
                + "subsetdef: unit_group_slim \"unit group slim\"\n"
                + "subsetdef: unit_slim \"unit slim\"\n"
                + "subsetdef: value_slim \"Value slim\"\n"
                + "default-namespace: quality\n"
                + "namespace-id-rule: * UO:$sequence(7,0,9999999)$\n"
                + "remark: Filtered by Ancestor ID equals \"UO:0000000\"\n"
                + "ontology: uo\n"
                + "ontology: pato\n"
                + "ontology: pato\n"
                + "ontology: pato\n"
                + '\n'
                + "[Term]\n"
                + "id: UO:0000000\n"
                + "name: unit\n"
                + "namespace: unit.ontology\n"
                + "def: \"A unit of measurement is a standardized quantity of a physical quality.\" [Wikipedia:Wikipedia]\n"
                + "created_by: george gkoutos\n"
                + '\n'
                + "[Term]\n"
                + "id: UO:0000001\n"
                + "name: length unit\n"
                + "namespace: unit.ontology\n"
                + "def: \"A unit which is a standard measure of the distance between two points.\" [Wikipedia:Wikipedia]\n"
                + "subset: unit_group_slim\n" + "is_a: UO:0000000 ! unit\n"
                + "relationship: is_unit_of PATO:0001708 ! 1-D extent\n"
                + "created_by: george gkoutos";
        StringDocumentSource streamDocumentSource = new StringDocumentSource(
                input);
        OWLOntologyLoaderConfiguration loaderConfig = new OWLOntologyLoaderConfiguration()
                .setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT);
        OWLOntology ontology = rootOntologyManager
                .loadOntologyFromOntologyDocument(streamDocumentSource,
                        loaderConfig);
        OWLAnnotationProperty date = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#date"));
        OWLAnnotationProperty mpathSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#mpath_slim"));
        OWLAnnotationProperty subsetProperty = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#SubsetProperty"));
        OWLAnnotationProperty attributeSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#attribute_slim"));
        OWLAnnotationProperty hasOBONamespace = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#hasOBONamespace"));
        OWLAnnotationProperty autogeneratedby = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#auto-generated-by"));
        OWLAnnotationProperty hasDbXref = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
        OWLAnnotationProperty defaultnamespace = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#default-namespace"));
        OWLAnnotationProperty hasOBOFormatVersion = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#hasOBOFormatVersion"));
        OWLAnnotationProperty iao0000115 = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/IAO_0000115"));
        OWLAnnotationProperty namespaceIdRule = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#NamespaceIdRule"));
        OWLAnnotationProperty createdBy = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#created_by"));
        OWLAnnotationProperty inSubset = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#inSubset"));
        OWLAnnotationProperty savedby = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#saved-by"));
        OWLClass pato0001708 = Class(IRI("http://purl.obolibrary.org/obo/PATO_0001708"));
        OWLClass uo0 = Class(IRI("http://purl.obolibrary.org/obo/UO_0000000"));
        OWLClass uo1 = Class(IRI("http://purl.obolibrary.org/obo/UO_0000001"));
        OWLAnnotationProperty id = AnnotationProperty(IRI("http://www.geneontology.org/formats/oboInOwl#id"));
        OWLAnnotationProperty abnormalSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#abnormal_slim"));
        OWLAnnotationProperty scalarSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#scalar_slim"));
        OWLLiteral literal = Literal("Wikipedia:Wikipedia", XSD_STRING);
        OWLAnnotationProperty unitSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#unit_slim"));
        OWLAnnotationProperty absentSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#absent_slim"));
        OWLObjectProperty isUnitOf = ObjectProperty(IRI("http://purl.obolibrary.org/obo/uo#is_unit_of"));
        OWLAnnotationProperty cellQuality = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#cell_quality"));
        OWLAnnotationProperty unitGroupSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#unit_group_slim"));
        OWLAnnotationProperty valueSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#value_slim"));
        OWLAnnotationProperty prefixSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#prefix_slim"));
        OWLAnnotationProperty dispositionSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#disposition_slim"));
        OWLAnnotationProperty relationalSlim = AnnotationProperty(IRI("http://purl.obolibrary.org/obo/uo#relational_slim"));
        Set<OWLAxiom> expected = new HashSet<>(
                Arrays.asList(
                        Declaration(date),
                        Declaration(autogeneratedby),
                        Declaration(hasDbXref),
                        Declaration(defaultnamespace),
                        Declaration(subsetProperty),
                        Declaration(hasOBOFormatVersion),
                        Declaration(iao0000115),
                        Declaration(namespaceIdRule),
                        Declaration(createdBy),
                        Declaration(inSubset),
                        Declaration(savedby),
                        Declaration(pato0001708),
                        Declaration(uo0),
                        Declaration(RDFSComment()),
                        Declaration(RDFSLabel()),
                        Declaration(hasOBONamespace),
                        Declaration(uo1),
                        Declaration(id),
                        SubAnnotationPropertyOf(mpathSlim, subsetProperty),
                        AnnotationAssertion(hasOBONamespace, uo1.getIRI(),
                                Literal("unit.ontology", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(),
                                attributeSlim.getIRI(),
                                Literal("Attribute slim", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(), iao0000115.getIRI(),
                                Literal("definition", XSD_STRING)),
                        AnnotationAssertion(hasOBONamespace, uo0.getIRI(),
                                Literal("unit.ontology", XSD_STRING)),
                        SubAnnotationPropertyOf(unitSlim, subsetProperty),
                        AnnotationAssertion(RDFSComment(), valueSlim.getIRI(),
                                Literal("Value slim", XSD_STRING)),
                        SubAnnotationPropertyOf(absentSlim, subsetProperty),
                        SubAnnotationPropertyOf(abnormalSlim, subsetProperty),
                        AnnotationAssertion(RDFSLabel(), uo1.getIRI(),
                                Literal("length unit", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(),
                                hasOBOFormatVersion.getIRI(),
                                Literal("has_obo_format_version", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(),
                                namespaceIdRule.getIRI(),
                                Literal("namespace-id-rule", XSD_STRING)),
                        SubClassOf(uo1,
                                ObjectSomeValuesFrom(isUnitOf, pato0001708)),
                        SubAnnotationPropertyOf(cellQuality, subsetProperty),
                        AnnotationAssertion(
                                RDFSComment(),
                                relationalSlim.getIRI(),
                                Literal("Relational slim: types of quality that require an additional entity in order to exist",
                                        XSD_STRING)),
                        SubAnnotationPropertyOf(prefixSlim, subsetProperty),
                        SubAnnotationPropertyOf(scalarSlim, subsetProperty),
                        AnnotationAssertion(RDFSComment(), scalarSlim.getIRI(),
                                Literal("Scalar slim", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(),
                                abnormalSlim.getIRI(),
                                Literal("Abnormal/normal slim", XSD_STRING)),
                        SubAnnotationPropertyOf(attributeSlim, subsetProperty),
                        AnnotationAssertion(RDFSLabel(), uo0.getIRI(),
                                Literal("unit", XSD_STRING)),
                        SubAnnotationPropertyOf(dispositionSlim, subsetProperty),
                        AnnotationAssertion(RDFSComment(), unitSlim.getIRI(),
                                Literal("unit slim", XSD_STRING)),
                        SubAnnotationPropertyOf(relationalSlim, subsetProperty),
                        AnnotationAssertion(id, uo1.getIRI(),
                                Literal("UO:0000001", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(), mpathSlim.getIRI(),
                                Literal("Pathology slim", XSD_STRING)),
                        AnnotationAssertion(createdBy, uo1.getIRI(),
                                Literal("george gkoutos", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(), hasDbXref.getIRI(),
                                Literal("database_cross_reference", XSD_STRING)),
                        SubClassOf(uo1, uo0),
                        AnnotationAssertion(RDFSLabel(),
                                hasOBONamespace.getIRI(),
                                Literal("has_obo_namespace", XSD_STRING)),
                        AnnotationAssertion(id, uo0.getIRI(),
                                Literal("UO:0000000", XSD_STRING)),
                        AnnotationAssertion(createdBy, uo0.getIRI(),
                                Literal("george gkoutos", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(), prefixSlim.getIRI(),
                                Literal("prefix slim", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(),
                                cellQuality.getIRI(),
                                Literal("cell_quality", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(), absentSlim.getIRI(),
                                Literal("Absent/present slim", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(),
                                subsetProperty.getIRI(),
                                Literal("subset_property", XSD_STRING)),
                        SubAnnotationPropertyOf(unitGroupSlim, subsetProperty),
                        AnnotationAssertion(RDFSComment(),
                                unitGroupSlim.getIRI(),
                                Literal("unit group slim", XSD_STRING)),
                        AnnotationAssertion(RDFSComment(),
                                dispositionSlim.getIRI(),
                                Literal("Disposition slim", XSD_STRING)),
                        AnnotationAssertion(RDFSLabel(), inSubset.getIRI(),
                                Literal("in_subset", XSD_STRING)),
                        SubAnnotationPropertyOf(valueSlim, subsetProperty),
                        AnnotationAssertion(inSubset, uo1.getIRI(),
                                unitGroupSlim.getIRI()),
                        df.getOWLAnnotationAssertionAxiom(
                                iao0000115,
                                uo0.getIRI(),
                                Literal("A unit of measurement is a standardized quantity of a physical quality.",
                                        XSD_STRING),
                                singleton(Annotation(hasDbXref, literal))),
                        df.getOWLAnnotationAssertionAxiom(
                                iao0000115,
                                uo1.getIRI(),
                                Literal("A unit which is a standard measure of the distance between two points.",
                                        XSD_STRING),
                                singleton(Annotation(hasDbXref, literal)))));
        assertEquals(expected, ontology.getAxioms());
    }
}
TOP

Related Classes of org.obolibrary.obo2owl.LoadAnonymousTestCase

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.