Java Code Examples for org.semanticweb.owlapi.model.OWLDataFactory#getOWLAnnotationProperty()
The following examples show how to use
org.semanticweb.owlapi.model.OWLDataFactory#getOWLAnnotationProperty() .
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: OGWSubAnnotationTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Load the ontology <code>/graph/subannotprops.owl</code> into {@link #wrapper}, * and also loads the {@code OWLAnnotationProperty}s needed. */ @BeforeClass public static void loadTestOntology() throws OWLOntologyCreationException, OBOFormatParserException, IOException { ParserWrapper parserWrapper = new ParserWrapper(); OWLOntology ont = parserWrapper.parse(OGWSubAnnotationTest.class.getResource( "/graph/subannotprops.owl").getFile()); wrapper = new OWLGraphWrapper(ont); OWLDataFactory f = wrapper.getManager().getOWLDataFactory(); subsetProp = f.getOWLAnnotationProperty( IRI.create("http://www.geneontology.org/formats/oboInOwl#SubsetProperty")); groupProp = f.getOWLAnnotationProperty( IRI.create("http://purl.obolibrary.org/obo/uberon/core#grouping_class")); fake1Prop = f.getOWLAnnotationProperty( IRI.create("http://purl.obolibrary.org/obo/uberon/core#fake1")); fake2Prop = f.getOWLAnnotationProperty( IRI.create("http://purl.obolibrary.org/obo/uberon/core#fake2")); lonelyProp = f.getOWLAnnotationProperty( IRI.create("http://purl.obolibrary.org/obo/uberon/core#lonely")); }
Example 2
Source File: NCBI2OWLTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 3
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 4
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 5
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 6
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 7
Source File: AxiomCopier.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * make annotations to be placed on axiom * * @param df * @param srcClass * @param isXrefAnn if true use hasDbXref not source * @return annotations */ private Set<? extends OWLAnnotation> anns(OWLDataFactory df, OWLClass srcClass, boolean isXrefAnn) { String iri = srcClass.getIRI().toString(); iri = iri.replaceAll(".*/", ""); iri = iri.replaceAll("_", ":"); String pn = "source"; if (isXrefAnn) { pn = "hasDbXref"; } OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#"+pn)); OWLAnnotation ann = df.getOWLAnnotation(p, df.getOWLLiteral(iri)); return Collections.singleton(ann); }
Example 8
Source File: AxiomAnnotationTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Append xref annotations onto an existing axiom * * @param axiom * @param xrefs * @param ontology * @return */ public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) { // filter existing Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations()); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final OWLDataFactory factory = manager.getOWLDataFactory(); for (String x : xrefs) { OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref")); OWLLiteral v = factory.getOWLLiteral(x); newAnnotations.add(factory.getOWLAnnotation(p, v)); } final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology); return newAxiom; }
Example 9
Source File: OWLGraphWrapperBasic.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addCommentToOntology(OWLOntology ont, String cmt) { OWLDataFactory df = getDataFactory(); OWLAnnotationProperty p = df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI()); OWLLiteral v = df.getOWLLiteral(cmt); OWLAnnotation ann = df.getOWLAnnotation(p, v); AddOntologyAnnotation addAnn = new AddOntologyAnnotation(ont, ann); getManager().applyChange(addAnn); }
Example 10
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public ModelAnnotationSolrDocumentLoader(SolrServer server, OWLOntology model, OWLReasoner r, String modelUrl, Set<String> modelFilter, boolean skipDeprecatedModels, boolean skipTemplateModels) { super(server); this.model = model; this.reasoner = r; this.requiredModelStates = modelFilter; this.skipDeprecatedModels = skipDeprecatedModels; this.skipTemplateModels = skipTemplateModels; this.graph = new OWLGraphWrapper(model); this.modelUrl = modelUrl; current_doc_number = 0; OWLDataFactory df = graph.getDataFactory(); partOf = OBOUpperVocabulary.BFO_part_of.getObjectProperty(df); occursIn = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(df); defaultClosureRelations = new ArrayList<String>(1); defaultClosureRelations.add(graph.getIdentifier(partOf)); enabledBy = OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(df); title = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/title")); source = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/source")); contributor = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/contributor")); date = df.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/date")); evidence = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence")); modelState = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/modelstate")); comment = df.getRDFSComment(); with = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence-with")); layoutHintX = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/hint/layout/x")); layoutHintY = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/hint/layout/y")); templatestate = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/templatestate")); displayLabelProp = df.getRDFSLabel(); shortIdProp = df.getOWLAnnotationProperty(IRI.create(Obo2OWLConstants.OIOVOCAB_IRI_PREFIX+"id")); jsonProp = df.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/json-model")); bpSet = getAspect(graph, "biological_process"); }
Example 11
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 12
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 13
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, String value) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); IRI iri = format.getIRI(propertyCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(iri); OWLLiteral literal = dataFactory.getOWLLiteral(value); OWLAnnotation annotation = dataFactory.getOWLAnnotation( property, literal); manager.applyChange( new AddOntologyAnnotation(ontology, annotation)); return annotation; }
Example 14
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 15
Source File: ConjunctiveSetInformationContentRatioSimilarity.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void translateResultsToOWLAxioms(String id, OWLNamedIndividual result, Set<OWLAxiom> axioms) { OWLDataFactory df = simEngine.getGraph().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, getLCS())); // 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 16
Source File: Similarity.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
public Set<OWLAxiom> translateResultsToOWLAxioms() { System.out.println("TRANSLATING TO OWL AXIOM:"+this); OWLGraphWrapper graph = simEngine.getGraph(); Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); OWLDataFactory df = graph.getDataFactory(); if (!(a instanceof OWLNamedObject)) { System.err.println(a+ "not named - cant write OWL results"); return axioms; } if (!(b instanceof OWLNamedObject)) { System.err.println(b+ "not named - cant write OWL results"); return axioms; } IRI ia = ((OWLNamedObject) a).getIRI(); IRI ib = ((OWLNamedObject) b).getIRI(); String[] toksA = splitIRI(ia); String[] toksB = splitIRI(ib); String id = toksA[0]+toksA[1]+"-vs-"+toksB[1]; persistentIRI = IRI.create(id); // each similarity is stored as an individual of class similarity_relationship OWLNamedIndividual result = df.getOWLNamedIndividual(persistentIRI); OWLClass ac = df.getOWLClass(annotationIRI("similarity_relationship")); axioms.add(df.getOWLClassAssertionAxiom(ac, result)); axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), result.getIRI(), df.getOWLLiteral("Similarity relationship between "+simEngine.label(a)+" and "+simEngine.label(b)))); // each object in the pair is connected to the similarity OWLAnnotationProperty p = df.getOWLAnnotationProperty(annotationIRI("has_similarity_relationship")); axioms.add(df.getOWLAnnotationAssertionAxiom(p, ((OWLNamedObject) a).getIRI(), result.getIRI())); axioms.add(df.getOWLAnnotationAssertionAxiom(p, ((OWLNamedObject) b).getIRI(), result.getIRI())); // every similarity has a score OWLAnnotationProperty sp = df.getOWLAnnotationProperty(annotationIRI("has_score")); axioms.add(df.getOWLAnnotationAssertionAxiom(sp, result.getIRI(), df.getOWLLiteral(score))); translateResultsToOWLAxioms(id, result, axioms); return axioms; }
Example 17
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Convenience method for adding an annotation assertion to the * ontology, taking a CURIE for the property. * * @param ontology the current ontology * @param subject the subject of the annotation * @param propertyCURIE will be expanded to the full annotation * property IRI * @param value the annotation value * @return the annotation axiom */ protected static OWLAnnotationAssertionAxiom annotate( OWLOntology ontology, OWLEntity subject, String propertyCURIE, OWLAnnotationValue value) { OWLDataFactory dataFactory = ontology.getOWLOntologyManager(). getOWLDataFactory(); IRI iri = format.getIRI(propertyCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(iri); return annotate(ontology, subject, property, value); }
Example 18
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Convenience method to get the first string literal of an * annotation property. * * @param ontology the current ontology * @param subject the subject * @param propertyIRI the property IRI * @return null or the literal content */ protected static String getFirstLiteral(OWLOntology ontology, OWLEntity subject, IRI propertyIRI) { OWLDataFactory dataFactory = ontology.getOWLOntologyManager(). getOWLDataFactory(); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(propertyIRI); return getFirstLiteral(ontology, subject, property); }