org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom.
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: 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 #2
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 #3
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 #4
Source File: TableToAxiomConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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); } } } } } }
Example #5
Source File: Mooncat.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #6
Source File: MarkdownRenderer.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void renderAnnotationAxioms(String tag, IRI piri, Set<OWLAnnotationAssertionAxiom> annotationAxioms) { List<String> vs = new ArrayList<String>(); Set<OWLAnnotationAssertionAxiom> consumed = new HashSet<OWLAnnotationAssertionAxiom>(); for (OWLAnnotationAssertionAxiom aaa : annotationAxioms) { if (aaa.getProperty().getIRI().equals(piri)) { StringBuffer v = new StringBuffer(generateText(aaa.getValue())); if (aaa.getAnnotations().size() > 0) { List<String> avs = new ArrayList<String>(); for (OWLAnnotation ann : aaa.getAnnotations()) { avs.add(generateText(ann)); } Collections.sort(avs); v.append(" [ "+StringUtils.join(avs, ", ")+" ]"); } vs.add(v.toString()); consumed.add(aaa); } } annotationAxioms.removeAll(consumed); renderTagValues(tag, vs); }
Example #7
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 #8
Source File: NCBI2OWLTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void testSpecies(OWLOntology ontology) { IRI iri = IRI.create("http://purl.obolibrary.org/obo/NCBITaxon_species"); OWLDataFactory df = ontology.getOWLOntologyManager(). getOWLDataFactory(); OWLClass taxon = df.getOWLClass(iri); assertTrue("Species class in signature", ontology.containsClassInSignature(iri)); // Check axioms Set<OWLClassAxiom> axioms = ontology.getAxioms(taxon, Imports.EXCLUDED); assertEquals("Count class axioms", 1, axioms.size()); assertEquals("SubClassOf(<http://purl.obolibrary.org/obo/NCBITaxon_species> <http://purl.obolibrary.org/obo/NCBITaxon#_taxonomic_rank>)", axioms.toArray()[0].toString()); // Check annotations List<String> values = new ArrayList<String>(); values.add("AnnotationAssertion(<http://www.geneontology.org/formats/oboInOwl#hasOBONamespace> <http://purl.obolibrary.org/obo/NCBITaxon_species> \"ncbi_taxonomy\"^^xsd:string)"); values.add("AnnotationAssertion(rdfs:label <http://purl.obolibrary.org/obo/NCBITaxon_species> \"species\"^^xsd:string)"); Set<OWLAnnotationAssertionAxiom> annotations = ontology.getAnnotationAssertionAxioms(iri); assertEquals("Count annotations for Species", 2, annotations.size()); checkAnnotations(annotations, values); }
Example #9
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 #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: MarkdownRenderer.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void renderControlledAnnotations(OWLNamedObject c) { Set<OWLAnnotationAssertionAxiom> annotationAxioms = ontology.getAnnotationAssertionAxioms(c.getIRI()); renderAnnotationAxiom("Label", OWLRDFVocabulary.RDFS_LABEL.getIRI(), annotationAxioms); renderAnnotationAxiom("Definition", Obo2OWLVocabulary.IRI_IAO_0000115.getIRI(), annotationAxioms); renderAnnotationAxiom("Comment", OWLRDFVocabulary.RDFS_COMMENT.getIRI(), annotationAxioms); renderSection("Synonyms"); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_hasExactSynonym.getIRI(), annotationAxioms); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_hasBroadSynonym.getIRI(), annotationAxioms); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_hasNarrowSynonym.getIRI(), annotationAxioms); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_hasRelatedSynonym.getIRI(), annotationAxioms); renderSection("Cross-references"); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_hasDbXref.getIRI(), annotationAxioms); renderSection("Subsets"); renderAnnotationAxioms("", Obo2OWLVocabulary.IRI_OIO_inSubset.getIRI(), annotationAxioms); }
Example #12
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Get the definition xrefs (IAO_0000115) * * @param c * @return list of definition xrefs */ public List<String> getDefXref(OWLObject c){ OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115.getIRI()); OWLAnnotationProperty xap = getAnnotationProperty(OboFormatTag.TAG_XREF.getTag()); if (c instanceof OWLEntity) { List<String> list = new ArrayList<String>(); for (OWLOntology ont : getAllOntologies()) { Set<OWLAnnotationAssertionAxiom> axioms = ont.getAnnotationAssertionAxioms(((OWLEntity) c).getIRI()); for (OWLAnnotationAssertionAxiom axiom :axioms){ if(lap.equals(axiom.getProperty())){ for(OWLAnnotation annotation: axiom.getAnnotations(xap)){ OWLAnnotationValue value = annotation.getValue(); if(value instanceof OWLLiteral){ list.add(((OWLLiteral)value).getLiteral()); } } } } } return list; } else { return null; } }
Example #13
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public boolean isOboAltId(OWLEntity e) { Set<OWLAnnotationAssertionAxiom> axioms = new HashSet<>(); for(OWLOntology ont : getAllOntologies()) { axioms.addAll(ont.getAnnotationAssertionAxioms(e.getIRI())); } return isOboAltId(axioms); }
Example #14
Source File: AbstractElkObjectConverter.java From elk-reasoner with Apache License 2.0 | 5 votes |
@Override public OWLAnnotationAssertionAxiom visit( ElkAnnotationAssertionAxiom axiom) { return owlFactory_.getOWLAnnotationAssertionAxiom( convert(axiom.getProperty()), convert(axiom.getSubject()), convert(axiom.getValue())); }
Example #15
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Find the corresponding {@link OWLObject}s for a given set of OBO-style alternate identifiers. * <p> * WARNING: This methods scans all object annotations in all ontologies. * This is an expensive method. * <p> * Consider loading all altId-mappings using {@link #getAllOWLObjectsByAltId()}. * * @param altIds * @return map of altId to OWLObject (never null) * @see #getAllOWLObjectsByAltId() */ public Map<String, OWLObject> getOWLObjectsByAltId(Set<String> altIds) { 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(); if (altIds.contains(altId)) { OWLAnnotationSubject subject = aa.getSubject(); if (subject instanceof IRI) { OWLObject obj = getOWLObject((IRI) subject); if (obj != null) { results.put(altId, obj); } } } } } } return results; }
Example #16
Source File: OWLGraphWrapperBasic.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void mergeOntology(OWLOntology extOnt, LabelPolicy labelPolicy) throws OWLOntologyCreationException { OWLOntologyManager manager = getManager(); LOG.info("Merging "+extOnt+" policy: "+labelPolicy); for (OWLAxiom axiom : extOnt.getAxioms()) { if (labelPolicy != LabelPolicy.ALLOW_DUPLICATES) { if (axiom instanceof OWLAnnotationAssertionAxiom) { OWLAnnotationAssertionAxiom aa = (OWLAnnotationAssertionAxiom)axiom; if (aa.getProperty().isLabel()) { OWLAnnotationSubject subj = aa.getSubject(); if (subj instanceof IRI) { Optional<OWLLiteral> label = null; for (OWLAnnotationAssertionAxiom a1 : sourceOntology.getAnnotationAssertionAxioms(subj)) { if (a1.getProperty().isLabel()) { label = a1.getValue().asLiteral(); } } if (label != null && label.isPresent()) { if (labelPolicy == LabelPolicy.PRESERVE_SOURCE) { LOG.info("Preserving existing label:" +subj+" "+label+" // ditching: "+axiom); continue; } if (labelPolicy == LabelPolicy.PRESERVE_EXT) { LOG.info("Replacing:" +subj+" "+label+" with: "+axiom); LOG.error("NOT IMPLEMENTED"); } } } } } } manager.applyChange(new AddAxiom(sourceOntology, axiom)); } for (OWLImportsDeclaration oid: extOnt.getImportsDeclarations()) { manager.applyChange(new AddImport(sourceOntology, oid)); } addCommentToOntology(sourceOntology, "Includes "+summarizeOntology(extOnt)); }
Example #17
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 #18
Source File: OWLView.java From relex with Apache License 2.0 | 5 votes |
/** * Print out RelEx relations. All relations shown * in a binary form. * * Example: * _subj(throw, John) * _obj(throw, ball) * tense(throw, past) * definite-FLAG(ball, T) * noun_number(ball, singular) */ public void printRelations(ParsedSentence parse, String sentence, int sentence_id, String ontologyname) { try { sent = sentence; //Add the sentence to Sentence Class this.sentence_id = sentence_id; sentenceInd = factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#" + "sentence_" + sentence_id)); //OWLAnnotationProperty p = new OWLAnnotationPropertyImpl(IRI.create(sentence)); //OWLAnnotation label = factory.getOWLAnnotation(sentence); OWLOntologyFormat ontologyFormat = manager.getOntologyFormat(ontology); OWLAnnotation label = (OWLAnnotation) factory.getOWLAnnotationProperty(sentence, (PrefixManager) ontologyFormat); OWLClassAssertionAxiom sentClass = factory.getOWLClassAssertionAxiom(this.sentence,sentenceInd); OWLAnnotationAssertionAxiom labelClass = factory.getOWLAnnotationAssertionAxiom((OWLAnnotationSubject) sentClass, label); manager.applyChange(new AddAxiom(ontology, sentClass)); manager.applyChange(new AddAxiom(ontology, labelClass)); printRelations(parse, null); } catch (OWLOntologyChangeException ex) { Logger.getLogger(OWLView.class.getName()).log(Level.SEVERE, null, ex); } }
Example #19
Source File: NCBI2OWLTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void checkAnnotations(Set<OWLAnnotationAssertionAxiom> axioms, List<String> values) { List<String> results = new ArrayList<String>(); for (OWLAnnotationAssertionAxiom axiom : axioms) { String string = axiom.toString(); results.add(string); } assertEquals("Compare sizes", values.size(), results.size()); java.util.Collections.sort(values); java.util.Collections.sort(results); for (int i=0; i < results.size(); i++) { assertEquals("Check Annotation " + i, values.get(i), results.get(i)); } }
Example #20
Source File: OWLToolsTestBasics.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static boolean ignore(OWLAxiom a) { if (a instanceof OWLAnnotationAssertionAxiom) { if (((OWLAnnotationAssertionAxiom)a).getProperty().getIRI(). equals(IRI.create("http://www.geneontology.org/formats/oboInOwl#id"))) { return true; } } return false; }
Example #21
Source File: MarkdownRenderer.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private String getLabel(OWLNamedObject ob) { String label = null; for (OWLAnnotationAssertionAxiom aaa : ontology.getAnnotationAssertionAxioms(ob.getIRI())) { if (aaa.getProperty().isLabel()) { label = generateText(aaa.getValue()); break; } } return label; }
Example #22
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. * * @param ontology the current ontology * @param subject the subject of the annotation * @param property the annotation property * @param value the annotation value * @return the annotation axiom */ protected static OWLAnnotationAssertionAxiom annotate( OWLOntology ontology, OWLEntity subject, OWLAnnotationProperty property, OWLAnnotationValue value) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); OWLAnnotationAssertionAxiom axiom = dataFactory.getOWLAnnotationAssertionAxiom( property, subject.getIRI(), value); manager.addAxiom(ontology, axiom); return axiom; }
Example #23
Source File: NCBI2OWLTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void testActinobacteria(OWLOntology ontology) { String curie = "ncbi:201174"; IRI iri = OWLConverter.format.getIRI(curie); OWLDataFactory df = ontology.getOWLOntologyManager(). getOWLDataFactory(); OWLClass taxon = df.getOWLClass(iri); assertTrue("Actinobacteria class in signature", ontology.containsClassInSignature(iri)); // Check axioms Set<OWLClassAxiom> axioms = ontology.getAxioms(taxon, Imports.EXCLUDED); assertEquals("Count class axioms for Actinobacteria", 1, axioms.size()); assertEquals("SubClassOf(<http://purl.obolibrary.org/obo/NCBITaxon_201174> <http://purl.obolibrary.org/obo/NCBITaxon_2>)", axioms.toArray()[0].toString()); // Check annotations List<String> values = new ArrayList<String>(); values.add(expandAnnotation(curie, "ncbitaxon:has_rank", OWLConverter.format.getIRI("ncbi:phylum"))); values.add(expandAnnotation(curie, "oio:hasOBONamespace", "ncbi_taxonomy")); values.add(expandAnnotation(curie, "oio:hasDbXref", "GC_ID:11")); values.add(expandLabel(curie, "rdfs:label", "Actinobacteria [NCBITaxon:201174]")); values.add(expandSynonym(curie, "ncbitaxon:scientific_name", "oio:hasExactSynonym", "Actinobacteria")); values.add(expandSynonym(curie, "ncbitaxon:synonym", "oio:hasRelatedSynonym", "'Actinobacteria'")); values.add(expandSynonym(curie, "ncbitaxon:synonym", "oio:hasRelatedSynonym", "not Actinobacteria Cavalier-Smith 2002")); values.add(expandSynonym(curie, "ncbitaxon:blast_name", "oio:hasRelatedSynonym", "actinobacteria")); Set<OWLAnnotationAssertionAxiom> annotations = ontology.getAnnotationAssertionAxioms(iri); assertEquals("Count annotations for Actinobacteria", values.size(), annotations.size()); checkAnnotations(annotations, values); }
Example #24
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 #25
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Convenience method to get the first string literal of an * annotation property. * * @param ontology the current ontology * @param taxon the subject * @param property the property * @return null or the label content */ protected static String getFirstLiteral(OWLOntology ontology, OWLEntity taxon, OWLAnnotationProperty property) { Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAnnotationAssertionAxioms(taxon.getIRI()); for (OWLAnnotationAssertionAxiom axiom : axioms) { if (property.equals(axiom.getProperty())) { OWLAnnotationValue value = axiom.getValue(); if (value instanceof OWLLiteral) { OWLLiteral literal = (OWLLiteral)value; return literal.getLiteral(); } } } return null; }
Example #26
Source File: NCBI2OWLTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void testBacteria(OWLOntology ontology) { String curie = "ncbi:2"; IRI iri = OWLConverter.format.getIRI(curie); OWLDataFactory df = ontology.getOWLOntologyManager(). getOWLDataFactory(); OWLClass taxon = df.getOWLClass(iri); assertTrue("Bacteria class in signature", ontology.containsClassInSignature(iri)); // Check axioms Set<OWLClassAxiom> axioms = ontology.getAxioms(taxon, Imports.EXCLUDED); assertEquals("Count class axioms for Bacteria", 1, axioms.size()); assertEquals("SubClassOf(<http://purl.obolibrary.org/obo/NCBITaxon_2> <http://purl.obolibrary.org/obo/NCBITaxon_131567>)", axioms.toArray()[0].toString()); // Check annotations List<String> values = new ArrayList<String>(); values.add(expandAnnotation(curie, "ncbitaxon:has_rank", OWLConverter.format.getIRI("ncbi:superkingdom"))); values.add(expandAnnotation(curie, "oio:hasOBONamespace", "ncbi_taxonomy")); values.add(expandAnnotation(curie, "oio:hasDbXref", "GC_ID:11")); values.add(expandLabel(curie, "rdfs:label", "Bacteria")); values.add(expandSynonym(curie, "ncbitaxon:genbank_common_name", "oio:hasExactSynonym", "eubacteria")); values.add(expandSynonym(curie, "ncbitaxon:synonym", "oio:hasRelatedSynonym", "not Bacteria Haeckel 1894")); values.add(expandSynonym(curie, "ncbitaxon:in_part", "oio:hasRelatedSynonym", "Prokaryota")); values.add(expandSynonym(curie, "ncbitaxon:in_part", "oio:hasRelatedSynonym", "Monera")); values.add(expandSynonym(curie, "ncbitaxon:in_part", "oio:hasRelatedSynonym", "Procaryotae")); values.add(expandSynonym(curie, "ncbitaxon:in_part", "oio:hasRelatedSynonym", "Prokaryotae")); values.add(expandSynonym(curie, "ncbitaxon:blast_name", "oio:hasRelatedSynonym", "eubacteria")); Set<OWLAnnotationAssertionAxiom> annotations = ontology.getAnnotationAssertionAxioms(iri); assertEquals("Count annotations for Bacteria", values.size(), annotations.size()); checkAnnotations(annotations, values); }
Example #27
Source File: Mooncat.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Check, if the named object has the annotation property IAO:0000412, * declaring the object as imported. * * @param named * @param ontology * @return true if the item has the annotation property IAO:0000412 */ public static boolean isImportMarkedEntity(OWLNamedObject named, OWLOntology ontology) { for (OWLAnnotationAssertionAxiom axiom : ontology.getAnnotationAssertionAxioms(named.getIRI())) { OWLAnnotationProperty property = axiom.getProperty(); if (importedMarkerIRI.equals(property.getIRI())) { return true; } } return false; }
Example #28
Source File: AbstractOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void setInformationContentFromOntology(OWLOntology o) { OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager(); OWLDataFactory df = mgr.getOWLDataFactory(); clearInformationContentCache(); for (OWLAnnotationAssertionAxiom ax : o.getAxioms(AxiomType.ANNOTATION_ASSERTION)) { if (ax.getProperty().getIRI().toString().equals(icIRIString)) { OWLLiteral lit = (OWLLiteral) ax.getValue(); OWLClass c = df.getOWLClass((IRI) ax.getSubject()); Double v = lit.parseDouble(); setInformtionContectForAttribute(c, v); } } assignDefaultInformationContentForAllClasses(); }
Example #29
Source File: PhenoSimHQEPreProcessor.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void expandInheresInPartOf() { LOG.info("Expanding IPO; axioms before="+outputOntology.getAxiomCount()); IRI ipoIRI = getIRIViaOBOSuffix(INHERES_IN_PART_OF); OWLAnnotationProperty eap = getOWLDataFactory().getOWLAnnotationProperty(IRI.create("http://purl.obolibrary.org/obo/IAO_0000424")); OWLAnnotationProperty aap = getOWLDataFactory().getOWLAnnotationProperty(IRI.create("http://purl.obolibrary.org/obo/IAO_0000425")); Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>(); for (OWLAnnotationAssertionAxiom ax : outputOntology.getAxioms(AxiomType.ANNOTATION_ASSERTION)) { if (ax.getProperty().equals(eap) || ax.getProperty().equals(aap)) { rmAxioms.add(ax); } } LOG.info("Clearing old expansions: "+rmAxioms.size()); getOWLOntologyManager().removeAxioms(outputOntology, rmAxioms); OWLAnnotationAssertionAxiom aaa = getOWLDataFactory().getOWLAnnotationAssertionAxiom(eap, ipoIRI, getOWLDataFactory().getOWLLiteral("BFO_0000052 some (BFO_0000050 some ?Y)")); addAxiomToOutput(aaa, false); MacroExpansionVisitor mev; mev = new MacroExpansionVisitor(outputOntology); mev.expandAll(); flush(); //mev.expandAll(); LOG.info("Expanded IPO; axioms after="+outputOntology.getAxiomCount()); }
Example #30
Source File: SimEngine.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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; }