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

项目:OWLAx    文件:OWLCellRenderer.java   
protected String getRendering(Object object) {
    if (object instanceof OWLObject) {
        String rendering = getOWLModelManager().getRendering(((OWLObject) object));
        for (OWLObject eqObj : equivalentObjects) {
            // Add in the equivalent class symbol
            rendering += " \u2261 " + getOWLModelManager().getRendering(eqObj);
        }
        return rendering;
    } else {
        if (object != null) {
            return object.toString();
        } else {
            return "";
        }
    }
}
项目:owltools    文件:ShuntGraphUtilsTest.java   
private void containsRel(String s, String t, String r, OWLShuntGraph shuntGraph, OWLGraphWrapper graph, Set<OWLShuntEdge> remaining) {
    boolean found = false;
    OWLObject cs = graph.getOWLObjectByIdentifier(s);
    OWLObject ct = graph.getOWLObjectByIdentifier(t);
    for (OWLShuntEdge edge : shuntGraph.edges) {
        if (s.equals(edge.sub) && t.equals(edge.obj) && r.equals(edge.pred)) {
            found = true;
            remaining.remove(edge);
            break;
        }
    }
    assertTrue("Did not find edge: ("+
            graph.getLabelOrDisplayId(cs)+"; "+
            graph.getLabelOrDisplayId(ct)+"; "+
            r+")", found);
}
项目:owltools    文件:OWLGraphWrapperTest.java   
@Test
public void testGetOBOSynonymsMultipleScopes() throws Exception{
    OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("ncbi_taxon_slim.obo");

    OWLObject cls = wrapper.getOWLClass(OWLGraphWrapper.DEFAULT_IRI_PREFIX + "NCBITaxon_10088");

    List<ISynonym> synonyms = wrapper.getOBOSynonyms(cls);
    assertEquals(2, synonyms.size());
    ISynonym synonym1 = synonyms.get(0);
    ISynonym synonym2 = synonyms.get(1);
    // TODO what is the right order of synonyms?
    if (synonym1.getLabel().equals("mice")) {
        ISynonym temp = synonym1;
        synonym1 = synonym2;
        synonym2 = temp;
    }
    assertEquals("Nannomys", synonym1.getLabel());
    assertEquals("RELATED", synonym1.getScope());
    assertNull(synonym1.getCategory());
    assertNull(synonym1.getXrefs());

    assertEquals("mice", synonym2.getLabel());
    assertEquals("EXACT", synonym2.getScope());
    assertNull(synonym2.getCategory());
    assertNull(synonym2.getXrefs());
}
项目:owltools    文件:ShuntGraphUtilsTest.java   
@Test
public void testSagaComplex() throws Exception {
    OWLObject focusObject = g.getOWLClassByIdentifier("GO:0000124"); // SAGA complex
    Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>();
    props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI()));

    ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, true);

    OWLShuntGraph topology = pair.getTopologyGraph();

    checkNodesSagaComplex(g, topology);
    checkTopologyRelationsSagaComplex(g, topology);

    OWLShuntGraph inferred = pair.getInferredGraph();

    checkNodesSagaComplex(g, inferred);
    checkInferredRelationsSagaComplex(g, inferred);
}
项目:skoseditor    文件:ConceptSchemeComboBox.java   
public static JComboBox getConceptSchemeComboBox(OWLEditorKit owlEditorKit) {

        final Comparator<OWLObject> comp = owlEditorKit.getModelManager().getOWLObjectComparator();

        List<OWLIndividual> sorted;
        Collections.sort(sorted = new ArrayList<OWLIndividual>(getConceptSchemes(owlEditorKit)), new OWLObjectComparatorAdapter<OWLIndividual>(comp) {

            public int compare(OWLIndividual o1, OWLIndividual o2) {
                return super.compare(o1,o2);
            }
        });

        JComboBox schemaBox = new JComboBox(sorted.toArray());
        schemaBox.setRenderer(new OWLCellRendererSimple(owlEditorKit));
        if(!getConceptSchemes(owlEditorKit).isEmpty()) {
            schemaBox.setSelectedIndex(0);
        }

        return schemaBox;

    }
