Java Code Examples for org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom#getSubject()
The following examples show how to use
org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom#getSubject() .
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: 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 2
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 3
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 4
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 5
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; }