private String getStringValue(OWLAnnotationAssertionAxiom ax) { OWLAnnotationValue value = ax.getValue(); String stringValue = value.accept(new OWLAnnotationValueVisitorEx<String>() { @Override public String visit(IRI iri) { return iri.toString(); } @Override public String visit(OWLAnonymousIndividual individual) { return null; } @Override public String visit(OWLLiteral literal) { return literal.getLiteral(); } }); return stringValue; }
private static JsonAnnotation create(final String key, OWLAnnotationValue value, final CurieHandler curieHandler) { return value.accept(new OWLAnnotationValueVisitorEx<JsonAnnotation>() { @Override public JsonAnnotation visit(IRI iri) { String iriString = curieHandler.getCuri(iri); return JsonAnnotation.create(key, iriString, VALUE_TYPE_IRI); } @Override public JsonAnnotation visit(OWLAnonymousIndividual individual) { return null; // do nothing } @Override public JsonAnnotation visit(OWLLiteral literal) { return JsonAnnotation.create(key, literal.getLiteral(), getType(literal)); } }); }
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox, OWLOntologyManager manager, OWLDataFactory factory) { ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory); for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) { OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create(Constants.CERTAINTY_ANNOTATION_URI )); OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() ); OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue ); OWLClassExpression clsEv = (OWLClassExpression)converter.convert( cc.getEvidence() ); OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() ); OWLAxiom axiom = factory.getOWLSubClassOfAxiom( clsEv, clsCn, Collections.singleton( annotation ) ); try { manager.applyChange( new AddAxiom(ontology, axiom) ); } catch( OWLOntologyChangeException e ) { e.printStackTrace(); } } }
protected List<OWLObjectEditor<? extends OWLAnnotationValue>> createEditors() { final IRIFromEntityEditor iriEditor = new IRIFromEntityEditor(owlEditorKit); iriEditor.addSelectionListener(changeListener); final OWLConstantEditor constantEditor = new OWLConstantEditor(owlEditorKit); // @@TODO add change listener final OWLAnonymousIndividualAnnotationValueEditor anonIndividualEditor = new OWLAnonymousIndividualAnnotationValueEditor(owlEditorKit); // @@TODO add change listener final IRITextEditor textEditor = new IRITextEditor(owlEditorKit); textEditor.addStatusChangedListener(mergedVerificationListener); List<OWLObjectEditor<? extends OWLAnnotationValue>> result = new ArrayList<OWLObjectEditor<? extends OWLAnnotationValue>>(); result.add(constantEditor); result.add(iriEditor); result.add(textEditor); result.add(anonIndividualEditor); return result; }
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) { return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() { @Override public OWLNamedIndividual visit(final IRI iri) { OWLNamedIndividual i = null; for(OWLNamedIndividual current : model.getIndividualsInSignature()) { if (current.getIRI().equals(iri)) { i = current; break; } } return i; } @Override public OWLNamedIndividual visit(OWLAnonymousIndividual individual) { return null; } @Override public OWLNamedIndividual visit(OWLLiteral literal) { return null; } }); }
/** * Retrieve the literal values for the axiom annotations with the given * annotation property IRI. * * @param iri * @param axiom * @return literal values or null */ public static List<String> getAxiomAnnotationValues(IRI iri, OWLAxiom axiom) { List<String> result = null; for(OWLAnnotation annotation : axiom.getAnnotations()) { OWLAnnotationProperty property = annotation.getProperty(); if (property.getIRI().equals(iri)) { OWLAnnotationValue value = annotation.getValue(); if (value instanceof OWLLiteral) { String literal = ((OWLLiteral) value).getLiteral(); if (result == null) { result = Collections.singletonList(literal); } else if (result.size() == 1) { result = new ArrayList<String>(result); result.add(literal); } else { result.add(literal); } } } } return result; }
/** * Find all corresponding {@link OWLObject}s with an OBO-style alternate identifier. * <p> * WARNING: This methods scans all object annotations in all ontologies. * This is an expensive method. * * @return map of altId to OWLObject (never null) */ public Map<String, OWLObject> getAllOWLObjectsByAltId() { final Map<String, OWLObject> results = new HashMap<String, OWLObject>(); final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag()); if (altIdProperty == null) { return Collections.emptyMap(); } for (OWLOntology o : getAllOntologies()) { Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION); for (OWLAnnotationAssertionAxiom aa : aas) { OWLAnnotationValue v = aa.getValue(); OWLAnnotationProperty property = aa.getProperty(); if (altIdProperty.equals(property) && v instanceof OWLLiteral) { String altId = ((OWLLiteral)v).getLiteral(); OWLAnnotationSubject subject = aa.getSubject(); if (subject instanceof IRI) { OWLObject obj = getOWLObject((IRI) subject); if (obj != null) { results.put(altId, obj); } } } } } return results; }
private String getOntologyAnnotationValue(OWLOntology o, OboFormatTag tag) { IRI dateTagIRI = Obo2Owl.trTagToIRI(tag.getTag()); Set<OWLAnnotation> annotations = o.getAnnotations(); for (OWLAnnotation annotation : annotations) { OWLAnnotationProperty property = annotation.getProperty(); if(dateTagIRI.equals(property.getIRI())) { OWLAnnotationValue value = annotation.getValue(); if (value != null) { if (value instanceof IRI) { return ((IRI) value).toString(); } else if (value instanceof OWLLiteral) { return ((OWLLiteral) value).getLiteral(); } } } } return null; }
public void buildClassMap(OWLGraphWrapper g) { IRI x = Obo2OWLVocabulary.IRI_OIO_hasDbXref.getIRI(); for (OWLOntology ont : g.getAllOntologies()) { for (OWLClass c : ont.getClassesInSignature()) { for (OWLAnnotationAssertionAxiom aa : ont.getAnnotationAssertionAxioms(c.getIRI())) { if (aa.getProperty().getIRI().equals(x)) { OWLAnnotationValue v = aa.getValue(); if (v instanceof OWLLiteral) { String xid =((OWLLiteral)v).getLiteral(); OWLClass xc = (OWLClass) g.getOWLObjectByIdentifier(xid); if (xc == null) { LOG.error("Cannot get class for: "+xid); } else { config.classMap.put(xc, c); } //LOG.info(c + " ===> "+xid); } } } } } }
private String getLabel(OWLEntity obj) throws MultiLabelException { String label = null; OWLAnnotationProperty labelProperty = ont.getOWLOntologyManager().getOWLDataFactory().getRDFSLabel(); for (OWLAnnotation ann : OwlHelper.getAnnotations(obj, labelProperty, ont)) { if (ann.getProperty().isLabel()) { OWLAnnotationValue v = ann.getValue(); if (v instanceof OWLLiteral) { if (label != null) { throw new MultiLabelException(obj); } label = ((OWLLiteral)v).getLiteral(); } } } return label; }
public static String getTitle(Iterable<OWLAnnotation> annotations) { if (annotations != null) { for (OWLAnnotation annotation : annotations) { String propertyId = annotation.getProperty().getIRI() .toString(); OWLAnnotationValue annValue = annotation.getValue(); String value = annValue.accept(LiteralValueVisitor.INSTANCE); if (value != null) { if ("http://purl.org/dc/elements/1.1/title" .equals(propertyId)) { return value; } } } } return null; }
/** * Add an synonym annotation, plus an annotation on that annotation * that specified the type of synonym. The second annotation has the * property oio:hasSynonymType. * * @param ontology the current ontology * @param subject the subject of the annotation * @param type the IRI of the type of synonym * @param property the IRI of the annotation property. * @param value the literal value of the synonym * @return the synonym annotation axiom */ protected static OWLAnnotationAssertionAxiom synonym( OWLOntology ontology, OWLEntity subject, OWLAnnotationValue type, OWLAnnotationProperty property, OWLAnnotationValue value) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); OWLAnnotationProperty hasSynonymType = dataFactory.getOWLAnnotationProperty( format.getIRI("oio:hasSynonymType")); OWLAnnotation annotation = dataFactory.getOWLAnnotation(hasSynonymType, type); Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>(); annotations.add(annotation); OWLAnnotationAssertionAxiom axiom = dataFactory.getOWLAnnotationAssertionAxiom( property, subject.getIRI(), value, annotations); manager.addAxiom(ontology, axiom); return axiom; }
String asString(OWLAnnotationValue value) { Objects.requireNonNull(value); if (Objects.isNull(value)) { return ""; } else { String str = value.toString().trim(); if (str.startsWith(QUOTES)) { int pos = str.indexOf(QUOTES, QUOTES.length()); if (pos == -1) { return str; } else { return str.substring(QUOTES.length(), pos); } } else { return str; } } }
Set<OWLAnnotation> reg(Set<OWLAnnotation> annotations) { Objects.requireNonNull(annotations); if (annotations.isEmpty()) { return Collections.emptySet(); } else if (annotations.size() == 1) { OWLAnnotation annotation = annotations.iterator().next(); String varName = VARIABLE_PREFIX + this.network.keySet().size(); this.variableOrder.add(varName); String annotStr = asString(annotation.getValue()); this.network.put(varName, annotStr); OWLAnnotationValue value = this.df.getOWLLiteral(varName); OWLAnnotation newAnnotation = this.df.getOWLAnnotation(annotation.getProperty(), value); return Collections.singleton(newAnnotation); } else { throw new IllegalArgumentException( "Unexpected number of annotations. The OWL axiom can have at most 1 annotation. Annotations: '" + annotations.toString() + "'."); } }
public Set<OWLAnnotationValue> getOntologyAnnotationValue( String turambarOntologyAnnotation) { Set<OWLAnnotationValue> response = new HashSet<OWLAnnotationValue>(); if (ontology.containsAnnotationPropertyInSignature( IRI.create(turambarOntologyAnnotation), true)) { final Set<OWLAnnotation> annotations = ontology.getAnnotations(); OWLDataFactory factory = ontology.getOWLOntologyManager() .getOWLDataFactory(); final OWLAnnotationProperty dcProperty = factory .getOWLAnnotationProperty(IRI .create(turambarOntologyAnnotation)); for (OWLAnnotation a : annotations) { if (a.getProperty().equals(dcProperty)) { response.add(a.getValue()); } } } return response; }
public Map<String, Set<OWLAnnotationValue>> getOntologyAnnotationsOrderedByOntology( String annotation) { Map<String, Set<OWLAnnotationValue>> annotationValuesByOntologyIri = new HashMap<String, Set<OWLAnnotationValue>>(); final OWLDataFactory factory = manager.getOWLDataFactory(); final OWLAnnotationProperty dcProperty = factory .getOWLAnnotationProperty(IRI.create(annotation)); for (OWLOntology ontology : manager.getOntologies()) { Set<OWLAnnotationValue> annotationValues = new HashSet<OWLAnnotationValue>(); for (OWLAnnotation owlAnnotation : ontology.getAnnotations()) { if (owlAnnotation.getProperty().equals(dcProperty)) { annotationValues.add(owlAnnotation.getValue()); } } if (!annotationValues.isEmpty()) { final OWLOntologyID ontologyID = ontology.getOntologyID(); annotationValuesByOntologyIri.put(ontologyID.getOntologyIRI() .toString(), annotationValues); } } return annotationValuesByOntologyIri; }
protected Optional<String> evaluateLabelAnnotationValue(OWLEntity entity, OWLAnnotationValue value) { // get label annotations Optional<String> label = getOWLAnnotationValueAsString(value); if (!label.isPresent()) { // try and get the URI fragment and use that as label Optional<String> fragment = getShortForm(entity.getIRI()); if (fragment.isPresent()) { return Optional.of(fragment.get()); } else { getLog().warn("OWLEntity " + entity + " contains no label. " + "No labels for this class will be loaded."); return Optional.of(entity.toStringID()); } } return label; }
private Collection<String> findAnnotationNames(IRI iri, OWLAnnotationProperty annotationType) { Collection<String> classNames = new HashSet<String>(); // get all literal annotations for (OWLAnnotationAssertionAxiom axiom : ontology.getAnnotationAssertionAxioms(iri)) { if (axiom.getAnnotation().getProperty().equals(annotationType)) { OWLAnnotationValue value = axiom.getAnnotation().getValue(); Optional<String> name = getOWLAnnotationValueAsString(value); if (name.isPresent()) { classNames.add(name.get()); } } } return classNames; }
public static String getLabel(OWLEntity e, OWLOntology ont) { final Iterator<OWLAnnotation> iterator = EntitySearcher.getAnnotations(e, ont).iterator(); while (iterator.hasNext()) { final OWLAnnotation an = iterator.next(); if (an.getProperty().isLabel()) { OWLAnnotationValue val = an.getValue(); if (val instanceof IRI) { return ((IRI) val).toString(); } else if (val instanceof OWLLiteral) { OWLLiteral lit = (OWLLiteral) val; return lit.getLiteral(); } else if (val instanceof OWLAnonymousIndividual) { OWLAnonymousIndividual ind = (OWLAnonymousIndividual) val; return ind.toStringID(); } else { throw new RuntimeException("Unexpected class " + val.getClass()); } } } return e.toStringID(); }
public static String getLabel(OWLEntity e, OWLOntology ont) { return EntitySearcher.getAnnotations(e, ont) .filter(an -> an.getProperty().isLabel()) .findFirst() .map(an -> { final OWLAnnotationValue val = an.getValue(); if (val instanceof IRI) { return ((IRI) val).toString(); } else if (val instanceof OWLLiteral) { OWLLiteral lit = (OWLLiteral) val; return lit.getLiteral(); } else if (val instanceof OWLAnonymousIndividual) { OWLAnonymousIndividual ind = (OWLAnonymousIndividual) val; return ind.toStringID(); } else { throw new RuntimeException("Unexpected class " + val.getClass()); } }) .orElse(e.toStringID()); }
private Metadata extractMetadata(OWLNamedIndividual individual, OWLGraphWrapper modelGraph, String modelId) { Metadata metadata = new Metadata(); metadata.modelId = modelId; metadata.individualIds = new HashSet<IRI>(); metadata.individualIds.add(individual.getIRI()); Set<OWLAnnotationAssertionAxiom> assertionAxioms = modelGraph.getSourceOntology().getAnnotationAssertionAxioms(individual.getIRI()); for (OWLAnnotationAssertionAxiom axiom : assertionAxioms) { OWLAnnotationProperty currentProperty = axiom.getProperty(); OWLAnnotationValue value = axiom.getValue(); extractMetadata(currentProperty, value, metadata); } return metadata; }
private Metadata extractMetadata(Collection<OWLAnnotation> annotations, OWLGraphWrapper modelGraph, String modelId) { Metadata metadata = new Metadata(); metadata.modelId = modelId; if (annotations != null && !annotations.isEmpty()) { for (OWLAnnotation owlAnnotation : annotations) { OWLAnnotationProperty currentProperty = owlAnnotation.getProperty(); OWLAnnotationValue value = owlAnnotation.getValue(); extractMetadata(currentProperty, value, metadata); } } return metadata; }
Set<OWLAnnotation> extract(JsonAnnotation[] values, String userId, Set<String> providerGroups, VariableResolver batchValues, ModelContainer model) throws UnknownIdentifierException { Set<OWLAnnotation> result = new HashSet<OWLAnnotation>(); OWLDataFactory f = model.getOWLDataFactory(); if (values != null) { for (JsonAnnotation jsonAnn : values) { if (jsonAnn.key != null && jsonAnn.value != null) { AnnotationShorthand shorthand = AnnotationShorthand.getShorthand(jsonAnn.key, curieHandler); if (shorthand != null) { if (AnnotationShorthand.evidence == shorthand) { IRI evidenceIRI; if (batchValues.notVariable(jsonAnn.value)) { evidenceIRI = curieHandler.getIRI(jsonAnn.value); } else { evidenceIRI = batchValues.getVariableValue(jsonAnn.value).getIRI(); } result.add(create(f, shorthand, evidenceIRI)); } else { result.add(create(f, shorthand, JsonTools.createAnnotationValue(jsonAnn, f))); } } else { IRI pIRI = curieHandler.getIRI(jsonAnn.key); if (dataPropertyIRIs.contains(pIRI) == false) { OWLAnnotationValue annotationValue = JsonTools.createAnnotationValue(jsonAnn, f); result.add(f.getOWLAnnotation(f.getOWLAnnotationProperty(pIRI), annotationValue)); } } } } } addGeneratedAnnotations(userId, providerGroups, result, f); return result; }
public static JsonAnnotation create(OWLAnnotationProperty p, OWLAnnotationValue value, CurieHandler curieHandler) { AnnotationShorthand annotationShorthand = AnnotationShorthand.getShorthand(p.getIRI()); if (annotationShorthand != null) { // try to shorten IRIs for shorthand annotations return create(annotationShorthand.getShorthand(), value, curieHandler); } return create(curieHandler.getCuri(p), value, curieHandler); }
public static OWLAnnotationValue createAnnotationValue(JsonAnnotation ann, OWLDataFactory f) { OWLAnnotationValue annotationValue; if (isIRIValue(ann)) { annotationValue = IRI.create(ann.value); } else { annotationValue = createLiteralInternal(ann, f); } return annotationValue; }
public void getRdfsLabels() { rdfsLabels = new HashMap<String, String>(); prefAltLabels = new HashMap<String, String>(); Set<OWLClass> classes = getAllConcepts(); String prefLabelIri = "<http://www.w3.org/2004/02/skos/core#prefLabel>"; String altLabelIri = "<http://www.w3.org/2004/02/skos/core#altLabel>"; for (OWLClass cls : classes) { for (OWLAnnotation a : EntitySearcher.getAnnotations(cls, ontology)) { // properties are of several types: rdfs-label, altLabel or prefLabel OWLAnnotationProperty prop = a.getProperty(); OWLAnnotationValue val = a.getValue(); if (val instanceof OWLLiteral) { // RDFS-labels if (prop.isLabel()) { // System.out.println(cls + " labelled " + ((OWLLiteral) val).getLiteral()); // classes can have several rdfs labels rdfsLabels.put(((OWLLiteral)val).getLiteral(), cls.toString()); } // preferred or alternative labels else if (prop.toString().equals(prefLabelIri) || prop.toString().equals(altLabelIri)) { // System.out.println(cls + " labelled (pref or alt) " + ((OWLLiteral) // val).getLiteral()); // classes can have several labels prefAltLabels.put(((OWLLiteral)val).getLiteral(), cls.toString()); } } } } }
protected void addPABoxConstraints(OWLOntology ontology, PABox pabox, KnowledgeBase kb, OWLOntologyManager manager, OWLDataFactory factory) { ConceptConverter converter = new ConceptConverter(kb, factory); for (Map.Entry<ATermAppl, Set<ConditionalConstraint>> entry : pabox.getConstraintsMap().entrySet()) { for (ConditionalConstraint cc : entry.getValue()) { OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create( Constants.CERTAINTY_ANNOTATION_URI )); OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() ); OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue ); OWLIndividual indiv = factory.getOWLNamedIndividual( IRI.create( entry.getKey().getName()) ); OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() ); OWLAxiom axiom = factory.getOWLClassAssertionAxiom( clsCn, indiv, Collections.singleton( annotation ) ); try { manager.applyChange( new AddAxiom(ontology, axiom) ); } catch( OWLOntologyChangeException e ) { e.printStackTrace(); } } } }
public OWLAnnotation getAnnotation() { OWLAnnotationProperty property = annotationPropertySelector.getSelectedObject(); if (property != null){ lastSelectedProperty = property; OWLDataFactory dataFactory = owlEditorKit.getModelManager().getOWLDataFactory(); OWLAnnotationValue obj = getSelectedEditor().getEditedObject(); if (obj != null) { return dataFactory.getOWLAnnotation(property, obj); } } return null; }
@CLIMethod("--remove-subset-entities") public void removeSubsetEntities(Opts opts) throws Exception { opts.info("[SUBSET]+","Removes all classes, individuals and object properties that are in the specific subset(s)"); List<String> subSets = opts.nextList(); if (subSets == null || subSets.isEmpty()) { System.err.println("At least one subset is required for this function."); exit(-1); } // create annotation values to match Set<OWLAnnotationValue> values = new HashSet<OWLAnnotationValue>(); OWLDataFactory f = g.getDataFactory(); for(String subSet : subSets) { // subset as plain string values.add(f.getOWLLiteral(subSet)); // subset as IRI values.add(IRI.create(Obo2OWLConstants.DEFAULT_IRI_PREFIX+"#"+subSet)); } // get annotation property for subset OWLAnnotationProperty p = g.getAnnotationProperty(OboFormatTag.TAG_SUBSET.getTag()); // collect all objects in the given subset final Set<OWLObject> entities = Mooncat.findTaggedEntities(p, values, g); LOG.info("Found "+entities.size()+" tagged objects."); if (entities.isEmpty() == false) { final List<RemoveAxiom> changes = Mooncat.findRelatedAxioms(entities, g); if (changes.isEmpty() == false) { LOG.info("applying changes to ontology, count: "+changes.size()); g.getManager().applyChanges(changes); } else { LOG.info("No axioms found for removal."); } } }
private String getLabel(OWLEntity e) { String label = null; // todo - ontology import closure OWLAnnotationProperty property = owlDataFactory.getRDFSLabel(); for (OWLAnnotation ann : OwlHelper.getAnnotations(e, property, sourceOntology)) { OWLAnnotationValue v = ann.getValue(); if (v instanceof OWLLiteral) { label = ((OWLLiteral)v).getLiteral(); break; } } return label; }
/** * any class whose label matches any of the strings returned * here will be excluded from any analysis. * * the set of excluded labels is controlled by loading an * ontology with an entity PhenoSim_0000001 where all * the literals associated with this are excluded. * (note that this method may change in future) * * @return excluded labels */ public Set<String> getExcludedLabels() { if (excludedLabels != null) return excludedLabels; excludedLabels = new HashSet<String>(); for (OWLAnnotationAssertionAxiom aa : getGraph().getSourceOntology().getAnnotationAssertionAxioms(IRI.create("http://purl.obolibrary.org/obo/PhenoSim_0000001"))) { OWLAnnotationValue v = aa.getValue(); if (v instanceof OWLLiteral) { excludedLabels.add(((OWLLiteral)v).getLiteral()); } } return excludedLabels; }
public String getLabel(OWLEntity c, OWLOntology ont) { String label = null; // todo - ontology import closure OWLAnnotationProperty property = getOWLDataFactory().getRDFSLabel(); for (OWLAnnotation ann : OwlHelper.getAnnotations(c, property, ont)) { OWLAnnotationValue v = ann.getValue(); if (v instanceof OWLLiteral) { label = ((OWLLiteral)v).getLiteral(); break; } } return label; }
public boolean isUpperLevel(OWLClass c) { // TODO - cache Set<OWLAnnotation> anns = OwlHelper.getAnnotations(c, inputOntology); for (OWLAnnotation ann : anns) { String ap = ann.getProperty().getIRI().toString(); OWLAnnotationValue v = ann.getValue(); if (v instanceof IRI) { IRI iv = (IRI)v; if (ap.endsWith("inSubset")) { // TODO - formalize this if (iv.toString().contains("upper_level")) { return true; } // this tag is used in uberon if (iv.toString().contains("non_informative")) { return true; } // hack: representation of early dev a bit problematic // temporary: find a way to exclude these axiomatically if (iv.toString().contains("early_development")) { return true; } } } } return false; }
public String getLabel(OWLEntity c, OWLOntology ont) { String label = null; // todo - ontology import closure for (OWLAnnotation ann : OwlHelper.getAnnotations(c, owlDataFactory.getRDFSLabel(), ont)) { OWLAnnotationValue v = ann.getValue(); if (v instanceof OWLLiteral) { label = ((OWLLiteral)v).getLiteral(); break; } } return label; }
public OntologyAnnotation(OWLAnnotation ann) { property = ann.getProperty().getIRI().toString(); OWLAnnotationValue v = ann.getValue(); if (v instanceof IRI) { value = v.toString(); } else { OWLLiteral lit = ((OWLLiteral)v); value = lit.getLiteral().toString(); } }
public static Set<OWLObject> findTaggedEntities(OWLAnnotationProperty p, Set<OWLAnnotationValue> values, final OWLGraphWrapper graph) { if (p == null || values == null || values.isEmpty()) { return Collections.emptySet(); } final Set<OWLObject> entities = new HashSet<OWLObject>(); Set<OWLOntology> allOntologies = graph.getAllOntologies(); for (OWLOntology ontology : allOntologies) { Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION); for (OWLAnnotationAssertionAxiom axiom : axioms) { if (p.equals(axiom.getProperty()) && values.contains(axiom.getValue())) { axiom.getSubject().accept(new OWLAnnotationSubjectVisitor(){ @Override public void visit(IRI iri) { OWLObject owlObject = graph.getOWLObject(iri); if (owlObject != null) { entities.add(owlObject); } } @Override public void visit(OWLAnonymousIndividual individual) { // do nothing } }); } } } return entities; }
public boolean isSkippable(OWLClass c) { Set<OWLAnnotation> anns = OwlHelper.getAnnotations(c, ont); for (OWLAnnotation ann : anns) { String ap = ann.getProperty().getIRI().toString(); OWLAnnotationValue v = ann.getValue(); if (v instanceof IRI) { IRI iv = (IRI)v; if (ap.endsWith("inSubset")) { // TODO - formalize this if (iv.toString().contains("upper_level")) { return true; } // this tag is used in uberon if (iv.toString().contains("non_informative")) { return true; } // hack: representation of early dev a bit problematic // temporary: find a way to exclude these axiomatically if (iv.toString().contains("early_development")) { return true; } } } } return false; }
private AnnTuple getAnnTuple(OWLAnnotationAssertionAxiom aax) { String v; OWLAnnotationValue av = aax.getValue(); if (av instanceof OWLLiteral) { v = ((OWLLiteral)av).getLiteral(); } else { v = av.toString(); } v = v.toLowerCase(); return new AnnTuple((IRI)aax.getSubject(), v); }
public Object makeAnnotationValue(OWLAnnotationValue v) { if (v instanceof IRI) { return ((IRI)v).toString(); } else if (v instanceof OWLLiteral) { String lit = ((OWLLiteral)v).getLiteral(); return lit; } else { return null; } }