org.semanticweb.owlapi.model.parameters.Imports Java Examples

The following examples show how to use org.semanticweb.owlapi.model.parameters.Imports. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 
 * returns set of entities that belong to a referenced ontology that are referenced in the source ontology.
 * 
 * If the source ontology is not explicitly declared, then all entities that are referenced in the source
 * ontology and declared in a reference ontology are returned.
 * 
 * Example: if the source ontology is cl, and cl contains axioms that reference go:1, go:2, ...
 * and go is in the set of referenced ontologies, then {go:1,go:2,...} will be in the returned set.
 * It is irrelevant whether go:1, ... is declared in the source (e.g. MIREOTed)
 * 
 * Note this only returns direct references. See
 * {@link #getClosureOfExternalReferencedEntities()} for closure of references
 * 
 * @return all objects referenced by source ontology
 */
public Set<OWLEntity> getExternalReferencedEntities() {
	OWLOntology ont = graph.getSourceOntology();
	Set<OWLEntity> objs = ont.getSignature(Imports.EXCLUDED);
	Set<OWLEntity> refObjs = new HashSet<OWLEntity>();
	LOG.info("testing "+objs.size()+" objs to see if they are contained in: "+getReferencedOntologies());
	for (OWLEntity obj : objs) {
		//LOG.info("considering: "+obj);
		// a reference ontology may have entities from the source ontology MIREOTed in..
		// allow a configuration with the URI prefix specified
		if (isInExternalOntology(obj)) {
			refObjs.add(obj);

		}
	}
	LOG.info("#refObjs: "+refObjs.size());

	return refObjs;
}
 
Example #2
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Set<DataProperty> getAllClassDataProperties(IRI iri) {
    org.semanticweb.owlapi.model.IRI classIRI = SimpleOntologyValues.owlapiIRI(iri);
    if (owlOntology.containsClassInSignature(classIRI)) {
        OWLClass owlClass = owlManager.getOWLDataFactory().getOWLClass(classIRI);
        Node<OWLClass> equivalentClasses = owlReasoner.getEquivalentClasses(owlClass);
        NodeSet<OWLClass> superClasses = owlReasoner.getSuperClasses(owlClass);
        return owlOntology.dataPropertiesInSignature(Imports.INCLUDED)
                .filter(property -> {
                    Set<OWLDataPropertyDomainAxiom> domains = owlOntology.axioms(OWLDataPropertyDomainAxiom.class,
                            OWLDataPropertyExpression.class, property, Imports.INCLUDED,
                            Navigation.IN_SUB_POSITION).collect(Collectors.toSet());
                    return hasClassAsDomain(domains.stream(), classIRI, equivalentClasses, superClasses)
                            || hasNoDomain(domains.stream());
                })
                .map(SimpleOntologyValues::mobiDataProperty)
                .collect(Collectors.toSet());
    }
    throw new IllegalArgumentException("Class not found in ontology");
}
 
Example #3
Source File: OboOntologyReleaseRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private boolean isBridgingOntology(OWLOntology ont) {
	for (OWLClass c : ont.getClassesInSignature(Imports.INCLUDED)) {

		if (ont.getDeclarationAxioms(c).size() > 0) {
			if (mooncat.getOntology().getDeclarationAxioms(c).size() >0) {
				// class already declared in main ontology - a 2ary ontology MUST
				// declare at least one of its own classes if it is a bone-fide non-bridging ontology
			}
			else if (mooncat.isDangling(ont, c)) {
				// a dangling class has no OWL annotations.
				// E.g. bp_xp_cl contains CL classes as dangling
			}
			else {
				logInfo(c+" has declaration axioms, is not in main, and is not dangling, therefore "+ont+" is NOT a bridging ontology");
				return false;
			}
		}
	}
	logInfo(ont+" is a bridging ontology");
	return true;
}
 
Example #4
Source File: TableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphWrapper g) {
	
	if (isWriteHeader) {
		print("IRI");
		sep();
		print("label");
		sep();
		print("definition");
		nl();
	}
	graph = g;
	
	Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
	objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));

	for (OWLObject obj : objs) {
		if (obj.equals(g.getDataFactory().getOWLNothing()))
			continue;
		if (obj.equals(g.getDataFactory().getOWLThing()))
			continue;
		if (obj instanceof OWLNamedObject)
			render((OWLNamedObject)obj);
	}
	stream.close();
}
 
