org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom. 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
void addSubAnnotationProperties(Set<OWLAxiom> axioms) {
	// add ALL subannotprop axioms
	// - this is quite geared towards obo ontologies, where
	//   we want to preserve obo headers.
	// TODO: make this configurable
	LOG.info("adding SubAnnotationProperties");
	Set<OWLAxiom> sapAxioms = new HashSet<OWLAxiom>();
	for (OWLOntology refOnt : this.getReferencedOntologies()) {
		for (OWLSubAnnotationPropertyOfAxiom a : refOnt.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
			sapAxioms.add(a);
			Set<OWLAnnotationAssertionAxiom> s = refOnt.getAnnotationAssertionAxioms(a.getSubProperty().getIRI());
			if (s != null && !s.isEmpty()) {
				for (OWLAnnotationAssertionAxiom owlAnnotationAssertionAxiom : s) {
					sapAxioms.add(owlAnnotationAssertionAxiom);
				}
			}
		}
	}
	axioms.addAll(sapAxioms);
}
 
Example #2
Source File: OWLGraphWrapperEdgesExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Returns the direct child properties of <code>prop</code> in all ontologies.
 * @param prop      The <code>OWLAnnotationProperty</code> for which 
 *                  we want the direct sub-properties.
 * @return          A <code>Set</code> of <code>OWLAnnotationProperty</code>s 
 *                  that are the direct sub-properties of <code>prop</code>.
 * 
 * @see #getSubPropertyClosureOf(OWLObjectPropertyExpression)
 * @see #getSubPropertyReflexiveClosureOf(OWLObjectPropertyExpression)
 */
public Set<OWLAnnotationProperty> getSubAnnotationPropertiesOf(
        OWLAnnotationProperty prop) {
    Set<OWLAnnotationProperty> subProps = new HashSet<OWLAnnotationProperty>();
    for (OWLOntology ont : this.getAllOntologies()) {
        //we need to iterate each annotation property, to get 
        //its getSubAnnotationPropertyOfAxioms and see if prop is its parent 
        //(there is no method "getSuperAnnotationPropertyOfAxioms").
        for (OWLAnnotationProperty subProp : ont.getAnnotationPropertiesInSignature()) {
            for (OWLSubAnnotationPropertyOfAxiom ax: 
                    ont.getSubAnnotationPropertyOfAxioms(subProp)) {
                if (ax.getSuperProperty().equals(prop)) {
                    subProps.add(subProp);
                }
            }
        }
    }
    return subProps;
}
 
Example #3
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
private Stream<IRI> getSubAnnotationPropertiesFor(OWLAnnotationProperty property, boolean direct) {
    Set<OWLAnnotationProperty> directProps = owlOntology.axioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF,
            Imports.INCLUDED)
            .filter(axiom -> axiom.getSuperProperty().equals(property))
            .map(OWLSubAnnotationPropertyOfAxiom::getSubProperty)
            .filter(subproperty -> !subproperty.isBottomEntity() && subproperty.isOWLAnnotationProperty()
                    && !subproperty.getIRI().equals(property.getIRI()))
            .collect(Collectors.toSet());
    if (direct) {
        return directProps.stream()
                .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getIRI()));
    } else {
        Set<IRI> rtn = directProps.stream()
                .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getIRI()))
                .collect(Collectors.toSet());
        while (directProps.size() > 0) {
            OWLAnnotationProperty nextProp = directProps.iterator().next();
            directProps.remove(nextProp);
            owlOntology.axioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF, Imports.INCLUDED)
                    .filter(axiom -> axiom.getSuperProperty().equals(nextProp))
                    .map(OWLSubAnnotationPropertyOfAxiom::getSubProperty)
                    .filter(subproperty -> !subproperty.isBottomEntity() && subproperty.isOWLAnnotationProperty()
                            && !subproperty.getIRI().equals(nextProp.getIRI()))
                    .forEach(subproperty -> {
                        rtn.add(SimpleOntologyValues.mobiIRI(subproperty.getIRI()));
                        directProps.add(subproperty);
                    });
        }
        return rtn.stream();
    }
}
 
