protected void expandAssertions(OWLOntology o, OWLAnnotationProperty p) { OWLAnnotationProperty ap425 = df.getOWLAnnotationProperty(IRI_IAO_0000425.getIRI()); getAnnotationObjects(p, o.importsClosure(), ap425).map(a -> a.getValue().asLiteral()) .filter(v -> v.isPresent()) .forEach(v -> { String str = v.get().getLiteral(); LOG.info("assertion mapping {} to {}", p, str); expandAssertionToMap.put(p.getIRI(), str); }); }
@Override public void visit(OWLAnnotation node) { sb.append("Annotation("); node.annotations().forEach(a -> { a.accept(this); sb.append(' '); }); node.getProperty().accept(this); sb.append(' '); node.getValue().accept(this); sb.append(')'); }
public static boolean isDeprecated(@Nonnull IRI iri, @Nonnull Collection<OWLOntology> ontologies) { for (OWLOntology ontology : ontologies) { for (OWLAnnotationAssertionAxiom assertion : ontology.getAnnotationAssertionAxioms(iri)) { if (!assertion.getProperty().isDeprecated()) { continue; } if (!(assertion.getValue() instanceof OWLLiteral)) { continue; } OWLLiteral value = (OWLLiteral) assertion.getValue(); if (!value.isBoolean()) { continue; } if (value.parseBoolean()) { return true; } } } return false; } }
/** * @param ontology ontology * @return set of existing pattern names */ public static Set<String> getExistingPatternNames(OWLOntology ontology) { return asSet(ontology.annotations().filter(Utils::annotationInPatternNamespace) .map(a -> a.getProperty().getIRI().getFragment())); }
protected Set<OWLAnnotation> getVisitedAnnotations() { Set<OWLAnnotation> toReturn = new HashSet<>(); for (String visitedPatternName : this.visited) { IRI iri = IRI.create(PatternModel.NAMESPACE + visitedPatternName); this.getConstraintSystem().getOntologyManager().ontologies() .flatMap(OWLOntology::annotations).filter(a -> a.getProperty().getIRI().equals(iri)) .forEach(toReturn::add); } return toReturn; }
/** * @return originating ontology */ public OWLOntology getOriginatingOntology() { return ontologyManager.ontologies() .filter(o -> o.annotations().anyMatch(a -> a.getProperty().getIRI().equals(iri))) .findFirst().orElse(null); }
private void updateDeprecatedEntityAnnotations(@Nonnull List<OWLOntologyChange> changes) { if (!profile.shouldRemoveAnnotationAssertions()) { logger.info("[Deprecate Entity] Annotation assertions left intact"); return; } ontologies.forEach(o -> { o.getAnnotationAssertionAxioms(info.getEntityToDeprecate().getIRI()).stream() .filter(ax -> { Set<IRI> preservedAnnotationValuePropertiesIris = profile.getPreservedAnnotationValuePropertiesIris(); return !preservedAnnotationValuePropertiesIris.contains(ax.getProperty().getIRI()); }) .forEach(ax -> changes.add(new RemoveAxiom(o, ax))); }); }
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 } } } }
@Override public Set<OWLObject> getOWLObjects(OWLOntology ontology, ErrorListener errorListener) { return asSet(ontology.annotations().filter(a -> iri.equals(a.getProperty().getIRI())), OWLObject.class); }
/** * Imports closure changed. */ protected final void importsClosureChanged() { // NOTE: This method only gets called when the ontology being parsed // adds a direct import. This is enough // for resolving the imports closure. // We cache IRIs of various entities here. // We also mop up any triples that weren't parsed and consumed in the // imports closure. ontology.annotationPropertiesInSignature(INCLUDED) .forEach(e -> annPropertyIRIs.add(e.getIRI())); ontology.dataPropertiesInSignature(INCLUDED).forEach(e -> dataPropertyIRIs.add(e.getIRI())); ontology.objectPropertiesInSignature(INCLUDED) .forEach(e -> objectPropertyIRIs.add(e.getIRI())); ontology.classesInSignature(INCLUDED).forEach(e -> classIRIs.add(e.getIRI())); ontology.datatypesInSignature(INCLUDED).forEach(e -> dataRangeIRIs.add(e.getIRI())); ontology.individualsInSignature(INCLUDED).forEach(e -> individualIRIs.add(e.getIRI())); }
private void printOntologyHeader(final OWLOntology ontology) { ontology.annotations().forEach(annotation -> { final IRI property = annotation.getProperty().getIRI(); final OWLAnnotationValue value = annotation.getValue(); if (property.equals(OWLRDFVocabulary.OWL_VERSION_INFO.getIRI())) verbose("Version Info = " + getString(value)); else if (property.equals(OWLRDFVocabulary.OWL_PRIOR_VERSION.getIRI())) verbose("Prior Version Info = " + getString(value)); else if (property.equals(OWLRDFVocabulary.OWL_BACKWARD_COMPATIBLE_WITH.getIRI())) verbose("Backward Compatible With = " + getString(value)); else if (property.equals(OWLRDFVocabulary.OWL_INCOMPATIBLE_WITH.getIRI())) verbose("Incompatible With = " + getString(value)); }); }
private boolean isMetadataTag(OWLAnnotationProperty p) { final IRI metadataTagIRI = IRI .create(Obo2OWLConstants.OIOVOCAB_IRI_PREFIX, OboFormatTag.TAG_IS_METADATA_TAG .getTag()); return owlOntology.annotationAssertionAxioms(p.getIRI()) .anyMatch(ax -> metadataTagIRI.equals(ax.getProperty() .getIRI())); }
@Override @Nullable public String getName(String id) { // convert OBO id to IRI OWLAPIObo2Owl obo2owl = new OWLAPIObo2Owl(ont.getOWLOntologyManager()); IRI iri = obo2owl.oboIdToIRI(id); // look for label of entity List<OWLAnnotationAssertionAxiom> axioms = asList(ont.axioms(OWLAnnotationAssertionAxiom.class, OWLAnnotationSubject.class, iri, Imports.INCLUDED, IN_SUB_POSITION)); for (OWLAnnotationAssertionAxiom axiom : axioms) { if (axiom.getProperty().isLabel()) { OWLAnnotationValue value = axiom.getValue(); if (value instanceof OWLLiteral) { return ((OWLLiteral) value).getLiteral(); } } } return null; }
public void visit(OWLAnnotationAssertionAxiom axiom) { axiom.getSubject().accept(this); renderSpace(); axiom.getProperty().accept(this); renderSpace(); axiom.getValue().accept(this); }
@Override public void visit(OWLAnnotation node) { write("Annotation"); node.getProperty().getIRI().accept(this); node.getValue().accept(this); }
public static String getAnnotationValueByUri(OWLOntology o, OWLEntity owlEntity, String uri) { for (OWLAnnotation annotation : EntitySearcher.getAnnotations(owlEntity, o)) { if (annotation.getProperty().getIRI().toString().equals(uri)) { OWLLiteral value = (OWLLiteral) annotation.getValue(); return value.getLiteral(); } } return null; }
public static String getLabel(OWLOntology o, OWLEntity owlEntity) { String bestLabel = owlEntity.getIRI().toString(); for (OWLAnnotation annotation : EntitySearcher.getAnnotations(owlEntity, o)) { if (annotation.getProperty().isLabel()) { OWLLiteral value = (OWLLiteral) annotation.getValue(); bestLabel = value.getLiteral(); if (value.getLang().equals("") || value.getLang().equals("en")) { return bestLabel; } } } return bestLabel; }
public static boolean isAxiomForDictionary(@Nonnull OWLAnnotationAssertionAxiom ax, @Nonnull Dictionary dictionary) { if(!(ax.getSubject() instanceof IRI)) { return false; } if(!(ax.getValue() instanceof OWLLiteral)) { return false; } IRI iri = ax.getProperty().getIRI(); String lang = ((OWLLiteral) ax.getValue()).getLang(); return isDictionaryFor(dictionary, iri, lang); }
public void visit(OWLAnnotation annotation) { if (annotation.getProperty().getIRI().equals(adcManager.getURI())){ annotation.getValue().accept(this); } }