Example #5
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Set<IRI> getSubPropertiesFor(IRI iri) {
    long start = getStartTime();
    try {
        org.semanticweb.owlapi.model.IRI owlapiIRI = SimpleOntologyValues.owlapiIRI(iri);
        if (owlOntology.containsDataPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLDataProperty owlDataProperty = owlManager.getOWLDataFactory().getOWLDataProperty(owlapiIRI);
            return getSubDatatypePropertiesFor(owlDataProperty, false).collect(Collectors.toSet());
        } else if (owlOntology.containsObjectPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLObjectProperty owlObjectProperty = owlManager.getOWLDataFactory().getOWLObjectProperty(owlapiIRI);
            return getSubObjectPropertiesFor(owlObjectProperty, false).collect(Collectors.toSet());
        } else if (owlOntology.containsAnnotationPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLAnnotationProperty owlAnnotationProperty = owlManager.getOWLDataFactory()
                    .getOWLAnnotationProperty(owlapiIRI);
            return getSubAnnotationPropertiesFor(owlAnnotationProperty, false).collect(Collectors.toSet());
        } else {
            return Collections.emptySet();
        }
    } finally {
        logTrace("getSubPropertiesFor(IRI)", start);
    }
}
 
Example #6
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Hierarchy getSubDatatypePropertiesOf(ValueFactory vf, ModelFactory mf) {
    long start = getStartTime();
    try {
        Hierarchy hierarchy = new Hierarchy(vf, mf);
        Set<OWLDataProperty> properties = getDeclaredDatatypeProperties(Imports.INCLUDED)
                .collect(Collectors.toSet());
        threadPool.submit(() -> properties.parallelStream()
                .forEach(property -> {
                    IRI propIRI = SimpleOntologyValues.mobiIRI(property.getIRI());
                    hierarchy.addIRI(propIRI);
                    getSubDatatypePropertiesFor(property, true)
                            .forEach(subpropIRI -> hierarchy.addParentChild(propIRI, subpropIRI));
                })).get();
        return hierarchy;
    } catch (InterruptedException | ExecutionException e) {
        throw new MobiOntologyException("Error retrieving getSubDatatypePropertiesOf", e);
    } finally {
        logTrace("getSubDatatypePropertiesOf()", start);
    }
}
 
Example #7
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Hierarchy getSubClassesOf(ValueFactory vf, ModelFactory mf) {
    long start = getStartTime();
    try {
        Hierarchy hierarchy = new Hierarchy(vf, mf);
        Set<OWLClass> classes = getDeclaredClasses(Imports.INCLUDED).collect(Collectors.toSet());
        threadPool.submit(() -> classes.parallelStream()
                .forEach(owlClass -> {
                    if (owlClass.isTopEntity()) {
                        return;
                    }
                    IRI classIRI = SimpleOntologyValues.mobiIRI(owlClass.getIRI());
                    hierarchy.addIRI(classIRI);
                    getSubClassesFor(owlClass, true)
                            .forEach(subclassIRI -> hierarchy.addParentChild(classIRI, subclassIRI));
                })).get();
        return hierarchy;
    } catch (InterruptedException | ExecutionException e) {
        throw new MobiOntologyException("Error retrieving getSubClassesOf", e);
    } finally {
        logTrace("getSubClassesOf()", start);
    }
}
 
