Java 类org.semanticweb.owlapi.model.AxiomType 实例源码

项目:DL-Learner-Protege-Plugin    文件:ActionHandler.java   
@Override
public void done() {
    if(!isCancelled()){
        // stop timer
        if(timer != null) {
            timer.cancel();
        }

        // show results
        if(view.getAxiomType().equals(AxiomType.EQUIVALENT_CLASSES) || view.getAxiomType().equals(AxiomType.SUBCLASS_OF)) {
            List<EvaluatedDescriptionClass> result = Manager.getInstance().getCurrentlyLearnedDescriptions();
            updateList(result);
        }

        // show that leaning has been finished
        view.setLearningFinished();
        setProgress(0);
    }
    ProtegeApplication.getBackgroundTaskManager().endTask(learningTask);
}
项目:owltools    文件:OWLHandler.java   
@Deprecated
public void deleteFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException {
    if (isHelp()) {
        info("generates ClassAssertion");
        return;
    }
    OWLOntology ont = resolveOntology(Param.ontology);
    OWLIndividual i = resolveIndividual(Param.individualId);
    OWLIndividual j = resolveIndividual(Param.fillerId);
    OWLObjectProperty p = resolveObjectProperty(Param.propertyId);
    for (OWLObjectPropertyAssertionAxiom ax : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) {
        if (ax.getSubject().equals(i)) {
            if (p == null || ax.getProperty().equals(p)) {
                if (j == null || ax.getObject().equals(j)) {
                    removeAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j));
                }
            }
        }
    }
    String jsonStr = "";
    response.getWriter().write(jsonStr);
}
项目:owltools    文件:OWLServerSimSearchTest.java   
@Test
    public void testServerGetCoAnnotationSuggestions() throws Exception {
        g = loadOntology("../OWLTools-Sim/src/test/resources/sim/mp-subset-1.obo");
        String file="../OWLTools-Sim/src/test/resources/sim/mgi-gene2mp-subset-1.tbl";
//      g = loadOntology("/Users/Nicole/work/MONARCH/phenotype-ontologies/src/ontology/hp.obo");
//      String file="/Users/Nicole/work/MONARCH/phenotype-ontologies/data/Homo_sapiens/Hs-disease-to-phenotype-O.txt";

        TableToAxiomConverter ttac = new TableToAxiomConverter(g);
        ttac.config.axiomType = AxiomType.CLASS_ASSERTION;
        ttac.config.isSwitchSubjectObject = true;
        ttac.parse(file);           

        OwlSimFactory owlSimFactory = new FastOwlSimFactory();
        OwlSim sos = owlSimFactory.createOwlSim(g.getSourceOntology());

        sos.createElementAttributeMapFromOntology();
//      sos.populateFullCoannotationMatrix();
        LOG.info("Finished populating the big matrix");

        HttpUriRequest httppost = createGoodCoAnnotationRequest(1);

        runServerCommunication(httppost,sos);

    }