项目:jopa    文件:LiveOntologyStatementExecutor.java   
@Override
public ResultSet executeQuery(final String query, final Statement statement) throws OwlapiDriverException {
    final ResultSet resultSet = connector.executeRead(snapshot -> {
        if (snapshot.getReasoner() == null) {
            throw new ReasonerNotAvailableException("Cannot execute query without a reasoner.");
        }
        final OWLAPIv3OWL2Ontology ont = new OWLAPIv3OWL2Ontology(snapshot.getOntologyManager(),
                snapshot.getOntology(), snapshot.getReasoner());

        final QueryResult<OWLObject> res = OWL2QueryEngine.exec(query, ont);

        return res != null ? AbstractResultSet.createResultSet(res, statement, query) : null;
    });
    if (resultSet == null) {
        throw new OwlapiDriverException("Unable to execute query " + query);
    }
    return resultSet;
}
项目:owltools    文件:ShuntGraphUtilsNRTest.java   
private void containsRel(String s, String t, String r, OWLShuntGraph shuntGraph, OWLGraphWrapper graph, Set<OWLShuntEdge> remaining) {
    boolean found = false;
    OWLObject cs = graph.getOWLObjectByIdentifier(s);
    OWLObject ct = graph.getOWLObjectByIdentifier(t);
    for (OWLShuntEdge edge : shuntGraph.edges) {
        if (s.equals(edge.sub) && t.equals(edge.obj) && r.equals(edge.pred)) {
            found = true;
            remaining.remove(edge);
            break;
        }
    }
    assertTrue("Did not find edge: ("+
            graph.getLabelOrDisplayId(cs)+"; "+
            graph.getLabelOrDisplayId(ct)+"; "+
            r+")", found);
}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
/**
 * Add a set of edges, as ancestors to x in OWLShuntGraph g.
 * This is reflexive.
 *
 * @param x
 * @param g
 * @param rel_ids
 * @return the modified OWLShuntGraph
 */
public OWLShuntGraph addTransitiveAncestorsToShuntGraph(OWLObject x, OWLShuntGraph g, List<String> rel_ids) {

    // Add this node, our seed.
    String topicID = getIdentifier(x);
    String topicLabel = getLabel(x);
    OWLShuntNode tn = new OWLShuntNode(topicID, topicLabel);
    g.addNode(tn);

    Set<OWLObjectProperty> props = relationshipIDsToPropertySet(rel_ids);
    if (x instanceof OWLClass) {
        addTransitiveAncestorsToShuntGraph((OWLClass) x, topicID, g, props);
    }
    else if (x instanceof OWLObjectProperty) {
        addTransitiveAncestorsToShuntGraph((OWLObjectProperty) x, topicID, g, props);
    }
    return g;
}
项目:owltools    文件:OWLGraphManipulator.java   
/**
 * Remove direct edges between the {@code OWLObject}s with the OBO-like IDs 
 * {@code sourceId} and {@code targetId}.
 * 
 * @param sourceId A {@code String} that is the OBO-like ID of the {@code OWLObject} 
 *                 whose edges to remove outgoing from.
 * @param targetId A {@code String} that is the OBO-like ID of the {@code OWLObject} 
    *                 whose edges to remove incoming to.
 * @return         An {@code int} that is the number of {@code OWLGraphEdge}s 
 *                 removed as a result.
 */