Example #8
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Hierarchy getSubAnnotationPropertiesOf(ValueFactory vf, ModelFactory mf) {
    long start = getStartTime();
    try {
        Hierarchy hierarchy = new Hierarchy(vf, mf);
        Set<OWLAnnotationProperty> properties = getDeclaredAnnotationProperties(Imports.INCLUDED)
                .collect(Collectors.toSet());
        threadPool.submit(() -> properties.parallelStream()
                .forEach(property -> {
                    if (property.isBuiltIn()) {
                        return;
                    }
                    IRI propIRI = SimpleOntologyValues.mobiIRI(property.getIRI());
                    hierarchy.addIRI(propIRI);
                    getSubAnnotationPropertiesFor(property, true)
                            .forEach(subpropIRI -> hierarchy.addParentChild(propIRI, subpropIRI));
                })).get();
        return hierarchy;
    } catch (InterruptedException | ExecutionException e) {
        throw new MobiOntologyException("Error retrieving subAnnotationPropertiesOf", e);
    } finally {
        logTrace("getSubAnnotationPropertiesOf()", start);
    }
}
 
Example #9
Source File: EdgeTableRenderer.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void render(OWLGraphWrapper g) {
	graph = g;
	
	Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
	objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));

	for (OWLObject obj : objs) {
		if (obj.equals(g.getDataFactory().getOWLNothing()))
			continue;
		if (obj.equals(g.getDataFactory().getOWLThing()))
			continue;
		if (obj instanceof OWLNamedObject)
			render((OWLNamedObject)obj);
	}
	stream.close();
}
 
Example #10
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Hierarchy getClassesWithIndividuals(ValueFactory vf, ModelFactory mf) {
    long start = getStartTime();
    try {
        Hierarchy hierarchy = new Hierarchy(vf, mf);
        Set<OWLClass> classes = getDeclaredClasses(Imports.INCLUDED).collect(Collectors.toSet());
        threadPool.submit(() -> classes.parallelStream()
                .forEach(owlClass -> {
                    Set<IRI> iris = owlReasoner.instances(owlClass, true)
                            .map(individual -> SimpleOntologyValues.mobiIRI(individual.getIRI()))
                            .collect(Collectors.toSet());
                    if (iris.size() > 0) {
                        IRI classIRI = SimpleOntologyValues.mobiIRI(owlClass.getIRI());
                        iris.forEach(iri -> hierarchy.addParentChild(classIRI, iri));
                    }
                })).get();
        return hierarchy;
    } catch (InterruptedException | ExecutionException e) {
        throw new MobiOntologyException("Error retrieving getClassesWithIndividuals", e);
    } finally {
        logTrace("getClassesWithIndividuals()", start);
    }
}
 
Example #11
Source File: QueryEngineImpl.java    From sparql-dl-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * QueryEngineImpl constructor
 *
 * @param manager    An OWLOntologyManager instance of OWLAPI v3
 * @param reasoner   An OWLReasoner instance.
 * @param strictMode If strict mode is enabled the query engine will throw a QueryEngineException if data types withing the query are not correct (e.g. Class(URI_OF_AN_INDIVIDUAL))
 */
public QueryEngineImpl(OWLOntologyManager manager, OWLReasoner reasoner, boolean strictMode) {
    this.manager = manager;
    this.reasoner = reasoner;
    this.factory = manager.getOWLDataFactory();
    this.strictMode = strictMode;
    reasoner.getRootOntology()
            .getAxioms(AxiomType.ANNOTATION_ASSERTION, Imports.INCLUDED)
            .stream()
            .filter(ax -> ax.getSubject() instanceof IRI)
            .forEach(ax -> {
                unannotatedAxioms.add(ax.getAxiomWithoutAnnotations());
                annotationAssertionsBySubject.put((IRI) ax.getSubject(), ax);
            });
    Set<OWLClass> classesInSignature = reasoner.getRootOntology().getClassesInSignature(Imports.INCLUDED);
    classesInSignature.add(factory.getOWLThing());
    classesInSignature.add(factory.getOWLNothing());
    classes = ImmutableSet.copyOf(classesInSignature);
    classIris = ImmutableSet.copyOf(classes.stream().map(OWLClass::getIRI).collect(toSet()));

    annotationPropertyIris = ImmutableSet.copyOf(reasoner.getRootOntology().getAnnotationPropertiesInSignature(Imports.INCLUDED).stream().map(
            OWLNamedObject::getIRI).collect(toSet()));
}
 