项目:owltools    文件:PhenoSimHQEPreProcessor.java   
protected void makeHasPhenotypeInstancesDirect() {
    // x Type has_phenotype some C ==> x Type C
    LOG.info("x Type has_phenotype some C ==> x Type C");
    OWLObjectProperty hasPhenotype = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE);
    Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
    Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>();
    for (OWLClassAssertionAxiom caa : outputOntology.getAxioms(AxiomType.CLASS_ASSERTION)) {
        OWLClassExpression ex = caa.getClassExpression();
        OWLIndividual i = caa.getIndividual();
        if (ex instanceof OWLObjectSomeValuesFrom) {
            OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ex;
            if (svf.getProperty().equals(hasPhenotype)) {
                rmAxioms.add(caa);
                newAxioms.add(getOWLDataFactory().getOWLClassAssertionAxiom(svf.getFiller(), i));
            }

        }
    }
    LOG.info("making instances direct: +"+newAxioms.size()+ " -"+rmAxioms.size());
    addAxiomsToOutput(newAxioms, false);
    removeAxiomsFromOutput(rmAxioms, false);
}
项目:owltools    文件:AutomaticSimPreProcessorTest.java   
@Test
public void testAutoSimOnGO() throws Exception, MathException {

    ParserWrapper pw = new ParserWrapper();
    sourceOntol = pw.parseOBO(getResourceIRIString("go-subset-t1.obo"));
    g = new OWLGraphWrapper(sourceOntol);
    IRI vpIRI = g.getOWLObjectPropertyByIdentifier("GOTESTREL:0000001").getIRI();
    TableToAxiomConverter ttac = new TableToAxiomConverter(g);
    ttac.config.axiomType = AxiomType.CLASS_ASSERTION;
    ttac.config.property = vpIRI;
    ttac.config.isSwitchSubjectObject = true;
    ttac.parse("src/test/resources/simplegaf-t1.txt");

    OWLPrettyPrinter pp = new OWLPrettyPrinter(g);

    AutomaticSimPreProcessor pproc = new AutomaticSimPreProcessor();
    try {
        pproc.setInputOntology(sourceOntol);
        pproc.setOutputOntology(sourceOntol);
        pproc.preprocess();
    } finally {
        pproc.dispose();
    }

}
项目:owltools    文件:PropertyViewOntologyBuilder.java   
public Set<List<OWLObjectPropertyExpression>> getPropertyChains(OWLObjectProperty p) {
    LOG.info("Getting chains for: "+p);
    Set<List<OWLObjectPropertyExpression>> chains = new HashSet<List<OWLObjectPropertyExpression>>();
    for (OWLSubPropertyChainOfAxiom spca : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
        if (spca.getSuperProperty().equals(p)) {
            List<OWLObjectPropertyExpression> chain = spca.getPropertyChain();
            chains.add(chain);

            // note: limited form of cycle checking
            if (!chain.contains(p)) {
                chains.addAll(expandPropertyChain(chain));
            }
        }
    }
    LOG.info(p+" ==> "+chains);
    return chains;
}
项目:owltools    文件:Mooncat.java   
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);
}
项目:owltools    文件:TemplatedTransformer.java   
public Set<Mapping> getMappings() {
    Set<Mapping> ms = new HashSet<Mapping>();
    OWLAnnotationProperty vap = getVariableAnnotationProperty();
    for (OWLSubClassOfAxiom sca : ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED)) {
        Mapping m = new Mapping();
        Set<OWLAnnotation> anns = sca.getAnnotations(vap);
        for (OWLAnnotation ann : anns) {
            IRI v = (IRI) ann.getValue();
            m.vars.add(v);
        }
        if (m.vars.size() > 0) {
            m.src = sca.getSubClass();
            m.tgt = sca.getSuperClass();
            ms.add(m);
            LOG.info("MAPPING: "+m);
        }
    }
    return ms;

}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
private Map<OWLClass, Set<OWLSubClassOfAxiom>> initNeighborAxioms() {
    Map<OWLClass, Set<OWLSubClassOfAxiom>> result = new HashMap<OWLClass, Set<OWLSubClassOfAxiom>>();
    for(OWLOntology ont : getAllOntologies()) {
        for(OWLSubClassOfAxiom ax : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
            Set<OWLClass> inSignature = ax.getClassesInSignature();
            for (OWLClass cls : inSignature) {
                Set<OWLSubClassOfAxiom> neighbors = result.get(cls);
                if (neighbors == null) {
                    neighbors = new HashSet<OWLSubClassOfAxiom>();
                    result.put(cls, neighbors);
                }
                neighbors.add(ax);
            }
        }
    }

    return result;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * 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;
}
项目:owltools    文件:OWLGraphWrapperEdges.java   
private Map<OWLObjectProperty,Set<List<OWLObjectProperty>>> getPropertyChainMap() {
    if (pcMap == null) {
        pcMap = new HashMap<OWLObjectProperty,Set<List<OWLObjectProperty>>>();
        for (OWLSubPropertyChainOfAxiom a : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) {
            //LOG.info("CHAIN:"+a+" // "+a.getPropertyChain().size());
            if (a.getPropertyChain().size() == 2) {
                OWLObjectPropertyExpression p1 = a.getPropertyChain().get(0);
                OWLObjectPropertyExpression p2 = a.getPropertyChain().get(1);
                //LOG.info("  xxCHAIN:"+p1+" o "+p2);
                if (p1 instanceof OWLObjectProperty && p2 instanceof OWLObjectProperty) {
                    List<OWLObjectProperty> list = new Vector<OWLObjectProperty>();
                    list.add((OWLObjectProperty) p2);
                    list.add((OWLObjectProperty) a.getSuperProperty());
                    if (!pcMap.containsKey(p1)) 
                        pcMap.put((OWLObjectProperty) p1, new HashSet<List<OWLObjectProperty>>());
                    pcMap.get((OWLObjectProperty) p1).add(list);
                    //LOG.info("  xxxCHAIN:"+p1+" ... "+list);
                }
            }
            else {
                // TODO
            }
        }
    }
    return pcMap;
}
项目:Pellet4Android    文件:OntologyManager.java   
public Set<OWLAnnotationAssertionAxiom> getAnnotationValue(
        String turambarOntologyAnnotation) {
    OWLDataFactory factory = ontology.getOWLOntologyManager()
            .getOWLDataFactory();
    final OWLAnnotationProperty dcProperty = factory
            .getOWLAnnotationProperty(IRI
                    .create(turambarOntologyAnnotation));
    final Set<OWLAxiom> axioms = dcProperty.getReferencingAxioms(
            getOntology(), true);
    final Set<OWLAnnotationAssertionAxiom> values = new HashSet<OWLAnnotationAssertionAxiom>();
    for (OWLAxiom a : axioms) {
        if (a.getAxiomType().equals(AxiomType.ANNOTATION_ASSERTION)) {
            final OWLAnnotationAssertionAxiom annotationAssertion = (OWLAnnotationAssertionAxiom) a;

            values.add(annotationAssertion);
        }
    }
    return values;
}
项目:neo4j-sparql-extension-yars    文件:PredicateVariableExtractor.java   
/**
 * 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;
}
项目:uel    文件:UelOntologyGoal.java   
public void addPositiveAxioms(Set<? extends OWLAxiom> axioms) {
    for (OWLAxiom axiom : axioms) {
        if (axiom.isOfType(AxiomType.EQUIVALENT_CLASSES)) {
            addEquation((OWLEquivalentClassesAxiom) axiom);
        } else if (axiom.isOfType(AxiomType.SUBCLASS_OF)) {
            addSubsumption((OWLSubClassOfAxiom) axiom);
        } else {
            throw new RuntimeException("Unsupported axiom type: " + axiom);
        }
    }
}
项目:uel    文件:UelOntologyGoal.java   
public void addNegativeAxioms(Set<? extends OWLAxiom> axioms) {
    for (OWLAxiom axiom : axioms) {
        if (axiom.isOfType(AxiomType.EQUIVALENT_CLASSES)) {
            addDisequation((OWLEquivalentClassesAxiom) axiom);
        } else if (axiom.isOfType(AxiomType.SUBCLASS_OF)) {
            addDissubsumption((OWLSubClassOfAxiom) axiom);
        } else {
            throw new RuntimeException("Unsupported axiom type: " + axiom);
        }
    }
}
项目:minerva    文件:MolecularModelJsonRenderer.java   
/**
 * @return Map to be passed to Gson
 */