public int removeDirectEdgesBetween(String sourceId, String targetId) {
    OWLObject source = this.getOwlGraphWrapper().getOWLObjectByIdentifier(sourceId);
       if (source == null) {
           throw new IllegalArgumentException(sourceId + " was not found in the ontology");
       }
       OWLObject target = this.getOwlGraphWrapper().getOWLObjectByIdentifier(targetId);
       if (target == null) {
           throw new IllegalArgumentException(targetId + " was not found in the ontology");
       }

       Set<OWLGraphEdge> edgesToRemove = new HashSet<OWLGraphEdge>();
       for (OWLGraphEdge edge: this.getOwlGraphWrapper().getOutgoingEdgesWithGCI(source)) {
           if (edge.getTarget().equals(target)) {
               edgesToRemove.add(edge);
           }
       }
       int edgesRemoved = this.removeEdges(edgesToRemove);

       if (log.isInfoEnabled()) {
           log.info("Edges between " + sourceId + " and " + targetId + " removed, " + 
                   edgesRemoved + " removed.");
       }

       return edgesRemoved;
}
项目:owltools    文件:TableRenderer.java   
public void render(OWLGraphWrapper g) {

    if (isWriteHeader) {
        print("IRI");
        sep();
        print("label");
        sep();
        print("definition");
        nl();
    }
    graph = g;

    Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
    objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));

    for (OWLObject obj : objs) {
        if (obj.equals(g.getDataFactory().getOWLNothing()))
            continue;
        if (obj.equals(g.getDataFactory().getOWLThing()))
            continue;
        if (obj instanceof OWLNamedObject)
            render((OWLNamedObject)obj);
    }
    stream.close();
}
项目:owltools    文件:PhenologSimTest.java   
@Test
//  @Ignore("takes a long time, add to separate test suite") // uncomment this line to deactivate the test
    public void testSim() throws Exception{
        OWLGraphWrapper  wrapper = 
            getOntologyWrapperFromURL("http://obo.svn.sourceforge.net/viewvc/obo/phenotype-commons/ontology/mp-hp-ext-merged-uberon.owl?revision=3905");
        DescriptionTreeSimilarity sa = 
            new DescriptionTreeSimilarity();
        OWLObject a = wrapper.getOWLObject("http://purl.obolibrary.org/obo/MP_0005391");
        OWLObject b = wrapper.getOWLObject("http://purl.obolibrary.org/obo/HP_0000478");
        SimEngine se = new SimEngine(wrapper);
        //sa.forceReflexivePropertyCreation = true;
        sa.calculate(se, b, a);
        sa.print();
        System.out.println(sa.getScore());

    }
项目:owltools    文件:OWLHandler.java   
/**
 * Params: id
 * @throws OWLOntologyCreationException
 * @throws OWLOntologyStorageException
 * @throws IOException
 * @throws OWLParserException
 */
public void getAxiomsCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException, OWLParserException {
    headerOWL();
    boolean direct = getParamAsBoolean(Param.direct, false);
    OWLObject obj = this.resolveEntity();
    LOG.info("finding axioms about: "+obj);
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    if (obj instanceof OWLClass) {
        axioms.addAll(graph.getSourceOntology().getAxioms((OWLClass)obj, Imports.EXCLUDED));
    }
    if (obj instanceof OWLIndividual) {
        axioms.addAll(graph.getSourceOntology().getAxioms((OWLIndividual)obj, Imports.EXCLUDED));
    }
    if (obj instanceof OWLObjectProperty) {
        axioms.addAll(graph.getSourceOntology().getAxioms((OWLObjectProperty)obj, Imports.EXCLUDED));
    }

    for (OWLAxiom ax : axioms) {
        output(ax);
    }
}
项目:owltools    文件:AncestorsTest.java   
@Test
public void testDescendants() throws Exception {
    OWLGraphWrapper  g =  getOntologyWrapper();
    OWLClass c = g.getOWLClass("http://purl.obolibrary.org/obo/NCBITaxon_10090");
    OWLObject i = g.getOWLObject("http://purl.obolibrary.org/obo/MGI_101761");
    System.out.println("Descendants of "+c);
    System.out.println("Expecting "+i);
    boolean ok = false;
    for (OWLGraphEdge e : g.getIncomingEdgesClosure(c)) {
        System.out.println("i:"+e);
        if (e.getSource().equals(i))
            ok = true;
    }

    assertTrue(ok);
}
项目:owltools    文件:OWLHandler.java   
/**
 * generates a sub-ontology consisting only of classes specified using the id param.
 * If the include_ancestors param is true, then the transitive closure of the input classes is
 * included. otherwise, intermediate classes are excluded and paths are filled.
 * 
 * @throws OWLOntologyCreationException 
 * @throws OWLOntologyStorageException 
 * @throws IOException 
 * @see Mooncat#makeMinimalSubsetOntology(Set, IRI)
 */