Example #12
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Set<ObjectProperty> getAllClassObjectProperties(IRI iri) {
    org.semanticweb.owlapi.model.IRI classIRI = SimpleOntologyValues.owlapiIRI(iri);
    if (owlOntology.containsClassInSignature(classIRI)) {
        OWLClass owlClass = owlManager.getOWLDataFactory().getOWLClass(classIRI);
        Node<OWLClass> equivalentClasses = owlReasoner.getEquivalentClasses(owlClass);
        NodeSet<OWLClass> superClasses = owlReasoner.getSuperClasses(owlClass);
        return owlOntology.objectPropertiesInSignature(Imports.INCLUDED)
                .filter(property -> {
                    Set<OWLObjectPropertyDomainAxiom> domains = owlOntology.axioms(
                            OWLObjectPropertyDomainAxiom.class, OWLObjectPropertyExpression.class, property,
                            Imports.INCLUDED, Navigation.IN_SUB_POSITION).collect(Collectors.toSet());
                    return hasClassAsDomain(domains.stream(), classIRI, equivalentClasses, superClasses)
                            || hasNoDomain(domains.stream());
                })
                .map(SimpleOntologyValues::mobiObjectProperty)
                .collect(Collectors.toSet());
    }
    throw new IllegalArgumentException("Class not found in ontology");
}
 
Example #13
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Params: id
 * @throws OWLOntologyCreationException
 * @throws OWLOntologyStorageException
 * @throws IOException
 * @throws OWLParserException
 */
public void getAxiomsCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException, OWLParserException {
	headerOWL();
	boolean direct = getParamAsBoolean(Param.direct, false);
	OWLObject obj = this.resolveEntity();
	LOG.info("finding axioms about: "+obj);
	Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
	if (obj instanceof OWLClass) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLClass)obj, Imports.EXCLUDED));
	}
	if (obj instanceof OWLIndividual) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLIndividual)obj, Imports.EXCLUDED));
	}
	if (obj instanceof OWLObjectProperty) {
		axioms.addAll(graph.getSourceOntology().getAxioms((OWLObjectProperty)obj, Imports.EXCLUDED));
	}

	for (OWLAxiom ax : axioms) {
		output(ax);
	}
}
 
Example #14
Source File: AbstractConverter.java    From OWL2VOWL with MIT License 6 votes vote down vote up
private void processAnnotationProperties(OWLOntology ontology, VowlData vowlData) {
	for (OWLAnnotationProperty owlAnnotationProperty : ontology.annotationPropertiesInSignature(Imports.INCLUDED)
			.collect(Collectors.toSet())) {
		for (OWLAnnotationAxiom owlAnnotationAxiom : ontology.axioms(owlAnnotationProperty, Imports.INCLUDED)
				.collect(Collectors.toSet())) {
			try {
				String subject = owlAnnotationProperty.getIRI().toString();
				String property = "http://visualdataweb.org/ontologies/gizmo-core#assertionDatatypeValue";
				OWLAnnotationPropertyRangeAxiom ra = (OWLAnnotationPropertyRangeAxiom) owlAnnotationAxiom;
				String value = ra.getRange().toString();
				vowlData.addBaseConstructorAnnotation(subject, property, value);
			} catch (Exception e) {
				// not interesting
			}
		}
	}
}
 
Example #15
Source File: OntologyHelper.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Given an ontology and a set of IRIs, filter the set of IRIs to only include those that exist in
 * the ontology. Maybe include terms in imports.
 *
 * @param ontology the ontology to check for IRIs
 * @param IRIs Set of IRIs to filter
 * @param allowEmpty boolean specifying if an empty set can be returned
 * @param imports Imports INCLUDED or EXCLUDED
 * @return Set of filtered IRIs
 */