public JsonModel renderModel() {
    JsonModel json = new JsonModel();
    json.modelId = modelId;

    // per-Individual
    List<JsonOwlIndividual> iObjs = new ArrayList<JsonOwlIndividual>();
    for (OWLNamedIndividual i : ont.getIndividualsInSignature()) {
        iObjs.add(renderObject(i));
    }
    json.individuals = iObjs.toArray(new JsonOwlIndividual[iObjs.size()]);

    // per-Assertion
    Set<OWLObjectProperty> usedProps = new HashSet<OWLObjectProperty>();

    List<JsonOwlFact> aObjs = new ArrayList<JsonOwlFact>();
    for (OWLObjectPropertyAssertionAxiom opa : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) {
        JsonOwlFact fact = renderObject(opa);
        if (fact != null) {
            aObjs.add(fact);
            usedProps.addAll(opa.getObjectPropertiesInSignature());
        }
    }
    json.facts = aObjs.toArray(new JsonOwlFact[aObjs.size()]);

    JsonAnnotation[] anObjs = renderAnnotations(ont.getAnnotations(), curieHandler);
    if (anObjs != null && anObjs.length > 0) {
        json.annotations = anObjs;
    }

    return json;

}
项目:DL-Learner-Protege-Plugin    文件:ProtegePlugin.java   
@Override
public boolean isValidInput() {
    if(getAxiomType() == AxiomType.EQUIVALENT_CLASSES) {
        Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.EQUIVALENT);
    } else if(getAxiomType() == AxiomType.SUBCLASS_OF) {
        Manager.getInstance(getOWLEditorKit()).setLearningType(LearningType.SUPER);
    }
    view.reset();
    checkReasonerStatus();
    return true;
}
项目:DL-Learner-Protege-Plugin    文件:SuggestClassPanelHandler.java   
@Override
    public void valueChanged(ListSelectionEvent e) {
        if(view.getSuggestClassPanel().getSuggestionsTable().getSelectedRow() >= 0){

            // get the selected class expression
            EvaluatedDescription newDesc = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion();

            // enable 'Add' button
            if(!e.getValueIsAdjusting() && newDesc != null) {
                view.getAddButton().setEnabled(true);
            }

            // update the class coverage diagram
            if(view.getAxiomType().equals(AxiomType.EQUIVALENT_CLASSES) || 
                    view.getAxiomType().equals(AxiomType.SUBCLASS_OF)) {
//              evaluatedDescription = view.getSuggestClassPanel().getSuggestionsTable().getSelectedSuggestion();
                if(!e.getValueIsAdjusting() && (evaluatedDescription == null || !evaluatedDescription.equals(newDesc))){
//                  view.getMoreDetailForSuggestedConceptsPanel().renderDetailPanel(evaluatedDescription);
                    view.showHintMessagePanel(false);
                    view.showGraphicalPanel(true);
                    view.getGraphicalPanel().setDescription(evaluatedDescription);
                }
            }

            evaluatedDescription = newDesc;
        }


    }