public void makeSubsetOntologyCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
    headerOWL();
    Set<OWLClass> objs = resolveClassList();
    Set<OWLClass> tObjs = new HashSet<OWLClass>();
    if (getParamAsBoolean("include_ancestors")) {
        // TODO - more more efficient
        for (OWLClass obj : objs) {
            for (OWLObject t : graph.getAncestorsReflexive(obj)) {
                tObjs.add((OWLClass)t);
            }
        }
    }
    else {
        tObjs = objs;
    }
    Mooncat mooncat;
    mooncat = new Mooncat(graph);
    OWLOntology subOnt = 
            mooncat.makeMinimalSubsetOntology(tObjs,
                    IRI.create("http://purl.obolibrary.org/obo/temporary"));
    for (OWLAxiom axiom : subOnt.getAxioms()) {
        output(axiom); // TODO
    }
    graph.getManager().removeOntology(subOnt);
}
项目:owltools    文件:DescriptionTreeSimilarity.java   
/**
 * given two paths to the same node..
 * TODO - also include from tips of edges to LCS..?
 * 
 * @param x
 * @param ea
 * @param eb
 * @return class expression
 */
private OWLClassExpression combinePathsToMakeExpression(OWLObject x, OWLGraphEdge ea, OWLGraphEdge eb) {
    LOG.info("combining, tgt="+x+" EA="+ea+" EB="+eb);
    Set<OWLClassExpression> args = new HashSet<OWLClassExpression>();
    if (ea == null) {
        ea = new OWLGraphEdge(null,x,new Vector<OWLQuantifiedProperty>(),null);
        ea.setTarget(x);
    }
    if (eb == null) {
        eb = new OWLGraphEdge(null,x,new Vector<OWLQuantifiedProperty>(),null);
        eb.setTarget(x);
    }
    LOG.info("making Union of "+ea+" and "+eb);
    if (!ea.getTarget().equals(x)) {
        LOG.info("##EA no match!!");
    }
    if (!eb.getTarget().equals(x)) {
        LOG.info("##EB no match!!");
    }
    return makeUnion(ea,eb);

}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
/**
 * Generator for the cache in {@link #getRelationClosureMap(OWLObject, List)}.
 * 
 * @param obj
 * @param relation_ids
 * @return map of ids to their displayable labels
 * @see #getRelationClosureMap(OWLObject, List)
 */