public static Set<IRI> filterExistingTerms(
    OWLOntology ontology, Set<IRI> IRIs, boolean allowEmpty, Imports imports) {
  Set<IRI> missingIRIs = new HashSet<>();
  for (IRI iri : IRIs) {
    if (!ontology.containsEntityInSignature(iri, imports)) {
      logger.warn("Ontology does not contain {}", iri.toQuotedString());
      missingIRIs.add(iri);
    }
  }

  if (missingIRIs.containsAll(IRIs) && !allowEmpty) {
    throw new IllegalArgumentException(emptyTermsError);
  }
  return IRIs;
}
 
Example #16
Source File: NCBI2OWLTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void testExactSynonym(OWLOntology ontology) {
	IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
	OWLDataFactory df = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
	assertTrue("Exact Synonym property in signature",
		ontology.containsAnnotationPropertyInSignature(iri));
	
	// Check axioms
	Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
	assertEquals("Count class axioms", 0, axioms.size());

	// Check annotations
	List<String> values = new ArrayList<String>();
	values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");

	Set<OWLAnnotationAssertionAxiom> annotations = 
		ontology.getAnnotationAssertionAxioms(iri);
	assertEquals("Count annotations for Exact", 1, annotations.size());

	checkAnnotations(annotations, values);
}
 
Example #17
Source File: EquivalentClassReasoning.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * This is how we define the failure behavior given a Reasoning Mode.
 *
 * @param mode one of the enum instances that define how reasoning behavior should be over
 *     equivalent axioms
 * @param ontology Ontology to reason over
 * @return The EquivalentAxiomReasoningTest instance with the implementation of how to detect a
 *     failing Equivalence Axiom
 */
private static EquivalentAxiomReasoningTest createTest(
    EquivalentClassReasoningMode mode, OWLOntology ontology) {
  EquivalentAxiomReasoningTest test = null;
  switch (mode) {
    case ALL:
      test = axiom -> false;
      break;
    case NONE:
      test = axiom -> true;
      break;
    case ASSERTED_ONLY:
      test =
          axiom ->
              !ontology.containsAxiom(
                  axiom, Imports.INCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS);
      break;
  }
  return test;
}
 
Example #18
Source File: InvalidReferenceChecker.java    From robot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Checks if entity is dangling.
 *
 * @param ontology the OWLOntology to check
 * @param entity the OWLEntity to check
 * @return true if owlClass has no logical or non-logical axioms
 */
public static boolean isDangling(OWLOntology ontology, OWLEntity entity) {
  if (entity instanceof OWLClass) {
    OWLClass owlClass = (OWLClass) entity;
    // Ignore OWLThing and OWLNothing
    // Not dangling if there are axioms about the class
    if (owlClass.isOWLThing()
        || owlClass.isOWLNothing()
        || ontology.getAxioms(owlClass, Imports.INCLUDED).size() > 0) return false;
    return ontology.getAnnotationAssertionAxioms(owlClass.getIRI()).size() <= 0;
  }
  if (entity instanceof OWLObjectProperty) {
    OWLObjectProperty owlProperty = (OWLObjectProperty) entity;
    // Ignore top and bottom properties
    // Not dangling if there are axioms about the property
    if (owlProperty.isOWLBottomDataProperty()
        || owlProperty.isOWLTopDataProperty()
        || owlProperty.isOWLBottomObjectProperty()
        || owlProperty.isOWLTopObjectProperty()
        || ontology.getAxioms(owlProperty, Imports.INCLUDED).size() > 0) return false;
    return ontology.getAnnotationAssertionAxioms(owlProperty.getIRI()).size() <= 0;
  }
  return false;
}
 
Example #19
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Assumes OBO-style IDspaces; specifically URI contains "..../IDSPACE_..." 
 * @param idspace
 * @param subOnt
 */