项目:pronto    文件:ProntoLoaderUtils.java   
/**
 * Loads conditional constraints from an ontology with annotated axioms
 * 
 * @param ontology
 * @param signature 
 * @param declAxioms Used to return declaration axioms for auto-generated class names
 * @param iriPrefix IRI prefix for auto-generated class names
 * @param raxList
 * @return
 */
public static Set<ConditionalConstraint> loadDefaultConstraintsFromOWL(
        OWLOntology ontology,
        Map<String, OWLClassExpression> nameMap,
        Set<OWLEntity> signature,
        List<RemoveAxiom> raxList, String iriPrefix,
        OWLOntologyManager manager) {

    Set<ConditionalConstraint> ccSet = new HashSet<ConditionalConstraint>();
    //Begin with generic (default) subclass-of axioms
    for( OWLAxiom axiom : ontology.getAxioms( AxiomType.SUBCLASS_OF ) ) {
        for( OWLAnnotation annotation : axiom.getAnnotations() ) {

            if( Constants.CERTAINTY_ANNOTATION_URI.equals(annotation.getProperty().getIRI().toURI() ) ) {

                OWLSubClassOfAxiom sbAxiom = (OWLSubClassOfAxiom) axiom;
                String subClassIRI = generateClassName(sbAxiom.getSubClass(), nameMap, iriPrefix);
                String superClassIRI = generateClassName(sbAxiom.getSuperClass(), nameMap, iriPrefix);
                ConditionalConstraint cc = newConstraint(subClassIRI, superClassIRI, annotation.getValue().toString());

                signature.addAll( sbAxiom.getSubClass().getClassesInSignature() );
                signature.addAll( sbAxiom.getSuperClass().getClassesInSignature() );

                if( null != cc ) {

                    ccSet.add( cc );

                    if( null != raxList ) {
                        raxList.add( new RemoveAxiom( ontology, axiom ) );
                    }
                }
            }
        }
    }

    return ccSet;
}
项目:elk-reasoner    文件:ElkReasoner.java   
@Override
public boolean isEntailmentCheckingSupported(final AxiomType<?> axiomType) {
    Class<? extends ElkObject> elkAxiomClass = OwlConverter
            .convertType(axiomType.getActualClass());
    if (elkAxiomClass == null
            || !ElkAxiom.class.isAssignableFrom(elkAxiomClass)) {
        // not supported
        return false;
    }
    // else
    return EntailmentQueryConverter.isEntailmentCheckingSupported(
            elkAxiomClass.asSubclass(ElkAxiom.class));
}
项目:owltools    文件:AbstractOwlSim.java   
@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();
}
项目:owltools    文件:PhenoSimHQEPreProcessor.java   
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());
}
项目:owltools    文件:Mooncat.java   
public static Set<OWLObject> findTaggedEntities(OWLAnnotationProperty p, Set<OWLAnnotationValue> values, final OWLGraphWrapper graph) {
    if (p == null || values == null || values.isEmpty()) {
        return Collections.emptySet();
    }
    final Set<OWLObject> entities = new HashSet<OWLObject>();
    Set<OWLOntology> allOntologies = graph.getAllOntologies();
    for (OWLOntology ontology : allOntologies) {
        Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION);
        for (OWLAnnotationAssertionAxiom axiom : axioms) {
            if (p.equals(axiom.getProperty()) && values.contains(axiom.getValue())) {
                axiom.getSubject().accept(new OWLAnnotationSubjectVisitor(){

                    @Override
                    public void visit(IRI iri) {
                        OWLObject owlObject = graph.getOWLObject(iri);
                        if (owlObject != null) {
                            entities.add(owlObject);
                        }
                    }

                    @Override
                    public void visit(OWLAnonymousIndividual individual) {
                        // do nothing
                    }
                });
            }
        }
    }
    return entities;
}
项目:owltools    文件:Mooncat.java   
/**
 * For every pair X DisjointWith Y, generate an axiom
 * A and Y = Nothing
 * 
 * (may become deprecated after Elk supports disjoints)
 * 
 * @param ont
 * @param manager
 * @param dataFactory
 */