public Map<String,String> getRelationClosureMapEngine(OWLObject obj, List<String> relation_ids){

    final Map<String,String> relation_map = new HashMap<String,String>(); // capture labels/ids

    // reflexive
    String id = getIdentifier(obj);
    String label = getLabel(obj);
    relation_map.put(id, label);

    // Our relation collection.
    final Set<OWLObjectProperty> props = relationshipIDsToPropertySet(relation_ids);

    if (obj instanceof OWLClass) {
        addIdLabelClosure((OWLClass) obj, true, props, relation_map);
    }
    else if (obj instanceof OWLObjectProperty) {
        addIdLabelClosure((OWLObjectProperty) obj, true, relation_map);
    }
    return relation_map;
}
项目:owltools    文件:SimEngine.java   
public Set<OWLObject> nonSignificantObjects() {
    if (minimumIC == null) {
        return new HashSet<OWLObject>();
    }
    if (nonSignificantObjectSet != null ) {
        return nonSignificantObjectSet;
    }
    nonSignificantObjectSet = new HashSet<OWLObject>();
    for (OWLObject obj : graph.getAllOWLObjects()) {
        if (this.hasInformationContent(obj) &&
                this.getInformationContent(obj) < minimumIC) {
            nonSignificantObjectSet.add(obj);
        }
    }
    return nonSignificantObjectSet;
}
项目:owltools    文件:OWLGraphWrapperEdges.java   
protected Set<OWLGraphEdge> primitiveEdgeToFullEdges(OWLGraphEdge e) {
    Set<OWLGraphEdge> edges = new OWLGraphEdgeSet();
    if (e.isTargetNamedObject()) {
        edges.add(e); // do nothing
    }
    else {
        // extend
        OWLObject s = e.getSource();
        Set<OWLGraphEdge> nextEdges = getOutgoingEdges(e.getTarget());
        for (OWLGraphEdge e2 : nextEdges) {
            OWLGraphEdge nu = this.combineEdgePair(s, e, e2, 1);
            if (nu != null)
                edges.add(nu);
        }
    }
    filterEdges(edges);
    return edges;
}
项目:owltools    文件:CompactGraphClosureReader.java   
private OWLGraphEdge parseEdge(OWLOntology ont, OWLObject src, String edgeStr) {
    OWLGraphEdge e;
    String[] vals = edgeStr.split(",");
    int len = vals.length;
    OWLObject tgt = getObject(vals[len-2]); 
    int dist = Integer.parseInt(vals[len-1]);
    OWLQuantifiedProperty[] qpa = new OWLQuantifiedProperty[len-2];
    for (int i=0; i<len-2; i++) {
        OWLQuantifiedProperty qp = parseQP(vals[i]);
        qpa[i] = qp;
    }
    List<OWLQuantifiedProperty> qpl = Arrays.asList(qpa); // fixed length, cannot be appended to

    e = new OWLGraphEdge(src, tgt, qpl, ont);
    e.setDistance(dist);
    return e;
}
项目:owltools    文件:OWLGraphUtil.java   
public static Set<OWLGraphEdge> findLeastCommonSubsumersAsEdges(OWLGraphWrapper g,
        OWLObject x, OWLObject y) {
    Set<OWLGraphEdge> cses = findCommonSubsumersAsEdges(g,x,y);
    Set<OWLGraphEdge> lcses = new HashSet<OWLGraphEdge>();
    lcses.addAll(cses);
    for (OWLGraphEdge cse: cses) {
        Set<OWLObject> zs = g.getAncestors(cse.getSource());
        for (OWLObject z : zs) {
            for (OWLGraphEdge lcse: lcses) {
                if (lcse.getSource().equals(z))
                    lcses.remove(lcse);
            }
        }
    }
    return lcses;
}
项目:owltools    文件:ComplexAnnotationSolrDocumentLoader.java   
private Map<String, String> addClosureToDoc(ArrayList<String> relations, String closureName, String closureNameLabel, String closureMap,
        OWLObject cls, SolrInputDocument solr_doc){

    // Add closures to doc; label and id.
    Map<String, String> cmap = currentGraph.getRelationClosureMap(cls, relations);
    List<String> idClosure = new ArrayList<String>(cmap.keySet());
    List<String> labelClosure = new ArrayList<String>(cmap.values());
    solr_doc.addField(closureName, idClosure);
    solr_doc.addField(closureNameLabel, labelClosure);
    for( String tid : idClosure){
        addFieldUnique(solr_doc, closureName, tid);
    }

    // Compile closure maps to JSON.
    if( ! cmap.isEmpty() ){
        String jsonized_cmap = gson.toJson(cmap);
        solr_doc.addField(closureMap, jsonized_cmap);
    }

    return cmap;
}
项目:owltools    文件:ShuntGraphUtilsNRTest.java   
@Test
public void testSagaComplex() throws Exception {
    OWLObject focusObject = g.getOWLClassByIdentifier("GO:0000124"); // SAGA complex
    Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>();
    props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI()));

    ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, true);

    OWLShuntGraph topology = pair.getTopologyGraph();

    checkNodesSagaComplex(g, topology);
    checkTopologyRelationsSagaComplex(g, topology);

    OWLShuntGraph inferred = pair.getInferredGraph();

    checkNodesSagaComplex(g, inferred);
    checkInferredRelationsSagaComplex(g, inferred);
}
项目:owltools    文件:AbstractSimEngineTest.java   
protected void run(OWLGraphWrapper  wrapper, Similarity sim, OWLObject a, OWLObject b) throws Exception{
    OWLPrettyPrinter pp = new OWLPrettyPrinter(wrapper);
    SimEngine se = new SimEngine(wrapper);
    System.out.println("Comparing "+pp.render(a)+" -vs- "+pp.render(b));
    /*
    for (OWLObject x : wrapper.getDescendantsReflexive(a)) {
        System.out.println("d="+x);
    }
    */

    OWLClassExpression lcs = se.getLeastCommonSubsumerSimpleClassExpression(a, b);
    if (lcs != null) {
        System.out.println(" LCS: "+pp.render(lcs));            
    }

    se.calculateSimilarity(sim, a, b);

    System.out.println(sim);
    for (OWLAxiom ax : sim.translateResultsToOWLAxioms()) {
        System.out.println("  Ax: "+pp.render(ax));
    }

}
项目:owltools    文件:FlyTest.java   
@Test
@Ignore("This test requires an external resource. This can lead to false positive failures.")
public void testConvertXPs() throws Exception {
    ParserWrapper pw = new ParserWrapper();
    OWLGraphWrapper g =
        pw.parseToOWLGraph("http://purl.obolibrary.org/obo/fbbt.obo");
    OWLObject wmb = g.getOWLObjectByIdentifier("FBbt:00004326"); // wing margin bristle
    OWLObject eso = g.getOWLObjectByIdentifier("FBbt:00005168"); // external sensory organ

    Set<OWLObject> ancs = g.getAncestorsReflexive(wmb);
    assertTrue(ancs.contains(wmb)); // reflexivity test
    assertTrue(ancs.contains(eso)); //wing margin bristle --> external sensory organ

    for (OWLObject c : ancs) {
        System.out.println(g.getIdentifier(c)+" "+g.getLabel(c)+" URI:"+c);
    }
}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
/**
 * Gets all ancestors and direct descendants (distance == 1) that are OWLNamedObjects.
 * i.e. excludes anonymous class expressions
 * <p>
 * TODO: we're current just doing distance == 1 up;
 *       we'll want to have a more full graph in the future
 * <p>
 * TODO: a work in progress
 * 
 * @param x
 * @param rel_ids
 * @return set of named ancestors and direct descendents
 */