public void transferAxiomsUsingIdSpace(String idspace, OWLOntology subOnt) {
	Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
	LOG.info("ID Space: "+idspace);
	for (OWLClass c : getOntology().getClassesInSignature()) {
		String iriStr = c.getIRI().toString().toLowerCase();
		if (iriStr.contains("/"+idspace.toLowerCase()+"_")) {
			LOG.info("MATCH: "+c);
			axioms.addAll(getOntology().getDeclarationAxioms(c));
			axioms.addAll(getOntology().getAxioms(c, Imports.EXCLUDED));
			axioms.addAll(getOntology().getAnnotationAssertionAxioms(c.getIRI()));
		}
	}
	LOG.info("Transferring "+axioms.size()+" axioms from "+getOntology()+" to "+subOnt);
	this.getManager().removeAxioms(getOntology(), axioms);
	this.getManager().addAxioms(subOnt, axioms);
}
 
Example #20
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Set<DataProperty> getAllNoDomainDataProperties() {
    return owlOntology.dataPropertiesInSignature(Imports.INCLUDED)
            .filter(property -> hasNoDomain(owlOntology.axioms(OWLDataPropertyDomainAxiom.class,
                    OWLDataPropertyExpression.class, property, Imports.INCLUDED,
                    Navigation.IN_SUB_POSITION)))
            .map(SimpleOntologyValues::mobiDataProperty)
            .collect(Collectors.toSet());
}
 
Example #21
Source File: OntologyHelper.java    From robot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get all OWLObjects from an input ontology.
 *
 * @param ontology OWLOntology to retrieve objects from
 * @return set of objects
 */
public static Set<OWLObject> getObjects(OWLOntology ontology) {
  Set<OWLObject> objects = new HashSet<>();
  // TODO - include or exclude imports?
  for (OWLAxiom axiom : ontology.getAxioms(Imports.EXCLUDED)) {
    objects.addAll(getObjects(axiom));
  }
  return objects;
}
 
Example #22
Source File: AbstractConverter.java    From OWL2VOWL with MIT License 5 votes vote down vote up
private void processDataProperties(OWLOntology ontology, VowlData vowlData) {
	for (OWLDataProperty property : ontology.dataPropertiesInSignature(Imports.INCLUDED)
			.collect(Collectors.toSet())) {
		for (OWLDataPropertyAxiom propertyAxiom : ontology.axioms(property, Imports.INCLUDED)
				.collect(Collectors.toSet())) {
			try {
				propertyAxiom.accept(new DataPropertyVisitor(vowlData, property));
			} catch (Exception e) {
				logger.info("DataPropertyVisitor : Failed to accept OWLDataPropertyAxiom -> Skipping");
			}
		}
	}
}
 
Example #23
Source File: OWLGraphWrapperEdges.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void includeAllWith(OWLAnnotationProperty ap, OWLOntology o) {
	for (OWLObjectProperty p : o.getObjectPropertiesInSignature(Imports.INCLUDED)) {
		Set<OWLAnnotation> anns = OwlHelper.getAnnotations(p, ap, o);
		for (OWLAnnotation ann : anns) {
			if (ann.getValue() instanceof OWLLiteral) {
				OWLLiteral v = (OWLLiteral) ann.getValue();
				if (v.parseBoolean()) {
					includeProperty(p);
				}
			}

		}
	}
}
 
Example #24
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Deprecated
public Set<OWLClassExpression> getDirectAttributeClassExpressions() {
	Set<OWLClassExpression> types = new HashSet<OWLClassExpression>();
	for (OWLNamedIndividual ind : inputOntology.getIndividualsInSignature(Imports.INCLUDED)) {
		types.addAll(OwlHelper.getTypes(ind, inputOntology));
	}
	LOG.info("Num attribute expressions = "+types.size());
	return types;
}
 