Example #4
Source File: AbstractElkObjectConverter.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public OWLSubAnnotationPropertyOfAxiom visit(
		ElkSubAnnotationPropertyOfAxiom axiom) {
	return owlFactory_.getOWLSubAnnotationPropertyOfAxiom(
			convert(axiom.getSubAnnotationProperty()),
			convert(axiom.getSuperAnnotationProperty()));
}
 
Example #5
Source File: AbstractOwlAxiomConverterVisitor.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public T visit(OWLSubAnnotationPropertyOfAxiom axiom) {
	throw new IllegalArgumentException(
			OWLSubAnnotationPropertyOfAxiom.class.getSimpleName()
					+ " cannot be converted to "
					+ getTargetClass().getSimpleName());
}
 
Example #6
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLAnnotationProperty> getSubProperties(OWLAnnotationProperty superProp, Set<OWLOntology> ontologies) {
	Set<OWLAnnotationProperty> result = new HashSet<OWLAnnotationProperty>();
	for (OWLOntology ont : ontologies) {
		for (OWLSubAnnotationPropertyOfAxiom ax : ont.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
			if (ax.getSuperProperty().equals(superProp)) {
				result.add(ax.getSubProperty());
			}
		}
	}
	return result;
}
 
Example #7
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLAnnotationProperty> getSuperProperties(OWLAnnotationProperty subProp, Set<OWLOntology> ontologies) {
	Set<OWLAnnotationProperty> result = new HashSet<OWLAnnotationProperty>();
	for (OWLOntology ont : ontologies) {
		for (OWLSubAnnotationPropertyOfAxiom ax : ont.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
			if (ax.getSubProperty().equals(subProp)) {
				result.add(ax.getSuperProperty());
			}
		}
	}
	return result;
}
 
Example #8
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method for asserting a subAnnotationProperty relation 
 * between a parent and child property in an ontology.
 *
 * @param ontology the current ontology
 * @param child the child property
 * @param parent the parent property
 * @return the axiom
 */
protected static OWLSubAnnotationPropertyOfAxiom
		assertSubAnnotationProperty(
		OWLOntology ontology, OWLAnnotationProperty child,
		OWLAnnotationProperty parent) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLSubAnnotationPropertyOfAxiom axiom = 
		dataFactory.getOWLSubAnnotationPropertyOfAxiom(
			child, parent);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example #9
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
  long subProperty =
      getOrCreateNode(getIri(axiom.getSubProperty()), OwlLabels.OWL_ANNOTATION_PROPERTY);
  long superProperty =
      getOrCreateNode(getIri(axiom.getSuperProperty()), OwlLabels.OWL_ANNOTATION_PROPERTY);
  getOrCreateRelationship(subProperty, superProperty, OwlRelationships.RDFS_SUB_PROPERTY_OF);
  return null;
}
 
Example #10
Source File: OwlAnnotationAxiomConverterVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public ElkAnnotationAxiom visit(OWLSubAnnotationPropertyOfAxiom owlSubAnnotationPropertyOfAxiom) {
	return new ElkSubAnnotationPropertyOfAxiomWrap<OWLSubAnnotationPropertyOfAxiom>(owlSubAnnotationPropertyOfAxiom);
}
 
Example #11
Source File: OwlAxiomConverterVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public ElkAxiom visit(
		OWLSubAnnotationPropertyOfAxiom owlSubAnnotationPropertyOfAxiom) {
	return CONVERTER.convert(owlSubAnnotationPropertyOfAxiom);
}
 
Example #12
Source File: FailingOwlAxiomVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
	defaultVisit(axiom);
}
 
Example #13
Source File: AxiomAnnotationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public OWLAxiom visit(OWLSubAnnotationPropertyOfAxiom axiom) {
	return factory.getOWLSubAnnotationPropertyOfAxiom(axiom.getSubProperty(), axiom.getSuperProperty(), annotations);
}
 
Example #14
Source File: CardinalityContraintsTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void visit(OWLSubAnnotationPropertyOfAxiom axiom) {
}