public OWLShuntGraph getSegmentShuntGraph(OWLObject x, List<String> rel_ids) {

    // Collection depot.
    OWLShuntGraph graphSegment = new OWLShuntGraph();

    // Add this node, our seed.
    String topicID = getIdentifier(x);
    String topicLabel = getLabel(x);
    OWLShuntNode tn = new OWLShuntNode(topicID, topicLabel);
    graphSegment.addNode(tn);

    // Next, get all of the named ancestors and add them to our shunt graph.
    graphSegment = addStepwiseAncestorsToShuntGraph(x, graphSegment, rel_ids);

    // Next, get all of the immediate descendents.
    graphSegment = addDirectDescendentsToShuntGraph(x, graphSegment, rel_ids);

    //      
    return graphSegment;
}
项目:OWLAx    文件:OWLCellRenderer.java   
protected Icon getIcon(Object object) {
    if (!renderIcon) {
        return null;
    }
    if (iconObject != null) {
        return owlEditorKit.getWorkspace().getOWLIconProvider().getIcon(iconObject);
    }
    if (object instanceof OWLObject) {
        return owlEditorKit.getWorkspace().getOWLIconProvider().getIcon((OWLObject) object);
    } else {
        return null;
    }
}
项目:minerva    文件:GafToLegoIndividualTranslator.java   
/**
 * @param id
 * @return cls or null
 */