Example #25
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Set<ObjectProperty> getAllNoDomainObjectProperties() {
    return owlOntology.objectPropertiesInSignature(Imports.INCLUDED)
            .filter(property -> hasNoDomain(owlOntology.axioms(OWLObjectPropertyDomainAxiom.class,
                    OWLObjectPropertyExpression.class, property, Imports.INCLUDED, Navigation.IN_SUB_POSITION)))
            .map(SimpleOntologyValues::mobiObjectProperty)
            .collect(Collectors.toSet());
}
 
Example #26
Source File: OWLHandler.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Params: direct
 * @throws OWLOntologyCreationException
 * @throws OWLOntologyStorageException
 * @throws IOException
 */
public void allSubClassOfCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
	headerOWL();
	boolean direct = getParamAsBoolean(Param.direct, true);
	OWLReasoner r = getReasoner();
	for (OWLClass c : getOWLOntology().getClassesInSignature(Imports.INCLUDED)) {
		for (OWLClass sc : r.getSuperClasses(c, direct).getFlattened()) {
			output(graph.getDataFactory().getOWLSubClassOfAxiom(c, sc));
		}
	}
}
 
Example #27
Source File: BridgeExtractor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addObjectProperty(OWLObjectProperty p, OWLOntology xOnt) {
	if (xOnt.getDeclarationAxioms(p).size() > 0) {
		return;
	}
	OWLOntologyManager m = ontology.getOWLOntologyManager();
	OWLDataFactory df = m.getOWLDataFactory();
	m.addAxiom(xOnt, df.getOWLDeclarationAxiom(p));
	for (OWLAxiom ax : ontology.getAxioms(p, Imports.EXCLUDED)) {
		m.addAxiom(xOnt, ax);
	}
	// TODO

}
 
Example #28
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * assumes that the ontology contains both attributes (TBox) and elements + associations (ABox)
 */
public void createElementAttributeMapFromOntology() {
	Set<OWLClass> allTypes = new HashSet<OWLClass>();
	for (OWLNamedIndividual e : sourceOntology.getIndividualsInSignature(Imports.INCLUDED)) {
		
		// NEW: we assume that grouping classes have already been generated
		Set<OWLClass> types = getReasoner().getTypes(e, true).getFlattened();
		allTypes.addAll(addElement(e, types));
		
		/*
		// find all attributes for an individual. May be
		//   direct named parent classes;
		//   parent class expressions
		Set<OWLClassExpression> types = e.getTypes(sourceOntology);

		// role-bounded MSC for k=1. TODO  k>1
		Map<OWLObjectPropertyExpression, Set<OWLIndividual>> pvs = e.getObjectPropertyValues(sourceOntology);
		for (OWLObjectPropertyExpression pe : pvs.keySet()) {
			for (OWLIndividual j : pvs.get(pe)) {
				for (OWLClassExpression t : j.getTypes(sourceOntology)) {
					types.add(owlDataFactory.getOWLObjectSomeValuesFrom(pe, t));
				}
			}
		}

		allTypes.addAll(addElement(e, types));
		*/

	}
	// need to materialize as classes...
	LOG.info("Using "+allTypes.size()+" attribute classes");
	fixedAttributeClasses = allTypes;
}
 
Example #29
Source File: FastOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void assignDefaultInformationContentForAllClasses() {
	for (OWLClass c : getSourceOntology().getClassesInSignature(Imports.INCLUDED) ) {
		try {
			getInformationContentForAttribute(c);
		} catch (UnknownOWLClassException e) {
			LOG.error("Unknown class: "+c);
		}
	}
}
 
Example #30
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isEntailed(Set<? extends OWLAxiom> axioms)
throws ReasonerInterruptedException,
UnsupportedEntailmentTypeException, TimeOutException,
AxiomNotInProfileException, FreshEntitiesException,
InconsistentOntologyException {
	for (OWLAxiom ax : axioms) {
		if (!getRootOntology().containsAxiom(ax, Imports.INCLUDED, AxiomAnnotations.IGNORE_AXIOM_ANNOTATIONS)) {
			return false;
		}
	}
	return true;
}