Java Code Examples for org.semanticweb.owlapi.model.OWLClass#isTopEntity()
The following examples show how to use
org.semanticweb.owlapi.model.OWLClass#isTopEntity() .
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: OWLGraphManipulator.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Filter from the ontologies all {@code OWLClass}es * present in {@code classesToKeep}, * and then update the {@code OWLGraphWrapper} container. * * @param classesToKeep a {@code Set} of {@code OWLClass}s * that are classes to be kept in the ontology. * @return A {@code Set} of {@code OWLClass}es representing the classes * actually removed as a result. */ public Set<OWLClass> filterClasses(Set<OWLClass> classesToKeep) { //now remove all classes not included in classesToKeep Set<OWLClass> classesRemoved = new HashSet<OWLClass>(); for (OWLOntology o : this.getOwlGraphWrapper().getAllOntologies()) { for (OWLClass iterateClass: o.getClassesInSignature()) { log.info(iterateClass); //don't delete OBO alt IDs nor owl:Nothing and owl:Thing if (this.getOwlGraphWrapper().isOboAltId(iterateClass) || iterateClass.isTopEntity() || iterateClass.isBottomEntity()) { continue; } if (!classesToKeep.contains(iterateClass) && this.removeClass(iterateClass)) { classesRemoved.add(iterateClass); } } } return classesRemoved; }
Example 2
Source File: GOReciprocalAnnotationRule.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GOReciprocalAnnotationRule(OWLGraphWrapper graph, TraversingEcoMapper eco) { this.graph = graph; evidences = eco.getAllValidEvidenceIds("IPI", true); OWLClass proteinBindingCls = graph.getOWLClassByIdentifier(PROTEIN_BINDING_GO_ID); if (proteinBindingCls == null) { throw new RuntimeException("No class found for identifier: "+PROTEIN_BINDING_GO_ID); } ElkReasonerFactory factory = new ElkReasonerFactory(); OWLReasoner reasoner = null; try { reasoner = factory.createReasoner(graph.getSourceOntology()); proteinBindingClasses = new HashSet<OWLClass>(); proteinBindingClasses.add(proteinBindingCls); Set<OWLClass> subClasses = reasoner.getSubClasses(proteinBindingCls, false).getFlattened(); for (OWLClass cls : subClasses) { if (!cls.isBottomEntity() && !cls.isTopEntity()) { proteinBindingClasses.add(cls); } } } finally { if (reasoner != null) { reasoner.dispose(); } } }
Example 3
Source File: GoIEPRestrictionsRule.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GoIEPRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) { this.message = MESSAGE; this.violationType = ViolationType.Warning; evidences = eco.getAllValidEvidenceIds("IEP", true); classSubSet = new HashSet<String>(); OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0008150"); OWLReasonerFactory factory = new ElkReasonerFactory(); OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology()); try { NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false); for(OWLClass cls : nodeSet.getFlattened()) { if (cls.isBottomEntity() || cls.isTopEntity()) { continue; } String oboId = graph.getIdentifier(cls); if (oboId != null) { classSubSet.add(oboId); } } } finally { reasoner.dispose(); } }
Example 4
Source File: GoMultipleTaxonRule.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GoMultipleTaxonRule(OWLGraphWrapper graph) { this.graph = graph; multiOrganismClasses = new HashSet<OWLClass>(); OWLClass mop = graph.getOWLClassByIdentifier(GO_ID_MULTI_ORGANISM_PROCESS); if (mop == null) { throw new RuntimeException("Could not find class for 'multi-organism process' id: "+GO_ID_MULTI_ORGANISM_PROCESS); } multiOrganismClasses.add(mop); ElkReasonerFactory factory = new ElkReasonerFactory(); OWLReasoner reasoner = null; try { reasoner = factory.createReasoner(graph.getSourceOntology()); Set<OWLClass> subClasses = reasoner.getSubClasses(mop, false).getFlattened(); for (OWLClass owlClass : subClasses) { if (owlClass.isBottomEntity() || owlClass.isTopEntity()) { continue; } multiOrganismClasses.add(owlClass); } } finally { if (reasoner != null) { reasoner.dispose(); } } }
Example 5
Source File: GoIPICatalyticActivityRestrictionsRule.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public GoIPICatalyticActivityRestrictionsRule(OWLGraphWrapper graph, TraversingEcoMapper eco) { this.message = MESSAGE; this.violationType = ViolationType.Warning; evidences = eco.getAllValidEvidenceIds("IPI", true); classSubSet = new HashSet<String>(); OWLClass rootClass = graph.getOWLClassByIdentifier("GO:0003824"); // catalytic activity OWLReasonerFactory factory = new ElkReasonerFactory(); OWLReasoner reasoner = factory.createReasoner(graph.getSourceOntology()); try { NodeSet<OWLClass> nodeSet = reasoner.getSubClasses(rootClass, false); for(OWLClass cls : nodeSet.getFlattened()) { if (cls.isBottomEntity() || cls.isTopEntity()) { continue; } String oboId = graph.getIdentifier(cls); if (oboId != null) { classSubSet.add(oboId); } } } finally { reasoner.dispose(); } }
Example 6
Source File: DLQueryTool.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Execute the DL query on the given ontology graph. Uses the factory to create * the {@link OWLReasoner} for an internal query ontology. * * @param queryObject * @param ontology * @param reasonerFactory * @return set of {@link OWLClass} which */ static Set<OWLClass> executeQuery(OWLClassExpression queryObject, OWLOntology ontology, OWLReasonerFactory reasonerFactory) { Set<OWLClass> subset = new HashSet<OWLClass>(); LOG.info("Create reasoner for query ontology."); // Create an instance of an OWL API reasoner OWLReasoner reasoner = reasonerFactory.createReasoner(ontology); try { LOG.info("Start evaluation for DL query subclass of: "+queryObject); NodeSet<OWLClass> node = reasoner.getSubClasses(queryObject, false); if (node != null) { Set<OWLClass> classes = node.getFlattened(); for (OWLClass owlClass : classes) { if (!owlClass.isBottomEntity() && !owlClass.isTopEntity()) { subset.add(owlClass); } } LOG.info("Number of found classes for dl query subclass of: "+classes.size()); } return subset; } finally { reasoner.dispose(); } }
Example 7
Source File: GCIUtil.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Generates trivial SVF axioms from existing GCIs * * <pre> * For each GCI of the form CX SubClassOf R some DX * for each C that is an inferred direct subclass of or equivalent to CX * for each D that is an inferred direct superclass of or equivalent to DX * add an axiom C SubClassOf R some D * </pre> * @param ontology * @param reasoner * @return axioms */ public static Set<OWLSubClassOfAxiom> getSubClassOfSomeValuesFromAxioms(OWLOntology ontology, OWLReasoner reasoner) { Set<OWLSubClassOfAxiom> axioms = new HashSet<OWLSubClassOfAxiom>(); OWLDataFactory df = ontology.getOWLOntologyManager().getOWLDataFactory(); for (OWLSubClassOfAxiom ax : ontology.getAxioms(AxiomType.SUBCLASS_OF)) { OWLClassExpression c = ax.getSubClass(); if (ax.getSuperClass() instanceof OWLObjectSomeValuesFrom) { OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ax.getSuperClass(); OWLObjectPropertyExpression p = svf.getProperty(); OWLClassExpression filler = svf.getFiller(); if (filler.isAnonymous() || c.isAnonymous()) { if (c.isBottomEntity()) continue; if (filler.isTopEntity()) continue; Set<OWLClass> childSet = reasoner.getEquivalentClasses(c).getEntities(); if (childSet.size() == 0) { childSet = reasoner.getSubClasses(c, true).getFlattened(); } for (OWLClass childClass : childSet) { if (childClass.isBottomEntity()) continue; Set<OWLClass> childClassSuperClasses = reasoner.getSuperClasses(childClass, false).getFlattened(); childClassSuperClasses.addAll(reasoner.getEquivalentClasses(childClass).getEntities()); Set<OWLClass> parentSet = reasoner.getEquivalentClasses(filler).getEntities(); if (parentSet.size() == 0) { parentSet = reasoner.getSuperClasses(filler, true).getFlattened(); } // TODO: remove additional redundancy (R some X) SubClassOf (R some Y) // Elk cannot test arbitrary entailments for (OWLClass parentClass : parentSet) { if (parentClass.isTopEntity()) continue; // do not assert C SubClassOf part-of some D, if C SubClassOf D is entailed if (childClassSuperClasses.contains(parentClass)) continue; axioms.add(df.getOWLSubClassOfAxiom(childClass, df.getOWLObjectSomeValuesFrom(p, parentClass))); } } } } } LOG.info("Inferred SVFs: "+axioms.size()); return axioms; }
Example 8
Source File: InferredParentRenderer.java From owltools with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void render(OWLClass c, OWLClass filler) { if (c.isBottomEntity()) return; if (c.isTopEntity()) return; OWLClassExpression cx = c; if (filler != null) { OWLObjectSomeValuesFrom svf = graph.getDataFactory().getOWLObjectSomeValuesFrom(gciProperty, filler); cx = graph.getDataFactory().getOWLObjectIntersectionOf(c, svf); } if (!reasoner.isSatisfiable(cx)) { LOG.info("Ignore unsat: "+cx+" // base= "+c); return; } print(getId(c)); sep(); print(graph.getLabel(c)); if (gciFillers.size() > 0) { if (filler != null) { sep(); print(getId(filler)); sep(); print(graph.getLabel(filler)); } else { sep(); print("-"); sep(); print("-"); } } for (OWLObjectProperty p : properties) { Set<OWLClass> parents = reasoner.getSuperClassesOver(cx, p, true); List<OWLClass> lparents = new ArrayList<OWLClass>(parents); List<String> l1 = new ArrayList<String>(); List<String> l2 = new ArrayList<String>(); for (OWLClass pc : lparents) { l1.add(getId(pc)); l2.add(graph.getLabel(pc)); } sep(); print(join(l1, "|")); sep(); print(join(l2, "|")); } print("\n"); }