private void addBioEntity(OWLClass pr, OWLOntology lego, Bioentity bioentity) { Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(pr); if (declarationAxioms == null || declarationAxioms.isEmpty()) { // add class declaration and add label OWLOntologyManager m = lego.getOWLOntologyManager(); OWLDataFactory f = m.getOWLDataFactory(); Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); axioms.add(f.getOWLDeclarationAxiom(pr)); String label = bioentity.getSymbol()+" - "+bioentity.getFullName(); axioms.add(f.getOWLAnnotationAssertionAxiom(f.getRDFSLabel(), pr.getIRI(), f.getOWLLiteral(label))); m.addAxioms(lego, axioms); } }
public void visit(OWLDeclarationAxiom axiom) { // if (axiom.getEntity().isOWLClass()) { // OWLClass cls=(OWLClass)axiom.getEntity(); // if (!m_axioms.m_classes.contains(cls)) // m_axioms.m_classes.add(cls); // } // if (axiom.getEntity().isOWLObjectProperty()) { // OWLObjectProperty op=(OWLObjectProperty)axiom.getEntity(); // if (!m_axioms.m_objectProperties.contains(op)) // m_axioms.m_objectProperties.add(op); // } // if (axiom.getEntity().isOWLDataProperty()) { // OWLDataProperty dp=(OWLDataProperty)axiom.getEntity(); // if (!m_axioms.m_dataProperties.contains(dp)) // m_axioms.m_dataProperties.add(dp); // } }
@Override public Set<ComplexIntegerAxiom> visit(OWLDeclarationAxiom axiom) { Objects.requireNonNull(axiom); OWLEntity entity = axiom.getEntity(); if (entity.isOWLClass()) { return declare(entity.asOWLClass(), axiom.getAnnotations()); } else if (entity.isOWLObjectProperty()) { return declare(entity.asOWLObjectProperty(), axiom.getAnnotations()); } else if (entity.isOWLNamedIndividual()) { return declare(entity.asOWLNamedIndividual(), axiom.getAnnotations()); } else if (entity.isOWLDataProperty()) { return declare(entity.asOWLDataProperty(), axiom.getAnnotations()); } else if (entity.isOWLAnnotationProperty()) { // FIXME add annotation property return Collections.emptySet(); } else { throw TranslationException.newUnsupportedAxiomException(axiom); } }
/** * Extracts {@link PredicateVariableExtractor} rules. * * @param ot ontology * @return extracted rules */ @Override public List<Rule> extract(OWLOntology ot) { List<Rule> list = new ArrayList<>(); // list of predicates in ontology List<String> ps = new ArrayList<>(); ps.add(TOPOBJ); ps.add(TOPDATA); OWLEntity e; String op; // check all declarations for (OWLDeclarationAxiom a : ot.getAxioms(AxiomType.DECLARATION)) { e = a.getEntity(); if (e.isOWLObjectProperty()) { // if it is a object property declaration, add it to the list // and also add it as subproperty of owl:topObjectProperty op = getString(e.asOWLObjectProperty()); ps.add(op); list.add(new SubPropertyOf(op, TOPOBJ)); } else if (e.isOWLDataProperty()) { // if it is a data property declaration, add it to the list // and also add it as subproperty of owl:topDataProperty op = getString(e.asOWLDataProperty()); ps.add(op); list.add(new SubPropertyOf(op, TOPDATA)); } } list.add(new PredicateVariable(ps)); return list; }
protected Component prepareRenderer(Object value, boolean isSelected, boolean hasFocus) { renderingComponent.setOpaque(isSelected || opaque); if (value instanceof OWLEntity) { OWLEntity entity = (OWLEntity) value; OWLDeclarationAxiom declAx = getOWLModelManager().getOWLDataFactory().getOWLDeclarationAxiom(entity); if (getOWLModelManager().getActiveOntology().containsAxiom(declAx)) { ontology = getOWLModelManager().getActiveOntology(); } entity.accept(activeEntityVisitor); if (OWLUtilities.isDeprecated(getOWLModelManager(), entity)) { setStrikeThrough(true); } else { setStrikeThrough(false); } } prepareTextPane(getRendering(value), isSelected); if (isSelected) { renderingComponent.setBackground(SELECTION_BACKGROUND); textPane.setForeground(SELECTION_FOREGROUND); } else { renderingComponent.setBackground(componentBeingRendered.getBackground()); textPane.setForeground(componentBeingRendered.getForeground()); } final Icon icon = getIcon(value); iconLabel.setIcon(icon); if (icon != null) { iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), plainFontHeight)); } renderingComponent.revalidate(); return renderingComponent; }
private OWLAnnotationProperty getDcSourceProperty(OWLOntology lego, OWLDataFactory f) { OWLAnnotationProperty p = f.getOWLAnnotationProperty(DC_SOURCE); Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(p); if (declarationAxioms == null || declarationAxioms.isEmpty()) { OWLOntologyManager m = lego.getOWLOntologyManager(); m.addAxiom(lego, f.getOWLDeclarationAxiom(p)); } return p; }
public void visit(final OWLDeclarationAxiom axiom) { notSupported(axiom); // axiom.getEntity().accept(new OWLEntityVisitor() { // // public void visit(OWLAnnotationProperty property) { // ctx.annotationProperties.add(property); // } // // public void visit(OWLDatatype datatype) { // notSupported(axiom); // } // // public void visit(OWLNamedIndividual individual) { // notSupported(axiom); // } // // public void visit(OWLDataProperty property) { // ctx.dataProperties.add(property); // } // // public void visit(OWLObjectProperty property) { // ctx.objectProperties.add(property); // } // // public void visit(OWLClass cls) { // ctx.classes.add(cls); // } // }); }
@Override public T visit(OWLDeclarationAxiom axiom) { throw new IllegalArgumentException( OWLDeclarationAxiom.class.getSimpleName() + " cannot be converted to " + getTargetClass().getSimpleName()); }
public Set<OWLClass> extractClassesFromDeclarations(Set<OWLAxiom> axs) { Set<OWLClass> cs = new HashSet<OWLClass>(); for (OWLAxiom ax : axs) { if (ax instanceof OWLDeclarationAxiom) { OWLEntity e = ((OWLDeclarationAxiom)ax).getEntity(); if (e instanceof OWLClass) cs.add((OWLClass) e); } } return cs; }
private static Set<OWLAxiom> filter(Set<OWLAxiom> axioms, Diff diff) { if (diff.isFilterDeclarations) { return axioms.stream().filter(a -> !(a instanceof OWLDeclarationAxiom)). collect(Collectors.toSet()); } else { return axioms; } }
/** * Returns an OWLNamedIndividual with this IRI <b>if it has been declared</b> * in the source or support ontologies. Returns null otherwise. * * @param iri * @return {@link OWLNamedIndividual} */ public OWLNamedIndividual getOWLIndividual(IRI iri) { OWLNamedIndividual c = getDataFactory().getOWLNamedIndividual(iri); for (OWLOntology o : getAllOntologies()) { for (OWLDeclarationAxiom da : o.getDeclarationAxioms(c)) { if (da.getEntity() instanceof OWLNamedIndividual) { return (OWLNamedIndividual) da.getEntity(); } } } return null; }
/** * Convenience method for adding a declaration axiom to the ontology. * * @param ontology the current ontology * @param subject the entity for which the declaration will be added * @return the declaration axiom */ protected static OWLDeclarationAxiom declare(OWLOntology ontology, OWLEntity subject) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); OWLDeclarationAxiom axiom = dataFactory.getOWLDeclarationAxiom(subject); manager.addAxiom(ontology, axiom); return axiom; }
/** * Creates the owl axioms from concept version bi. * * @param setOfAxioms the set of axioms * @param factory the factory * @param pm the pm * @param conceptVersionBI the concept version bi * @return the OWL class * @throws Exception the exception */ private OWLClass createOWLAxiomsFromConceptVersionBI( Set<OWLAxiom> setOfAxioms, OWLDataFactory factory, PrefixManager pm, ConceptVersionBI conceptVersionBI) throws Exception { // Declaration OWLClass owlClass = factory.getOWLClass(":" + getSnomedConceptID(conceptVersionBI), pm); OWLDeclarationAxiom declarationAxiom = factory.getOWLDeclarationAxiom(owlClass); setOfAxioms.add(declarationAxiom); // Create annotation type axiom // Fully specified description OWLAnnotation labelAnnotation = factory.getOWLAnnotation(factory.getRDFSLabel(), factory.getOWLLiteral( conceptVersionBI.getFullySpecifiedDescription().getText(), conceptVersionBI.getFullySpecifiedDescription().getLang())); OWLAxiom labelAnnotationAxiom = factory.getOWLAnnotationAssertionAxiom(owlClass.getIRI(), labelAnnotation); setOfAxioms.add(labelAnnotationAxiom); // Preferred name OWLAnnotation preferredTerm = factory.getOWLAnnotation(factory.getOWLAnnotationProperty(IRI .create(snomedEnUsPreferredAnnotation)), factory.getOWLLiteral( conceptVersionBI.getPreferredDescription().getText(), conceptVersionBI.getPreferredDescription().getLang())); OWLAxiom preferredTermAx = factory .getOWLAnnotationAssertionAxiom(owlClass.getIRI(), preferredTerm); setOfAxioms.add(preferredTermAx); return owlClass; }
@Override public Void visit(OWLDeclarationAxiom axiom) { String iri = getIri(axiom); long node = getOrCreateNode(iri); addDefinedBy(node); if (axiom.getEntity() instanceof OWLClass) { graph.addLabel(node, OwlLabels.OWL_CLASS); } else if (axiom.getEntity() instanceof OWLNamedIndividual) { graph.addLabel(node, OwlLabels.OWL_NAMED_INDIVIDUAL); } else if (axiom.getEntity() instanceof OWLObjectProperty) { if (!graph.getLabels(node).contains(OwlLabels.OWL_OBJECT_PROPERTY)) { graph.addLabel(node, OwlLabels.OWL_OBJECT_PROPERTY); if (ontology.isPresent()) { OWLObjectProperty property = (OWLObjectProperty) axiom.getEntity(); graph.setNodeProperty(node, EdgeProperties.SYMMETRIC, !property.isAsymmetric(ontology.get())); graph.setNodeProperty(node, EdgeProperties.REFLEXIVE, property.isReflexive(ontology.get())); graph.setNodeProperty(node, EdgeProperties.TRANSITIVE, property.isTransitive(ontology.get())); } } } else if (axiom.getEntity() instanceof OWLDataProperty) { graph.setLabel(node, OwlLabels.OWL_DATA_PROPERTY); } else { // logger.warning("Unhandled declaration type " + axiom.getEntity().getClass().getName()); } return null; }
@Override public OWLDeclarationAxiom getAxiomWithoutAnnotations() { if (!isAnnotated()) { return this; } return new OWLDeclarationAxiomImpl(getEntity(), NO_ANNOTATIONS); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } // superclass is responsible for null, identity, owlaxiom type and // annotations if (!(obj instanceof OWLDeclarationAxiom)) { return false; } return ((OWLDeclarationAxiom) obj).getEntity().equals(entity); }
public static String formatAxiom(OWLAxiom a, OWLOntology ont) { if (a instanceof OWLSubPropertyChainOfAxiom) { // TODO: implement return a.toString(); } else if (a instanceof OWLSubObjectPropertyOfAxiom) { // TODO: implement return a.toString(); } else if (a instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sc = (OWLSubClassOfAxiom) a; return formatClassExpression(sc.getSubClass(), ont) + " \u2286 " + formatClassExpression(sc.getSuperClass(), ont); } else if (a instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom ec = (OWLEquivalentClassesAxiom) a; List<OWLClassExpression> ces = ec.getClassExpressionsAsList(); StringBuilder sb = new StringBuilder(); sb.append(formatClassExpression(ces.get(0), ont)); for (int i = 1; i < ces.size(); i++) { sb.append(" = "); sb.append(formatClassExpression(ces.get(i), ont)); } return sb.toString(); } else if (a instanceof OWLDeclarationAxiom) { OWLDeclarationAxiom da = (OWLDeclarationAxiom) a; OWLEntity ent = da.getEntity(); String name = (ent.isOWLClass()) ? getLabel(ent.asOWLClass(), ont) : ent.toString(); return "init(" + name + ")"; } else { return a.toString(); } }
public Boolean visit(OWLDeclarationAxiom axiom) { return Boolean.TRUE; }
public void visit(OWLDeclarationAxiom axiom) { }
@Override public OWLDeclarationAxiom visit(ElkDeclarationAxiom axiom) { return owlFactory_.getOWLDeclarationAxiom(convert(axiom.getEntity())); }
@SuppressWarnings("static-method") public ElkDeclarationAxiom convert( OWLDeclarationAxiom owlDeclarationAxiom) { return new ElkDeclarationAxiomWrap<OWLDeclarationAxiom>( owlDeclarationAxiom); }
@Override public ElkAxiom visit(OWLDeclarationAxiom owlDeclarationAxiom) { return CONVERTER.convert(owlDeclarationAxiom); }
@Override public void visit(OWLDeclarationAxiom axiom) { defaultVisit(axiom); }
private void tr(OWLDeclarationAxiom ax) { // do nothing: instances and tlrs declared fresh }
@Override public OWLAxiom visit(OWLDeclarationAxiom axiom) { return factory.getOWLDeclarationAxiom(axiom.getEntity(), annotations); }
@Override public void visit(OWLDeclarationAxiom axiom) { }
@Override public Boolean visit(OWLDeclarationAxiom axiom) { return true; }
@Override public Boolean visit(OWLDeclarationAxiom axiom) { return axiom.getEntity().isOWLClass() || axiom.getEntity().isOWLObjectProperty(); }
@Override public Boolean visit(OWLDeclarationAxiom axiom) { Objects.requireNonNull(axiom); return add(this.df.getOWLDeclarationAxiom(axiom.getEntity(), reg(axiom.getAnnotations()))); }
@Override public Boolean visit(OWLDeclarationAxiom axiom) { Objects.requireNonNull(axiom); return add(this.df.getOWLDeclarationAxiom(axiom.getEntity(), empty())); }
/** * Creates the owl property axioms from concept version bi. * * @param setOfAxioms the set of axioms * @param factory the factory * @param pm the pm * @param conceptVersionBI the concept version bi * @return the OWL object property * @throws Exception the exception */ private OWLObjectProperty createOWLPropertyAxiomsFromConceptVersionBI( Set<OWLAxiom> setOfAxioms, OWLDataFactory factory, PrefixManager pm, ConceptVersionBI conceptVersionBI) throws Exception { // Declaration OWLObjectProperty owlPropertyClass = factory.getOWLObjectProperty( ":" + getSnomedConceptID(conceptVersionBI), pm); OWLDeclarationAxiom declarationAxiom = factory.getOWLDeclarationAxiom(owlPropertyClass); setOfAxioms.add(declarationAxiom); // Create annotation type axiom // Fully specified description OWLAnnotation labelAnnotation = factory.getOWLAnnotation(factory.getRDFSLabel(), factory.getOWLLiteral( conceptVersionBI.getFullySpecifiedDescription().getText(), conceptVersionBI.getFullySpecifiedDescription().getLang())); OWLAxiom labelAnnotationAxiom = factory.getOWLAnnotationAssertionAxiom(owlPropertyClass.getIRI(), labelAnnotation); setOfAxioms.add(labelAnnotationAxiom); // Preferred name OWLAnnotation preferredTerm = factory.getOWLAnnotation(factory.getOWLAnnotationProperty(IRI .create(snomedEnUsPreferredAnnotation)), factory.getOWLLiteral( conceptVersionBI.getPreferredDescription().getText(), conceptVersionBI.getPreferredDescription().getLang())); OWLAxiom preferredTermAx = factory.getOWLAnnotationAssertionAxiom(owlPropertyClass.getIRI(), preferredTerm); setOfAxioms.add(preferredTermAx); // SubObjectPropertyOf // SubObjectPropertyOf(ObjectPropertyChain( // <http://snomed.info/id/363701004> <http://snomed.info/id/127489000> ) // <http://snomed.info/id/363701004>) for (RelationshipVersionBI<?> rel : conceptVersionBI .getRelationshipsOutgoingActiveIsa()) { if (rel.isStated()) { String sctid = getSnomedConceptID(OTFUtility.getConceptVersion(rel .getDestinationNid())); // Skip the root of the attributes tree if (!sctid.equals(snomedConceptAttributeModelConcept)) { OWLObjectProperty parent = factory.getOWLObjectProperty(":" + sctid, pm); setOfAxioms.add(factory.getOWLSubObjectPropertyOfAxiom( owlPropertyClass, parent)); } } } return owlPropertyClass; }
public static String getIri(OWLDeclarationAxiom expression) { return expression.getEntity().getIRI().toString(); }
@Override public void visit(OWLDeclarationAxiom axiom) { ignoreOwlAxiom("Declaration", axiom); }
@Override public void visit(OWLDeclarationAxiom axiom) { annotationAxiomsNotSupportedWarning(axiom); }