private OWLClass getOwlClass(String id) {
    OWLClass cls = graph.getOWLClassByIdentifier(id);
    if (cls == null) {
        // check alt ids
        OWLObject owlObject = allOWLObjectsByAltId.get(id);
        if (owlObject != null && owlObject instanceof OWLClass) {
            cls = (OWLClass) owlObject;
        }
    }
    return cls;
}
项目:owltools    文件:OWLGraphWrapperEdgesExtended.java   
/**
 * Similar to {@link #getNamedAncestorsWithGCI(OWLObject)} but returning only 
 * {@code OWLClass}es.
 * @param sourceObject  An {@code OWLObject} for which we want to retrieve ancestors 
 *                      through classical relations and through OBO GCI relations.
 * @return  A {@code Set} of {@code OWLClass}s that are ancestors of 
 *          {@code sourceObject} through classical relations and through OBO GCI relations.
 */
public Set<OWLClass> getOWLClassAncestorsWithGCI(OWLObject sourceObject) {
    Set<OWLClass> ancestors = new HashSet<OWLClass>();
    for (OWLNamedObject anc: this.getNamedAncestorsWithGCI(sourceObject)) {
        if (anc instanceof OWLClass) {
            ancestors.add((OWLClass) anc);
        }
    }
    return ancestors;
}
项目:owltools    文件:DescriptionTreeSimilarity.java   
private OWLClassExpression makeClassExpression(OWLObject x) {
    if (x instanceof OWLClassExpression)
        return (OWLClassExpression) x;
    else if (x instanceof OWLNamedIndividual) {
        // TODO - move this to graphwrapper
        Set<OWLNamedIndividual> nis = new HashSet<OWLNamedIndividual>();
        nis.add((OWLNamedIndividual) x);
        return graph.getDataFactory().getOWLObjectOneOf(nis);
    }
    else {
        System.err.println("cannot make CE from:"+x);
    }
    return null;
}
项目:owltools    文件:SimEngine.java   
public void filterObjects(Set<OWLObject> objs) {
    objs.removeAll(nonSignificantObjects());
    Set<OWLObject> rmSet = new HashSet<OWLObject>();
    for (OWLObject obj : objs) {
        if (this.isExcludedFromAnalysis(obj)) {
            rmSet.add(obj);

        }
    }
    objs.removeAll(rmSet);
}
项目:owltools    文件:MaxInfContentOnCaroTest.java   
@Test
public void testCAROPair() throws Exception{
    OWLGraphWrapper  wrapper = getOntologyWrapper("caro.owl");
    Similarity sa = 
        new MaximumInformationContentSimilarity();
    OWLObject a = wrapper.getOWLObjectByIdentifier("CARO:0000066"); // epithelium
    OWLObject b = wrapper.getOWLObjectByIdentifier("CARO:0000040"); // acellular anatomical structure
    run(wrapper,sa,a,b);
}
项目:owltools    文件:MultiSimilarity.java   
@Override
public void calculate(SimEngine simEngine, OWLObject a, OWLObject b)
throws SimilarityAlgorithmException {
    this.simEngine = simEngine;
    createFeatureToAttributeMap();
    calculate(a,b,featureToAttributeMap.get(a),featureToAttributeMap.get(b));
}
项目:jopa    文件:SelectResultSet.java   
private OWLObject getCurrentValue(int columnIndex) throws OntoDriverException {
    ensureOpen();
    if (currentRow == null) {
        throw new IllegalStateException("Current row is null.");
    }
    if (!indexesToVariables.containsKey(columnIndex)) {
        throw new OntoDriverException("No result binding found for index " + columnIndex);
    }
    final Variable<OWLObject> v = indexesToVariables.get(columnIndex);
    final GroundTerm<OWLObject> gt = currentRow.get(v);
    return gt != null ? gt.getWrappedObject() : null;
}
项目:jopa    文件:SelectResultSet.java   
private OWLLiteral getLiteral(String columnLabel) throws OwlapiDriverException {
    final OWLObject currentValue = getCurrentValue(columnLabel);
    if (!(currentValue instanceof OWLLiteral)) {
        throw new BindingValueMismatchException("Value " + currentValue + " is not an OWLLiteral.");
    }
    return (OWLLiteral) currentValue;
}
项目:owltools    文件:OWLGraphWrapperEdges.java   
/**
 * Gets all ancestors that are OWLNamedObjects
 * <p>
 * i.e. excludes anonymous class expressions
 * 
 * @param x
 * @return set of named ancestors
 */
