org.semanticweb.owlapi.model.OWLAnnotationProperty Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.OWLAnnotationProperty.
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: SimpleOntology.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@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 #2
Source File: SpeciesMergeUtil.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private OWLAxiom tr(OWLClass c, OWLAnnotationAssertionAxiom ax) { OWLAnnotationProperty p = ax.getProperty(); if (!ecmap.containsKey(c)) { // preserve as-is, exception for labels if (p.isLabel()) { OWLLiteral lit = (OWLLiteral) ax.getValue(); String newVal = lit.getLiteral() + " (" + suffix + ")"; return fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ax.getSubject(), fac.getOWLLiteral(newVal)); } return ax; } else { // the class is merged - ditch its axioms // (in future some may be preserved - syns?) // fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ecmap, // ax.getValue()); return null; } }
Example #3
Source File: TemplatedTransformer.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Set<Mapping> getMappings() { Set<Mapping> ms = new HashSet<Mapping>(); OWLAnnotationProperty vap = getVariableAnnotationProperty(); for (OWLSubClassOfAxiom sca : ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED)) { Mapping m = new Mapping(); Set<OWLAnnotation> anns = sca.getAnnotations(vap); for (OWLAnnotation ann : anns) { IRI v = (IRI) ann.getValue(); m.vars.add(v); } if (m.vars.size() > 0) { m.src = sca.getSubClass(); m.tgt = sca.getSuperClass(); ms.add(m); LOG.info("MAPPING: "+m); } } return ms; }
Example #4
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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; }
Example #5
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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; }
Example #6
Source File: OGWSubAnnotationTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test {@link * OWLGraphWrapperEdgesExtended#getSubAnnotationPropertiesOf(OWLAnnotationProperty)}. */ @Test public void shouldGetSubAnnotationPropertiesOf() { Set<OWLAnnotationProperty> expectedSubprops = new HashSet<OWLAnnotationProperty>(); expectedSubprops.add(groupProp); assertEquals("Incorrect sub-properties returned", expectedSubprops, wrapper.getSubAnnotationPropertiesOf(subsetProp)); expectedSubprops = new HashSet<OWLAnnotationProperty>(); expectedSubprops.add(fake1Prop); expectedSubprops.add(fake2Prop); assertEquals("Incorrect sub-properties returned", expectedSubprops, wrapper.getSubAnnotationPropertiesOf(groupProp)); assertEquals("Incorrect sub-properties returned", new HashSet<OWLAnnotationProperty>(), wrapper.getSubAnnotationPropertiesOf(lonelyProp)); }
Example #7
Source File: OWLGraphWrapperEdgesExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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 #8
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Map<String,String> renderAnnotations(Set<OWLAnnotation> annotations) { Map<String,String> result = null; if (annotations != null && !annotations.isEmpty()) { for (OWLAnnotation annotation : annotations) { OWLAnnotationProperty prop = annotation.getProperty(); String literal = getLiteralValue(annotation.getValue()); if (literal != null) { if (result == null) { result = new HashMap<String, String>(); } result.put(prop.toStringID(), literal); } } } return result; }
Example #9
Source File: OWLGraphWrapperEdgesExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns all child properties of <code>prop</code> in all ontologies, * ordered from the more general (closer from <code>prop</code>) to the more precise. * * @param prop the <code>OWLAnnotationProperty</code> for which we want * the ordered sub-properties. * @return A <code>LinkedHashSet</code> of <code>OWLAnnotationProperty</code>s * ordered from the more general to the more precise. * * @see #getSubAnnotationPropertiesOf(OWLAnnotationProperty) * @see #getSubAnnotationPropertyReflexiveClosureOf(OWLAnnotationProperty) */ //TODO: DRY, it is almost the same code as getSubPropertyClosureOf public LinkedHashSet<OWLAnnotationProperty> getSubAnnotationPropertyClosureOf( OWLAnnotationProperty prop) { //try to get the sub-properties from the cache LinkedHashSet<OWLAnnotationProperty> subProps = this.subAnnotationPropertyCache.get(prop); if (subProps != null) { return subProps; } subProps = new LinkedHashSet<OWLAnnotationProperty>(); Stack<OWLAnnotationProperty> stack = new Stack<OWLAnnotationProperty>(); stack.add(prop); while (!stack.isEmpty()) { OWLAnnotationProperty nextProp = stack.pop(); Set<OWLAnnotationProperty> directSubs = this.getSubAnnotationPropertiesOf(nextProp); directSubs.removeAll(subProps); stack.addAll(directSubs); subProps.addAll(directSubs); } //put the sub-properties in cache this.subAnnotationPropertyCache.put(prop, subProps); return subProps; }
Example #10
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private Map<String, Object> renderAnnotationAxioms(Set<OWLAnnotationAssertionAxiom> annotations) { Map<String, Object> result = null; if (annotations != null && !annotations.isEmpty()) { for (OWLAnnotationAssertionAxiom ax : annotations) { OWLAnnotationProperty prop = ax.getProperty(); String literal = getLiteralValue(ax.getValue()); if (literal != null) { if (result == null) { result = new HashMap<String, Object>(); } result.put(prop.toStringID(), literal); } } } return result; }
Example #11
Source File: OntologyLoader.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
private Set<String> getAnnotation(OWLEntity entity, String property) { Set<String> annotations = new HashSet<>(); try { OWLAnnotationProperty owlAnnotationProperty = factory.getOWLAnnotationProperty(IRI.create(property)); for (OWLAnnotation annotation : entity.getAnnotations(ontology, owlAnnotationProperty)) { if (annotation.getValue() instanceof OWLLiteral) { OWLLiteral val = (OWLLiteral) annotation.getValue(); annotations.add(val.getLiteral()); } } } catch (Exception e) { throw new RuntimeException("Failed to get label for OWLClass " + entity); } return annotations; }
Example #12
Source File: Mooncat.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void removeDirectives() { // TODO decide: move the set of directives into a constant/static collection? Set<IRI> directivesIRIs = new HashSet<IRI>(); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_LogicalDefinitionViewRelation.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsEquivalent.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsGenusDifferentia.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsHasSubClass.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsIsA.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsRelationship.getIRI()); directivesIRIs.add(Obo2OWLVocabulary.IRI_OIO_treatXrefsAsReverseGenusDifferentia.getIRI()); OWLOntology o = graph.getSourceOntology(); for(OWLAnnotation ann : o.getAnnotations()) { final OWLAnnotationProperty property = ann.getProperty(); if (directivesIRIs.contains(property.getIRI())) { manager.applyChange(new RemoveOntologyAnnotation(o, ann)); } } }
Example #13
Source File: DescriptionTreeSimilarity.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * adds additional axioms specific to this method. * Creates a named LCS class equivalent to the generated expression * * @param id * @param result * @param axioms */ @Override protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) { OWLDataFactory df = graph.getDataFactory(); // declare a named class for the LCS and make this equivalent to the anonymous expression OWLClass namedLCS = df.getOWLClass(IRI.create(id+"_LCS")); axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), namedLCS.getIRI(), df.getOWLLiteral("LCS of "+simEngine.label(a)+" and "+simEngine.label(b)))); axioms.add(df.getOWLEquivalentClassesAxiom(namedLCS, lcs)); // link the similarity object to the named LCS OWLAnnotationProperty lcsp = df.getOWLAnnotationProperty(annotationIRI("has_least_common_subsumer")); axioms.add(df.getOWLAnnotationAssertionAxiom(lcsp, result.getIRI(), namedLCS.getIRI())); }
Example #14
Source File: SimpleOntology.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@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 #15
Source File: SimpleOntologyValues.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
/** * . */ public static OWLAnnotation owlapiAnnotation(Annotation anno) { // TODO: ??? Fix this. if (anno == null) { return null; } OWLAnnotationProperty owlAnnoProperty = owlapiAnnotationProperty(anno.getProperty()); Value value = anno.getValue(); if (value instanceof IRI) { org.semanticweb.owlapi.model.IRI iri = owlapiIRI((IRI) value); return new OWLAnnotationImpl(owlAnnoProperty, iri, Stream.empty()); } else if (value instanceof Literal) { OWLLiteral literal = owlapiLiteral((Literal) value); return new OWLAnnotationImpl(owlAnnoProperty, literal, Stream.empty()); } else if (value instanceof SimpleIndividual) { OWLIndividual individual = owlapiIndividual((SimpleIndividual) value); return new OWLAnnotationImpl(owlAnnoProperty, (OWLAnonymousIndividual) individual, Stream.empty()); } else { throw new MobiOntologyException("Invalid annotation value"); } }
Example #16
Source File: OntologyHelper.java From BioSolr with Apache License 2.0 | 6 votes |
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; }
Example #17
Source File: SimpleOntologyValuesTest.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testMobiAnnotation() throws Exception { OWLAnnotation owlAnno = mock(OWLAnnotation.class); OWLAnnotation owlAnno1 = mock(OWLAnnotation.class); OWLAnnotationProperty owlProperty = mock(OWLAnnotationProperty.class); AnnotationProperty property = mock(AnnotationProperty.class); org.semanticweb.owlapi.model.IRI value = mock(org.semanticweb.owlapi.model.IRI.class); IRI iri = mock(IRI.class); expect(owlAnno.getProperty()).andReturn(owlProperty).anyTimes(); expect(owlAnno.getValue()).andReturn(value).anyTimes(); mockStaticPartial(SimpleOntologyValues.class, "mobiAnnotationProperty", "mobiIRI"); expect(SimpleOntologyValues.mobiAnnotationProperty(owlProperty)).andReturn(property).anyTimes(); expect(SimpleOntologyValues.mobiIRI(value)).andReturn(iri).anyTimes(); replay(owlAnno, owlAnno1, owlProperty, property, value, iri, SimpleOntologyValues.class); }
Example #18
Source File: AbstractOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public OWLOntology cacheInformationContentInOntology() throws OWLOntologyCreationException, UnknownOWLClassException { OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager(); OWLDataFactory df = mgr.getOWLDataFactory(); OWLOntology o = mgr.createOntology(); OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create(icIRIString)); for (OWLClass c : getSourceOntology().getClassesInSignature()) { Double ic = getInformationContentForAttribute(c); if (ic != null) { mgr.addAxiom(o, df.getOWLAnnotationAssertionAxiom(p, c.getIRI(), df.getOWLLiteral(ic))); } } return o; }
Example #19
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Convenience method for adding an annotation assertion to the * ontology itself, taking a CURIE for the property and an Boolean literal. * * @param ontology the current ontology * @param propertyCURIE will be expanded to the full annotation * property IRI * @param value the literal value of the annotation * @return the annotation axiom */ protected static OWLAnnotation annotate(OWLOntology ontology, String propertyCURIE, IRI value) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); IRI iri = format.getIRI(propertyCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(iri); OWLAnnotation annotation = dataFactory.getOWLAnnotation( property, value); manager.applyChange( new AddOntologyAnnotation(ontology, annotation)); return annotation; }
Example #20
Source File: GraphExclusionTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testReflexive() throws Exception { OWLGraphWrapper g = getGraph("graph_exclusion_test.owl"); Config conf = g.getConfig(); OWLAnnotationProperty ap = (OWLAnnotationProperty) g.getOWLObjectByLabel("include me"); conf.includeAllWith(ap, g.getSourceOntology()); for (OWLQuantifiedProperty qp : conf.graphEdgeIncludeSet) { System.out.println(" INCLUDE="+qp); } OWLClass finger = g.getOWLClassByIdentifier("FOO:finger"); Set<OWLGraphEdge> edgesR = g.getCompleteEdgesBetween(finger, finger); System.out.println("RE="+edgesR); }
Example #21
Source File: EquivalenceSetMergeUtilTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testMerge() throws OWLOntologyCreationException, IOException, IncoherentOntologyException, OWLOntologyStorageException { ParserWrapper pw = new ParserWrapper(); OWLGraphWrapper g = pw.parseToOWLGraph(getResourceIRIString("equivalence-set-merge-util-test.obo")); OWLOntology ont1 = g.getSourceOntology(); ElkReasonerFactory rf = new ElkReasonerFactory(); OWLReasoner reasoner = rf.createReasoner(ont1); EquivalenceSetMergeUtil esmu = new EquivalenceSetMergeUtil(g, reasoner); esmu.setPrefixScore("A", 8.0); esmu.setPrefixScore("B", 6.0); esmu.setPrefixScore("C", 4.0); OWLAnnotationProperty lp = g.getDataFactory().getOWLAnnotationProperty( OWLRDFVocabulary.RDFS_LABEL.getIRI() ); esmu.setPropertyPrefixScore( lp, "C", 5.0); esmu.setPropertyPrefixScore( lp, "B", 4.0); esmu.setPropertyPrefixScore( lp, "A", 3.0); OWLAnnotationProperty dp = g.getDataFactory().getOWLAnnotationProperty( Obo2OWLVocabulary.IRI_IAO_0000115.getIRI() ); esmu.setPropertyPrefixScore( dp, "B", 5.0); esmu.setPropertyPrefixScore( dp, "A", 4.0); esmu.setPropertyPrefixScore( dp, "C", 3.0); esmu.setRemoveAxiomatizedXRefs(true); esmu.merge(); OWLDocumentFormat fmt = new OBODocumentFormat(); pw.saveOWL(g.getSourceOntology(), "target/esmu.owl"); //pw.setCheckOboDoc(false); pw.saveOWL(g.getSourceOntology(), fmt, "target/esmu.obo"); OWLOntology ont2 = pw.parseOWL(getResourceIRIString("equivalence-set-merge-util-expected.obo")); assertEquals(0, compare(ont1, ont2)); }
Example #22
Source File: RedundantAxiomTagger.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void tagRedundantAxioms(OWLReasoner reasoner) { OWLOntology ont = reasoner.getRootOntology(); OWLOntologyManager mgr = ont.getOWLOntologyManager(); OWLDataFactory df = mgr.getOWLDataFactory(); OWLAnnotationProperty anProp = df.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#source")); for (OWLSubClassOfAxiom ax : ont.getAxioms(AxiomType.SUBCLASS_OF)) { if (!ax.getSuperClass().isAnonymous()) { OWLClass supc = (OWLClass) ax.getSuperClass(); mgr.removeAxiom(ont, ax); reasoner.flush(); NodeSet<OWLClass> ancs = reasoner.getSuperClasses(ax.getSubClass(), false); //LOG.info(ax + " ANCS="+ancs); if (ancs.containsEntity( supc)) { String direct = "indirect"; if (reasoner.getSuperClasses(ax.getSubClass(), true).containsEntity( supc)) { direct = "direct"; } LOG.info("SCA = "+ax+" D="+direct); OWLAnnotation ann = df.getOWLAnnotation(anProp, df.getOWLLiteral(direct)); OWLAxiom newAxiom = changeAxiomAnnotations(ax, Collections.singleton(ann), df); mgr.addAxiom(ont, newAxiom); } else { // put it back mgr.addAxiom(ont, ax); } } } }
Example #23
Source File: Mooncat.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
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; }
Example #24
Source File: AbstractSimPreProcessor.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Note: does not flush * @param ces * @return classes */ public Set<OWLClass> materializeClassExpressions(Set<OWLClassExpression> ces) { LOG.info("Materializing class expressions: "+ces.size()); OWLAnnotationProperty rdfsLabel = getOWLDataFactory().getRDFSLabel(); Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>(); Set<OWLClass> newClasses = new HashSet<OWLClass>(); for (OWLClassExpression ce : ces) { if (ce instanceof OWLClass) { newClasses.add((OWLClass) ce); continue; } if (materializedClassExpressionMap.containsKey(ce)) { newClasses.add(materializedClassExpressionMap.get(ce)); continue; } OWLClass mc = getOWLDataFactory().getOWLClass(IRI.create("http://x.org#"+MD5(ce.toString()))); newAxioms.add(getOWLDataFactory().getOWLDeclarationAxiom(mc)); newAxioms.add(getOWLDataFactory().getOWLEquivalentClassesAxiom(mc, ce)); newAxioms.add( getOWLDataFactory().getOWLAnnotationAssertionAxiom(rdfsLabel, mc.getIRI(), getOWLDataFactory().getOWLLiteral(generateLabel(ce))) ); LOG.info(mc + " EQUIV_TO "+ce); materializedClassExpressionMap.put(ce, mc); newClasses.add(mc); } // some CEs will be identical, but they will be mapped to the same class. // we might be able to optimize by pre-filtering dupes addAxiomsToOutput(newAxioms, false); LOG.info("Materialized "+ces.size()+ " class expressions, axioms: "+newAxioms.size()+", new classes:"+newClasses.size()); return newClasses; }
Example #25
Source File: OWLGraphWrapperEdges.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void excludeAllWith(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()) { excludeProperty(p); } } } } }
Example #26
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create an annotation property and add it to the ontology. * * @param ontology the current ontology * @param iri the IRI for the annotation property * @return the annotation property */ protected static OWLAnnotationProperty createAnnotationProperty( OWLOntology ontology, IRI iri) { OWLDataFactory dataFactory = ontology.getOWLOntologyManager(). getOWLDataFactory(); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(iri); declare(ontology, property); return property; }
Example #27
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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 typeCURIE a CURIE string for the type of synonym * @param propertyCURIE a CURIE string for the property * @param value the string value of the synonym * @return the axiom */ protected static OWLAnnotationAssertionAxiom synonym( OWLOntology ontology, OWLEntity subject, String typeCURIE, String propertyCURIE, String value) { OWLDataFactory dataFactory = ontology.getOWLOntologyManager(). getOWLDataFactory(); IRI type = format.getIRI(typeCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty( format.getIRI(propertyCURIE)); OWLLiteral literal = dataFactory.getOWLLiteral(value); return synonym(ontology, subject, type, property, literal); }
Example #28
Source File: OWLGraphWrapper.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Set<ISynonym> getOBOSynonyms(OWLEntity e, Obo2OWLVocabulary vocabulary, OWLOntology ont) { OWLAnnotationProperty synonymProperty = getDataFactory().getOWLAnnotationProperty(vocabulary.getIRI()); Set<OWLAnnotation> anns = OwlHelper.getAnnotations(e, synonymProperty, ont); Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ont.getAnnotationAssertionAxioms(e.getIRI()); if (anns != null && !anns.isEmpty()) { Set<ISynonym> set = new HashSet<ISynonym>(); for (OWLAnnotation a : anns) { if (a.getValue() instanceof OWLLiteral) { OWLLiteral val = (OWLLiteral) a.getValue(); String label = val.getLiteral(); if (label != null && label.length() > 0) { String category = null; Set<String> xrefs = null; SynonymDetails details = getOBOSynonymDetails(annotationAssertionAxioms, val, synonymProperty); if (details != null) { category = details.category; xrefs = details.xrefs; } Synonym s = new Synonym(label, vocabulary.getMappedTag(), category, xrefs); set.add(s); } } } if (!set.isEmpty()) { return set; } } return null; }
Example #29
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the values of the subset tag for a given OWLObject * * @param c could OWLClass or OWLObjectProperty * @return subsets to which the OWLObject belongs */ // TODO - return set public List<String> getSubsets(OWLObject c) { //OWLAnnotationProperty lap = getAnnotationProperty(OboFormatTag.TAG_SUBSET.getTag()); OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_OIO_inSubset.getIRI()); return getAnnotationValues(c, lap); }
Example #30
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * It returns the value of the builtin tag * * @param c * @return boolean */ @Deprecated public boolean getBuiltin(OWLObject c) { OWLAnnotationProperty lap = getAnnotationProperty(OboFormatTag.TAG_BUILTIN.getTag()); String val = getAnnotationValue(c, lap); return val == null ? false: Boolean.valueOf(val); }