public static void translateDisjointsToEquivalents(OWLOntology ont, OWLOntologyManager manager, OWLDataFactory dataFactory) {
    for (OWLDisjointClassesAxiom dca : ont.getAxioms(AxiomType.DISJOINT_CLASSES, Imports.INCLUDED)) {
        for (OWLClassExpression ce1 : dca.getClassExpressions()) {
            for (OWLClassExpression ce2 : dca.getClassExpressions()) {
                if (ce1.compareTo(ce2) <= 0)
                    continue;
                OWLEquivalentClassesAxiom eca = dataFactory.getOWLEquivalentClassesAxiom(dataFactory.getOWLNothing(),
                        dataFactory.getOWLObjectIntersectionOf(ce1, ce2));
                manager.addAxiom(ont, eca);
                // TODO - remove if requested
            }
        }
    }
}
项目:owltools    文件:OwlHelper.java   
public static Set<OWLAnnotationProperty> getSubProperties(OWLAnnotationProperty superProp, Set<OWLOntology> ontologies) {
    Set<OWLAnnotationProperty> result = new HashSet<OWLAnnotationProperty>();
    for (OWLOntology ont : ontologies) {
        for (OWLSubAnnotationPropertyOfAxiom ax : ont.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
            if (ax.getSuperProperty().equals(superProp)) {
                result.add(ax.getSubProperty());
            }
        }
    }
    return result;
}
项目:owltools    文件:OwlHelper.java   
public static Set<OWLAnnotationProperty> getSuperProperties(OWLAnnotationProperty subProp, Set<OWLOntology> ontologies) {
    Set<OWLAnnotationProperty> result = new HashSet<OWLAnnotationProperty>();
    for (OWLOntology ont : ontologies) {
        for (OWLSubAnnotationPropertyOfAxiom ax : ont.getAxioms(AxiomType.SUB_ANNOTATION_PROPERTY_OF)) {
            if (ax.getSubProperty().equals(subProp)) {
                result.add(ax.getSuperProperty());
            }
        }
    }
    return result;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * 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;
}
项目:owltools    文件:LegoTools.java   
private Set<OWLObjectPropertyAssertionAxiom> getAllPropertyAssertionAxioms(Set<OWLOntology> ontologies) {
    Set<OWLObjectPropertyAssertionAxiom> axioms = new HashSet<OWLObjectPropertyAssertionAxiom>();
    for(OWLOntology o : ontologies) {
        axioms.addAll(o.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION));
    }
    return axioms;
}
项目:owltools    文件:OboOntologyReleaseRunner.java   
/**
 * Remove inferred axioms, which are marked by the appropriate axiom annotation. 
 * 
 * @param removedSubClassOfAxioms
 * @param removedSubClassOfAxiomChanges
 * 
 * @see AxiomAnnotationTools#isMarkedAsInferredAxiom(OWLAxiom)
 */