public Set<OWLObject> getNamedAncestors(OWLObject x) {
    Set<OWLObject> ancs = new HashSet<OWLObject>();
    for (OWLGraphEdge e : getOutgoingEdgesClosure(x)) {
        if (e.getTarget() instanceof OWLNamedObject)
            ancs.add(e.getTarget());
    }
    return ancs;
}
项目:jopa    文件:SelectResultSet.java   
private Object owlObjectToObject(OWLObject owlValue) {
    if (owlValue == null) {
        return null;
    }
    if (owlValue instanceof OWLLiteral) {
        return OwlapiUtils.owlLiteralToValue((OWLLiteral) owlValue);
    }
    final Set<OWLEntity> sig = owlValue.getSignature();
    if (sig.isEmpty()) {
        return owlValue.toString();
    } else {
        return URI.create(sig.iterator().next().toStringID());
    }
}
项目:owltools    文件:OWLGraphWrapperEdgesExtended.java   
/**
 * Return the <code>OWLClass</code>es directly descendant of <code>parentClass</code>.
 * This method returns all sources of all edges incoming to <code>parentClass</code>, 
 * that are <code>OWLClass</code>es.
 * 
 * @param parentClass   The {@code OWLClass} for which we want the direct 
 *                      descendant {@code OWLClass}es
 * @return  A <code>Set</code> of <code>OWLClass</code>es being the direct descendants 
 *          of <code>parentClass</code>.
 * @see owltools.graph.OWLGraphWrapperEdges#getIncomingEdges(OWLObject)
 */
public Set<OWLClass> getOWLClassDirectDescendants(OWLClass parentClass) {

    Set<OWLClass> directDescendants = new HashSet<OWLClass>();
    for (OWLGraphEdge incomingEdge: 
            this.getIncomingEdges(parentClass)) {

        OWLObject directDescendant = incomingEdge.getSource();
        if (this.isRealClass(directDescendant)) { 
            directDescendants.add((OWLClass) directDescendant);
        }
    }

    return directDescendants;
}
项目:jopa    文件:AbstractResultSet.java   
public static ResultSet createResultSet(QueryResult<OWLObject> result, Statement statement, String query) {
    if (isAskQuery(query)) {
        return new AskResultSet(result, statement);
    } else {
        return new SelectResultSet(result, statement);
    }
}
项目:jopa    文件:QueryResultGenerator.java   
QueryResult<OWLObject> generate(List<String> variableNames, List<List<Object>> values) {
    final List<Variable<OWLObject>> vars = variableNames.stream().map(name -> {
        final Variable<OWLObject> var = mock(Variable.class);
        when(var.getName()).thenReturn(name);
        return var;
    }).collect(Collectors.toList());
    final QueryResult<OWLObject> result = new QueryResultImpl(vars);
    initData(result, values);
    return result;
}
项目:owltools    文件:SimJSONEngine.java   
protected Map<String,Object> makeObj(OWLObject obj) throws UnknownOWLClassException {
    Map<String,Object> m = new HashMap<String,Object>();
    m.put("id", g.getIdentifier(obj));
    m.put("label", g.getLabel(obj));
    if (obj != null && obj.getClass() == OWLClassImpl.class) {
        Double ic = sos.getInformationContentForAttribute(g.getOWLClass(obj));
        if (ic == null) {
            //LOG.info("Using max(maxIC) for "+g.getIdentifier(obj));
            ic = sos.getSummaryStatistics().max.getMax();
        }
        m.put("IC",ic);
    }
    return m;
}