Java Code Examples for org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom#getValue()
The following examples show how to use
org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom#getValue() .
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: 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 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: 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 4
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; }
Example 5
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 6
Source File: AxiomCopier.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
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); }
Example 7
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 8
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 9
Source File: OldSimpleOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private Set<OWLClass> getVerbotenClasses() { if (verbotenClasses == null) { verbotenClasses = new HashSet<OWLClass>(); for (OWLClass c : sourceOntology.getClassesInSignature(Imports.INCLUDED)) { // TODO - don't hardcode this! if (c.getIRI().toString().startsWith("http://purl.obolibrary.org/obo/FMA_")) { // eliminate FMA classes that have no uberon equiv if (OwlHelper.getEquivalentClasses(c, sourceOntology).isEmpty()) { LOG.info("removing FMA class: "+c); verbotenClasses.add(c); continue; } } Set<OWLAnnotationAssertionAxiom> aaas = sourceOntology.getAnnotationAssertionAxioms(c.getIRI()); for (OWLAnnotationAssertionAxiom aaa : aaas) { String ap = aaa.getProperty().getIRI().toString(); OWLAnnotationValue v = aaa.getValue(); if (v instanceof OWLLiteral) { OWLLiteral lv = (OWLLiteral)v; } if (v instanceof IRI) { IRI iv = (IRI)v; if (ap.endsWith("inSubset")) { if (iv.toString().endsWith("upper_level")) { LOG.info("removing upper level class: "+c); verbotenClasses.add(c); } } } } } Set<OWLClass> veqs = new HashSet<OWLClass>(); for (OWLClass vc : verbotenClasses) { for (OWLClassExpression eqc : OwlHelper.getEquivalentClasses(vc, sourceOntology)) { if (eqc instanceof OWLClass) { LOG.info("removing equiv "+eqc+" "+vc); veqs.add((OWLClass) eqc); } } } verbotenClasses.addAll(veqs); } return verbotenClasses; }
Example 10
Source File: GraphOwlVisitor.java From SciGraph with Apache License 2.0 | 4 votes |
@Override public Void visit(OWLAnnotationAssertionAxiom axiom) { if ((axiom.getSubject() instanceof IRI) || (axiom.getSubject() instanceof OWLAnonymousIndividual)) { long subject = 0L; if (axiom.getSubject() instanceof IRI) { subject = getOrCreateNode(((IRI) axiom.getSubject()).toString()); } else if (axiom.getSubject() instanceof OWLAnonymousIndividual) { subject = getOrCreateNode(OwlApiUtils.getIri((OWLAnonymousIndividual) axiom.getSubject())); } String property = getIri(axiom.getProperty()).toString(); if (axiom.getValue() instanceof OWLLiteral) { Optional<Object> literal = OwlApiUtils.getTypedLiteralValue((OWLLiteral) (axiom.getValue())); if (literal.isPresent()) { graph.addNodeProperty(subject, property, literal.get()); if (mappedProperties.containsKey(property)) { graph.addNodeProperty(subject, mappedProperties.get(property), literal.get()); } } } else if ((axiom.getValue() instanceof IRI) || (axiom.getValue() instanceof OWLAnonymousIndividual)) { long object = 0L; if (axiom.getValue() instanceof IRI) { object = getOrCreateNode(((IRI) axiom.getValue()).toString()); } else if (axiom.getValue() instanceof OWLAnonymousIndividual) { object = getOrCreateNode(OwlApiUtils.getIri((OWLAnonymousIndividual) axiom.getValue())); } long assertion = getOrCreateRelationship(subject, object, RelationshipType.withName(property)); graph.setRelationshipProperty(assertion, CommonProperties.IRI, property); graph.setRelationshipProperty(assertion, CommonProperties.OWL_TYPE, OwlRelationships.OWL_ANNOTATION.name()); } else { logger.info("Ignoring assertion axiom: " + axiom); } } else { logger.info("Ignoring assertion axiom: " + axiom); } return null; }