private void removeInferredAxioms(Set<OWLSubClassOfAxiom> removedSubClassOfAxioms, Set<RemoveAxiom> removedSubClassOfAxiomChanges)
{
    final OWLOntology ont = mooncat.getGraph().getSourceOntology();
    for (OWLSubClassOfAxiom a : ont.getAxioms(AxiomType.SUBCLASS_OF)) {
        if (AxiomAnnotationTools.isMarkedAsInferredAxiom(a)) {
            RemoveAxiom rmax = new RemoveAxiom(ont, a);
            removedSubClassOfAxiomChanges.add(rmax);
            removedSubClassOfAxioms.add(a);
        }
    }
}
项目:owltools    文件:NCBI2OWLTest.java   
private void testOntology(OWLOntology ontology, int taxa,
        int annotations) {
    int declarations = taxa // taxon class declarations
        + oio + props // OIO and other annotation properties
        + types + ranks;
    assertEquals("Count declarations", declarations,
        ontology.getAxiomCount(AxiomType.DECLARATION));

    int taxaExceptRoot = 0;
    if (taxa > 0) { taxaExceptRoot = taxa - 1; }

    int subClasses = taxaExceptRoot // taxa except root
        + ranks - 1; // ranks except taxonomy_rank
    assertEquals("Count subClass assertions", subClasses,
        ontology.getAxiomCount(AxiomType.SUBCLASS_OF));

    int subAnnotationProperties = types - 1; // taxa except synonym_type_property
    assertEquals("Count subClass assertions",
        subAnnotationProperties,
        ontology.getAxiomCount(
            AxiomType.SUB_ANNOTATION_PROPERTY_OF));

    assertEquals("Count annotation assertions", annotations,
        ontology.getAxiomCount(AxiomType.ANNOTATION_ASSERTION));

    int axioms = declarations
        + subClasses
        + subAnnotationProperties
        + annotations;
    assertEquals("Count all axioms", axioms,
        ontology.getAxiomCount());
}
项目:born    文件:BornReasoner.java   
@Override
public boolean isEntailmentCheckingSupported(AxiomType<?> axiomType) {
    Objects.requireNonNull(axiomType);
    logger.finer("isEntailmentCheckingSupported(" + axiomType + ")");
    throw new UnsupportedReasonerOperationInBornException(
            "Unsupported operation : isEntailmentCheckingSupported(AxiomType<?>)");
}
项目:jcel    文件:JcelReasoner.java   
private Set<AxiomType<?>> getSupportedTypes() {
    Set<AxiomType<?>> ret = new HashSet<>();
    ret.add(AxiomType.EQUIVALENT_CLASSES);
    ret.add(AxiomType.SUBCLASS_OF);
    ret.add(AxiomType.SUB_OBJECT_PROPERTY);
    return Collections.unmodifiableSet(ret);
}
项目:jcel    文件:JcelReasoner.java   
@Override
public boolean isEntailmentCheckingSupported(AxiomType<?> axiomType) {
    Objects.requireNonNull(axiomType);
    logger.finer("isEntailmentCheckingSupported(" + axiomType + ")");
    boolean ret = this.supportedAxiomTypes.contains(axiomType);
    logger.finer("" + ret);
    return ret;
}
项目:neo4j-sparql-extension    文件:PredicateVariableExtractor.java   
/**
 * 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;
}
项目:SciGraph    文件:ReasonerUtil.java   
Collection<OWLOntologyChange> removeAxioms(AxiomType<?> type) {
  Collection<OWLOntologyChange> removals = new HashSet<>();
  for (OWLOntology importedOnt: ont.getImportsClosure()) {
    Set<? extends OWLAxiom> axioms = importedOnt.getAxioms(type);
    removals.addAll(manager.removeAxioms(importedOnt, axioms));
  }
  return removals;
}
项目:SciGraph    文件:ReasonerUtil.java   
/***
 * Remove all axioms that would generate extra unsatisfiable classes for the reasoner
 */
Collection<OWLOntologyChange> removeUnsatisfiableClasses() {
  Collection<OWLOntologyChange> removals = new HashSet<>();
  removals.addAll(removeAxioms(AxiomType.DISJOINT_CLASSES));
  removals.addAll(removeAxioms(AxiomType.DATA_PROPERTY_DOMAIN));
  removals.addAll(removeAxioms(AxiomType.DATA_PROPERTY_RANGE));
  if (removals.size() > 0) {
    reasoner.flush();
  }
  logger.info("Removed " + removals.size() + " axioms to prevent unsatisfiable classes");
  return removals;
}
项目:semantika    文件:OwlPropertyStructureHandler.java   
public OwlPropertyStructureHandler(AbstractOwlOntology ontology)
{
   OWLOntology ont = ontology.asOwlOntology();
   for (AxiomType<?> type : AxiomType.RBoxAxiomTypes) {
      for (OWLAxiom axiom : ont.getAxioms(type, true)) {
         axiom.accept(this);
      }
   }
}
项目:semantika    文件:OwlClassStructureHandler.java   
public OwlClassStructureHandler(AbstractOwlOntology ontology)
{
   mPropertyStructureHandler = ontology.getPropertyStructureHandler();
   mOwlDataFactory = ontology.getOwlDataFactory();
   OWLOntology ont = ontology.asOwlOntology();
   for (AxiomType<?> type : AxiomType.TBoxAxiomTypes) {
      for (OWLAxiom axiom : ont.getAxioms(type, true)) {
         axiom.accept(this);
      }
   }
}
项目:gate-semano    文件:OntologyParser.java   
private void loadSubclassAxioms(OWLOntology o) {
    logger.debug("starting loading subclass axioms for "
            + o.getOntologyID().getOntologyIRI().toString());
    // first subclass axioms
    Set<OWLSubClassOfAxiom> subclassAxioms = o.getAxioms(AxiomType.SUBCLASS_OF);
    for (OWLSubClassOfAxiom subaxiom : subclassAxioms) {
        loadAxiom(subaxiom);
    }
    // then equivalent axioms
    // loadEquivAxioms();
    logger.debug("finished loading subclass axioms for "
            + o.getOntologyID().getOntologyIRI().toString());
}
项目:gate-semano    文件:OntologyParser.java   
private void loadSubclassAxioms() {
    logger.debug("starting loading subclass axioms for all ontologies "
            + ontologies.size());
    // first subclass axioms
    Set<OWLSubClassOfAxiom> subclassAxioms = new HashSet<OWLSubClassOfAxiom>();
    for (OWLOntology ox : ontologies) {
        subclassAxioms.addAll(ox.getAxioms(AxiomType.SUBCLASS_OF));
    }
    for (OWLSubClassOfAxiom subaxiom : subclassAxioms) {
        loadAxiom(subaxiom);
    }
    // then equivalent axioms
    // loadEquivAxioms();
    logger.debug("finished loading subclass axioms ");
}