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

项目:owltools    文件:FastOwlSim.java   
private <T extends OWLNamedObject> T getDeterministicRepresentative(Node<T> n) {
    T rep = null;
    // find lexical maximal entry as representative node
    for (T entry : n) {
        if (rep == null) {
            rep = entry;
        }
        else {
            // use IRI for comparison
            IRI repIRI = rep.getIRI();
            IRI entryIRI = entry.getIRI();
            if (entryIRI.compareTo(repIRI) > 0) {
                rep = entry;
            }
        }
    }
    return rep;
}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
/**
 * Create a category for a given named object. There are three options:
 * <ol>
 *  <li>use id space to lookup category string in the id space map</li>
 *  <li>use OBO namespace, if the is space is in useNamespace set</li>
 *  <li>fallback: use id space prefix (string before first colon)</li>
 * </ol>
 * 
 * @param named
 * @param idspaceMappings
 * @param useNamespace
 * @param useFallback if false ignore fall-back
 * @return category or null
 */
public String categorizeObject(OWLNamedObject named,  Map<String,String> idspaceMappings, 
        Set<String> useNamespace, boolean useFallback){
    String result = null;
    String idSpace = getIdspace(named.getIRI());
    if (idSpace != null) {
        if (idspaceMappings.containsKey(idSpace)) {
            result = idspaceMappings.get(idSpace);
        }
        else if (useNamespace.contains(idSpace)) {
            result = getNamespace(named);
        }
        else if (useFallback){
            result = idSpace;
        }
        // normalize
        if (result != null) {
            // replace backslash, dash, underscore, or slash with a whitespace
            result = result.replaceAll("[\\-_/]", " ");
        }
    }
    return result;
}
项目:owltools    文件:CompactGraphClosureRenderer.java   
public void render(OWLGraphEdge e) {
    if (!(e.getTarget() instanceof OWLNamedObject)) {
        return;
    }
    sep();
    int n = 0;
    for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
        if (n>0) {
            stream.print(",");
        }
        if (qp.hasProperty()) {
            crender(qp.getProperty());
            stream.print(" ");
        }
        stream.print(qp.getQuantifier());

        n++;
    }
    stream.print(",");
    crender(e.getTarget());
    stream.print(","+e.getDistance());
}
项目: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    文件:GraphClosureRenderer.java   
public void render(OWLGraphEdge e) {
    if (!(e.getTarget() instanceof OWLNamedObject)) {
        return;
    }
    print(e.getSource());
    sep();
    int n = 0;
    for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
        if (n>0) {
            stream.print(", ");
        }
        if (qp.hasProperty()) {
            print(qp.getProperty());
            stream.print(" ");
        }
        stream.print(qp.getQuantifier());

        n++;
    }
    sep();
    stream.print(e.getDistance());
    sep();
    print(e.getTarget());
    nl();

}
项目:owltools    文件:EdgeTableRenderer.java   
public void render(OWLGraphWrapper g) {
    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    文件:EdgeTableRenderer.java   
private void render(OWLNamedObject obj) {
    String id = graph.getIdentifier(obj);
    for (OWLGraphEdge e : graph.getOutgoingEdges(obj)) {
        OWLQuantifiedProperty qp = e.getSingleQuantifiedProperty();
        String r;
        if (qp.getProperty() != null) {
            r = graph.getIdentifier(qp.getProperty());
        }
        else if (qp.isSubClassOf()) {
            r = "is_a";
        }
        else if (qp.isInstanceOf()) {
            r = "a";
        }
        else {
            continue;
        }
        print(id);
        sep();
        print(r);
        sep();
        print(graph.getIdentifier(e.getTarget()));
        nl();

    }
}
项目:BioSolr    文件:AbstractOWLOntologyLoader.java   
private void indexEquivalentRelations(OWLClass owlClass) throws OWLOntologyCreationException {
    OWLReasoner reasoner = getOWLReasoner(ontology);

    // get direct children
    addEquivalentTerms(owlClass.getIRI(),
            reasoner.getEquivalentClasses(owlClass).getEntities().stream()
                    .map(OWLNamedObject::getIRI)
                    .collect(Collectors.toSet()));

    Set<String> relatedDescriptions = new HashSet<>();

    for (OWLClassExpression expression : owlClass.getEquivalentClasses(getManager().getOntologies())) {
        if (expression.isAnonymous()) {
            relatedDescriptions.add(manSyntaxRenderer.render(expression));
        }
    }

    if (!relatedDescriptions.isEmpty()) {
        addEquivalentClassDescriptions(owlClass.getIRI(), relatedDescriptions);
    }

}
项目:geoxygene    文件:OntologyBrowser.java   
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus1) {

  super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row,
      hasFocus1);
  if (value instanceof OWLNamedObject) {
    // this.setText(((OWLNamedObject) value).getIRI().getFragment());
    this.setText(((OWLNamedObject) value).getIRI().getFragment().toString());
  }

  return this;
}
项目:minerva    文件:OperationsTools.java   
/**
 * @param modelId
 * @param model
 * @param externalLookupService
 * @param inferenceProvider
 * @param curieHandler
 * @return renderer
 */
public static MolecularModelJsonRenderer createModelRenderer(
        final String modelId,
        final OWLOntology model, 
        final ExternalLookupService externalLookupService,
        final InferenceProvider inferenceProvider,
        final CurieHandler curieHandler) {

    MolecularModelJsonRenderer renderer;
    if (externalLookupService != null) {
        renderer = new MolecularModelJsonRenderer(modelId, model, inferenceProvider, curieHandler) {

            @Override
            protected String getLabel(OWLNamedObject i, String id) {
                String label = super.getLabel(i, id);
                if (label == null ) {
                    List<LookupEntry> lookup = externalLookupService.lookup(i.getIRI());
                    if (lookup != null && !lookup.isEmpty()) {
                        LookupEntry entry = lookup.iterator().next();
                        label = entry.label;
                    }
                }
                return label;
            }
        };
    }
    else {
        renderer = new MolecularModelJsonRenderer(modelId, model, inferenceProvider, curieHandler);
    }
    return renderer;
}
项目:owltools    文件:OWLHandler.java   
private void output(OWLObject obj) throws IOException {
    String fmt = getFormat();
    if (fmt.equals("pretty"))
        outputLine(owlpp.render(obj));
    else if (fmt.equals("json")) {
        //JSONPrinter jsonp = new JSONPrinter(response.getWriter());
        //jsonp.render(obj);
        cache(obj);
    }
    else if (isOWLOntologyFormat()) {
        // TODO - place objects into ontology, eg as subclass of result
        outputLine(obj.toString());
    }
    else {
        // TODO - do this more generically, e.g. within owlpp
        if (getParam("idstyle") != null && obj instanceof OWLNamedObject) {
            if (getParam("idstyle").toLowerCase().equals("obo")) {
                outputLine(graph.getIdentifier(obj));
            }
            else {
                outputLine(obj.toString());
            }
        }
        else 
            print(obj.toString());
    }
}
项目:owltools    文件:Sim2CommandRunner.java   
/**
 * by default, i and j are comparable only if i>j (i.e. self and symmetric
 * comparisons not permitted). If {@link SimConfigurationProperty#bidirectional}
 * is true, then self and symmetric are permitted.
 * 
 * if {@link SimConfigurationProperty#compare} is set to a string "A, B" then
 * only comparisons between objects with ID spaces A and B are compared.
 * 
 * This method can be applied to classes or to individuals. It is designed
 * to be use in an all x all comparison of either classes or individuals
 * 
 * it can be called with a null value for j. If j==null, then isComparable
 * is true if i is comparable to anything. This will fail if the first
 * entry in the compare property does not match the ID space of i.
 * 
 * @param i - not null
 * @param j - may be null
 * @return true if i and j are comparable
 */
private boolean isComparable(OWLNamedObject i, OWLNamedObject j) {
    if (g.getIsObsolete(i))
        return false;
    if (j != null && g.getIsObsolete(j))
        return false;
    String cmp = getProperty(SimConfigurationProperty.compare);
    if (cmp == null) {
        if (j==null)
            return true;
        Boolean bidi = getPropertyAsBoolean(SimConfigurationProperty.bidirectional);
        if (bidi == null || !bidi) {
            return i.compareTo(j) > 0;
        }
        else {
            return true;
        }

    } else {
        String[] idspaces = cmp.split(",");
        if (i.getIRI().toString().contains("/" + idspaces[0] + "_")
                && (j==null || j.getIRI().toString().contains("/" + idspaces[1] + "_"))) {
            return true;
        } else {
            return false;
        }
    }
}
项目:owltools    文件:SimEngine.java   
public Set<OWLObject> makeNonRedundant(Set<OWLObject> objs, boolean prioritizeNamedClasses) {
    // redundant set
    Set<OWLObject> rs = new HashSet<OWLObject>();

    // check each object to see if it's redundant
    for (OWLObject obj : objs) {
        Set<OWLObject> ancs = getAncestors(obj);
        ancs.retainAll(objs);
        ancs.remove(obj);

        for (OWLObject anc : ancs) {
            // we know that obj<anc,
            // anc is therefore redundant
            // (if it appears in the original set)

            // the exception is for cycles
            if (getAncestors(anc).contains(obj)) {
                // we have a cycle: anc subsumed by obj via the directly preceding test;
                //                  obj subsumed by anc via the getAncestors call

                // for cycles, keep both unless we want to prioritize named classes
                if (prioritizeNamedClasses) {
                    if (anc instanceof OWLAnonymousClassExpression && obj instanceof OWLNamedObject) {
                        rs.add(anc);
                    }
                }
            }
            else {
                // not a cycle - schedule redundant class for removal
                rs.add(anc);
            }
        }
    }
    objs.removeAll(rs);
    return objs;
}
项目:owltools    文件:Similarity.java   
public void print(PrintStream s, OWLObject x) {
    if (x instanceof OWLNamedObject) {
        String label = simEngine.getGraph().getLabel(x);
        if (label == null)
            s.print(x.toString());
        else
            s.print(x.toString()+" \""+label+"\"");
    }
    else {
        printDescription(s,x);
    }
}
项目:owltools    文件:Mooncat.java   
/**
 * Check, if the named object has the annotation property IAO:0000412, 
 * declaring the object as imported.
 * 
 * @param named
 * @param ontology
 * @return true if the item has the annotation property IAO:0000412
 */
public static boolean isImportMarkedEntity(OWLNamedObject named, OWLOntology ontology) {
    for (OWLAnnotationAssertionAxiom axiom : ontology.getAnnotationAssertionAxioms(named.getIRI())) {
        OWLAnnotationProperty property = axiom.getProperty();
        if (importedMarkerIRI.equals(property.getIRI())) {
            return true;
        }
    }
    return false;
}
项目:owltools    文件:BridgeExtractor.java   
private String getOntId(OWLNamedObject c) {
    String iriStr = c.getIRI().toString();
    iriStr = iriStr.replaceAll(".*/", ""); // up to final slash
    iriStr = iriStr.replaceAll("_\\d+",""); // assumes obo-style
    //LOG.info(c + " ==> "+iriStr);
    return iriStr.toLowerCase();
}
项目:owltools    文件:TemplatedTransformer.java   
private OWLClassExpression replaceVariables(OWLClassExpression inx,
        BindingSet bset) {
    if (inx instanceof OWLNamedObject) {
        IRI y = replaceIRI(((OWLNamedObject)inx).getIRI(), bset);
        if (inx instanceof OWLClass) {
            return getOWLDataFactory().getOWLClass(y);
        }
    }
    else if (inx instanceof OWLObjectSomeValuesFrom) {
        OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)inx;
        return getOWLDataFactory().getOWLObjectSomeValuesFrom(
                replaceVariables(svf.getProperty(),bset),
                replaceVariables(svf.getFiller(),bset));

    }
    else if (inx instanceof OWLObjectIntersectionOf) {
        Set<OWLClassExpression> es = new HashSet<OWLClassExpression>();
        for (OWLClassExpression e : ((OWLObjectIntersectionOf)inx).getOperands()) {
            es.add(replaceVariables(e, bset));
        }
        return getOWLDataFactory().getOWLObjectIntersectionOf(es);
    }
    else {

    }
    return null;
}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
/**
 * Return the names of the asserted subClasses of the cls (Class) 
 * passed in the argument
 * 
 * 
 * @param cls
 * @return array of of strings
 */
@Deprecated
public String[] getSubClassesNames(OWLClass cls){
    Set<OWLClassExpression> st = OwlHelper.getSubClasses(cls, sourceOntology);


    List<String> ar = new ArrayList<String>();
    for(OWLClassExpression ce: st){
        if(ce instanceof OWLNamedObject)
            ar.add(getLabel(ce)); 
    }

    return ar.toArray(new String[ar.size()]);
}
项目:owltools    文件:OWLGraphWrapperEdgesAdvanced.java   
public String categorizeNamespace(OWLObject c, Map<String, Object> configuration) {
    String result = null;
    if (c instanceof OWLNamedObject) {
        Map<String, String> idspaceMappings = new HashMap<String, String>();
        Set<String> useNamespace = new HashSet<String>();
        boolean useFallback = true;
        // configuration
        if (configuration != null) {
            // check mapped id spaces
            Object mapped = configuration.get("idspace-map");
            if (mapped != null && mapped instanceof Map<?, ?>) {
                for(Entry<?, ?> entry : ((Map<?, ?>) mapped).entrySet()) {
                    idspaceMappings.put(entry.getKey().toString(), entry.getValue().toString());
                }
            }

            // check use namespace
            Object useNamespaceConfig = configuration.get("use-namespace");
            if (useNamespaceConfig != null && useNamespaceConfig instanceof Iterable<?>) {
                for (Object o : (Iterable<?>)useNamespaceConfig) {
                    useNamespace.add(o.toString());
                }
            }

            // check use fallback
            Object fallbackConfig = configuration.get("use-fallback");
            if (fallbackConfig != null) {
                String fallbackString = fallbackConfig.toString();
                if (Boolean.FALSE.toString().equalsIgnoreCase(fallbackString)) {
                    useFallback = false;
                }
            }
        }
        result = categorizeObject((OWLNamedObject) c, idspaceMappings, useNamespace, useFallback);
    }
    return result;

}
项目:owltools    文件:OWLGraphWrapperExtended.java   
public String getLabelOrDisplayId(OWLObject c) {
    String label = getLabel(c);
    if (label == null) {
        if (c instanceof OWLNamedObject) {
            OWLNamedObject nc = (OWLNamedObject)c;
            label = nc.getIRI().getFragment();
        }
        else {
            label = c.toString();
        }
    }
    return label;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * Gets the OBO-style ID of the specified object. E.g. "GO:0008150". Set the
 * parameter useShorthand to false to ignore shorthands.
 * 
 * @param owlObject
 * @param useShorthand
 * @return OBO-style identifier, using obo2owl mapping
 */
public String getIdentifier(OWLObject owlObject, boolean useShorthand) {
    if (useShorthand) {
        return getIdentifier(owlObject);
    }
    if (owlObject instanceof OWLNamedObject) {
        return Owl2Obo.getIdentifier(((OWLNamedObject) owlObject).getIRI());
    }
    return null;
}
项目:owltools    文件:OWLGraphWrapperExtended.java   
/**
 * Generate a OboGraphs JSON ontology blob for the local axioms for an object.
 * 
 * This will include
 * 
 *  - all logical axioms about the object
 *  - all annotations for all entities in the signature
 *  
 * In other words, direct parents plus labels and other metadata on all entities
 * 
 * @param obj
 * @return JSON string
 * @throws JsonProcessingException
 * @throws OWLOntologyCreationException
 */
public String getOboGraphJSONString(OWLObject obj) throws JsonProcessingException, OWLOntologyCreationException {
       FromOwl fromOwl = new FromOwl();
       OWLOntologyManager m = sourceOntology.getOWLOntologyManager();
       if (obj instanceof OWLNamedObject) {
           OWLNamedObject nobj = (OWLNamedObject)obj;
           OWLOntology ont = m.createOntology(nobj.getIRI());
           Set<OWLAxiom> axioms = new HashSet<>();
           if (nobj instanceof OWLClass) {
               axioms.addAll(sourceOntology.getAxioms((OWLClass)nobj, Imports.INCLUDED));
           }
           else if (nobj instanceof OWLObjectProperty) {
               axioms.addAll(sourceOntology.getAxioms((OWLObjectProperty)nobj, Imports.INCLUDED));
           }
           m.addAxioms(ont, axioms);
           axioms = new HashSet<>();
           for (OWLEntity e : ont.getSignature()) {
               axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(e.getIRI()));
           }
           axioms.addAll(sourceOntology.getAnnotationAssertionAxioms(nobj.getIRI()));
           m.addAxioms(ont, axioms);

           GraphDocument gd = fromOwl.generateGraphDocument(ont);
           return OgJsonGenerator.render(gd);
       }
       else {
           return "{}";
       }

}
项目:owltools    文件:OWLGraphWrapperEdges.java   
public boolean isExcludeEdge(OWLGraphEdge edge) {

        if (config.graphEdgeExcludeSet != null ||
                config.graphEdgeIncludeSet != null) {
            for (OWLQuantifiedProperty qp : edge.getQuantifiedPropertyList()) {
                if (isExcluded(qp)) {
                    LOG.debug("excluded:"+edge+" based on: "+qp);
                    return true;
                }
            }
        }

        OWLObject t = edge.getTarget();
        if (t != null) {
            if (t instanceof OWLNamedObject) {
                OWLNamedObject nt = (OWLNamedObject) t;
                // TODO
                if (nt.getIRI().toString().startsWith("http://www.ifomis.org/bfo"))
                    return true;
                if (t instanceof OWLClass && t.equals(getDataFactory().getOWLThing())) {
                    return true;
                }

            }
        }
        return false;
    }
项目: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;
}
项目: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    文件:CompactGraphClosureRenderer.java   
protected void crender(OWLObject obj) {
    String s = ((OWLNamedObject) obj).getIRI().toString();
    if (s.startsWith(base)) {
        stream.print(s.replaceFirst(base, ""));
    }
    else {
        stream.print(s);
    }
}
项目:owltools    文件:ChadoGraphClosureRenderer.java   
public void render(OWLGraphEdge e) {
    if (!(e.getTarget() instanceof OWLNamedObject)) {
        return;
    }
    if (e.getQuantifiedPropertyList().size() != 1 && !isChain) {
        return;
    }
    StringBuffer rel = new StringBuffer("");
    int n = 0;
    for (OWLQuantifiedProperty qp : e.getQuantifiedPropertyList()) {
        //OWLQuantifiedProperty qp = e.getQuantifiedPropertyList().get(0);
        if (n > 0) {
            rel.append(",");
        }
        if (qp.isSubClassOf()) {
            rel.append("OBO_REL:is_a");
        }
        else if (qp.isSomeValuesFrom()) {
            rel.append(graph.getIdentifier(qp.getProperty()));
        }
        else {
            return;
        }
        n++;
    }
    stream.print(graph.getIdentifier(e.getSource()));
    sep();

    stream.print(rel);
    sep();
    stream.print(e.getDistance());
    sep();
    stream.print(graph.getIdentifier(e.getTarget()));
    nl();

}
项目:owltools    文件:TableRenderer.java   
private void render(OWLNamedObject obj) {
    print(obj.getIRI().toString());
    sep();
    print(graph.getLabel(obj));
    sep();
    print(graph.getDef(obj));
    nl();
}
项目:owltools    文件:OWLGraphWrapperEdgeTest.java   
@Test
public void testEdgesNR() throws Exception {
    OWLGraphWrapper wrapper = getGraph("graph/lf-apoptosis.obo");

    OWLObject x1 = wrapper.getOWLClassByIdentifier("GO:1990086");

    // we expect this to be true by default
    assertTrue(wrapper.config.isGraphReasonedAndRelaxed);

    int n=0;
    for (OWLGraphEdge e : wrapper.getOutgoingEdges(x1)) {
        n++;
        OWLObject t = e.getTarget();

        if (t instanceof OWLNamedObject){        


            // Figure out object the bits.
            String objectID = wrapper.getIdentifier(t);
            String elabel = wrapper.getEdgeLabel(e);

            if( objectID.equals("GO:1904019") ){
                assertEquals("expected direct superclass found", elabel, "is_a");                  
               } else if( objectID.equals("CL:0011004") ){
                   assertEquals("expected occurs_in link found", elabel, "occurs in");
               } else if( objectID.equals("GO:0006915") ){
                   fail("indirect superclasses not expcted with graph is reasoned and reduced");
            }else{
                fail("I didn't expect this: " + objectID);
            }
        }
    }
    assertEquals("I expected to get 2 links", 2, n);


}
项目:owltools    文件:OWLGraphGOTest.java   
@Test
public void testGOGraph1() throws Exception{

    //
    OWLObject x1 = wrapper.getOWLClassByIdentifier("GO:0022008");

    // In this loop we're checking that GO:0022008 has two known parents, one is_a and one part_of.
    // Anything else is an error.
    for (OWLGraphEdge e : wrapper.getOutgoingEdges(x1)) {
        OWLObject t = e.getTarget();

        if (t instanceof OWLNamedObject){               

            // Figure out object the bits.
            String objectID = wrapper.getIdentifier(t);
            //String objectLabel = wrapper.getLabel(t);
            String elabel = wrapper.getEdgeLabel(e);

            if( objectID.equals("GO:0030154") ){
                assertEquals("GO:0030154 part_of parent of GO_0022008:", elabel, "is_a");                   
            }else if( objectID.equals("GO:0007399") ){
                assertEquals("GO:0007399 part_of parent of GO_0022008:", elabel, "part_of");
            }else{
                fail("not a parent of GO_0022008: " + objectID);
            }
        }
    }
}
项目:owltools    文件:OWLGraphGOTest.java   
@Test
public void testGOGraph2() throws Exception{

    // 
    OWLObject x2 = wrapper.getOWLClassByIdentifier("GO:0007399");

    // In this loop we're checking that GO:0007399, known from above, has GO:0022008 as a part_of child somewhere.
    // Anything else is an error.
    boolean kid_p = false;
    final Set<OWLGraphEdge> incomingEdges = wrapper.getIncomingEdges(x2);
    for (OWLGraphEdge e : incomingEdges) {
        OWLObject s = e.getSource();

        if (s instanceof OWLNamedObject){               

            // Figure out subject the bits.
            String subjectID = wrapper.getIdentifier(s);
            //String subjectLabel = wrapper.getLabel(s);
            String elabel = wrapper.getEdgeLabel(e);

            if( subjectID.equals("GO:0022008") ){
                assertEquals("GO:0022008 part_of child of GO_0007399 (saw: " + elabel + ")", elabel, "part_of");
                kid_p = true;
            }
        }
    }
    assertTrue("saw GO:0022008 as a child of GO_0007399:", kid_p);
}
项目:owltools    文件:MarkdownRenderer.java   
private void renderControlledAnnotations(OWLNamedObject c) {
    Set<OWLAnnotationAssertionAxiom> annotationAxioms = 
            ontology.getAnnotationAssertionAxioms(c.getIRI());
    renderAnnotationAxiom("Label", OWLRDFVocabulary.RDFS_LABEL.getIRI(), annotationAxioms);
    renderAnnotationAxiom("Definition", Obo2OWLVocabulary.IRI_IAO_0000115.getIRI(), annotationAxioms);
    renderAnnotationAxiom("Comment", OWLRDFVocabulary.RDFS_COMMENT.getIRI(), annotationAxioms);

    renderSection("Synonyms");

    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_hasExactSynonym.getIRI(), 
            annotationAxioms);
    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_hasBroadSynonym.getIRI(), 
            annotationAxioms);
    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_hasNarrowSynonym.getIRI(), 
            annotationAxioms);
    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_hasRelatedSynonym.getIRI(), 
            annotationAxioms);

    renderSection("Cross-references");

    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_hasDbXref.getIRI(), 
            annotationAxioms);

    renderSection("Subsets");

    renderAnnotationAxioms("", 
            Obo2OWLVocabulary.IRI_OIO_inSubset.getIRI(), 
            annotationAxioms);      
}
项目:owltools    文件:MarkdownRenderer.java   
private String getLabelOrId(OWLNamedObject ob) {
    String label = getLabel(ob);
    if (label == null) {
        return getId(ob);
    }
    else {
        return label;
    }
}
项目:owltools    文件:MarkdownRenderer.java   
private String getLabel(OWLNamedObject ob) {
    String label = null;
    for (OWLAnnotationAssertionAxiom aaa : ontology.getAnnotationAssertionAxioms(ob.getIRI())) {
        if (aaa.getProperty().isLabel()) {
            label = generateText(aaa.getValue());
            break;
        }
    }
    return label;

}
项目:owltools    文件:MarkdownRenderer.java   
private String getMarkdownLink(OWLObject obj, String pathToRoot) {
    if (obj instanceof OWLNamedObject) {
        OWLNamedObject s = (OWLNamedObject)obj;
        String id = getId(s);
        String rpath = pathToRoot+getRelativePath(id);
        if (rpath.length() == 0) {
            // everything is in same directory; no need for "/"
            return "["+getLabelOrId(s)+"]("+id+".md)";
        }
        return "["+getLabelOrId(s)+"]("+rpath+"/"+id+".md)";
    }
    else {
        return generateText(obj);
    }
}
项目:ppinot    文件:IdOwlConversor.java   
public Set<String> toId(Set<? extends OWLNamedObject> entities) {
    Set<String> result = new HashSet<String>();
    for(OWLNamedObject i: entities) {
        result.add(i.getIRI().getFragment());
    }
    return result;

}
项目:minerva    文件:MolecularModelJsonRenderer.java   
protected String getLabel(OWLNamedObject i, String id) {
    return graph.getLabel(i);
}
项目:owltools    文件:Similarity.java   
public Set<OWLAxiom> translateResultsToOWLAxioms() {

        System.out.println("TRANSLATING TO OWL AXIOM:"+this);
        OWLGraphWrapper graph = simEngine.getGraph();
        Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();

        OWLDataFactory df = graph.getDataFactory();
        if (!(a instanceof OWLNamedObject)) {
            System.err.println(a+ "not named - cant write OWL results");
            return axioms;
        }
        if (!(b instanceof OWLNamedObject)) {
            System.err.println(b+ "not named - cant write OWL results");
            return axioms;
        }
        IRI ia = ((OWLNamedObject) a).getIRI();
        IRI ib = ((OWLNamedObject) b).getIRI();
        String[] toksA = splitIRI(ia);
        String[] toksB = splitIRI(ib);
        String id = toksA[0]+toksA[1]+"-vs-"+toksB[1];

        persistentIRI = IRI.create(id);

        // each similarity is stored as an individual of class similarity_relationship
        OWLNamedIndividual result = df.getOWLNamedIndividual(persistentIRI);
        OWLClass ac = df.getOWLClass(annotationIRI("similarity_relationship"));
        axioms.add(df.getOWLClassAssertionAxiom(ac, result));
        axioms.add(df.getOWLAnnotationAssertionAxiom(df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()),
                result.getIRI(), 
                df.getOWLLiteral("Similarity relationship between "+simEngine.label(a)+" and "+simEngine.label(b))));

        // each object in the pair is connected to the similarity
        OWLAnnotationProperty p = df.getOWLAnnotationProperty(annotationIRI("has_similarity_relationship"));
        axioms.add(df.getOWLAnnotationAssertionAxiom(p, ((OWLNamedObject) a).getIRI(), result.getIRI()));
        axioms.add(df.getOWLAnnotationAssertionAxiom(p, ((OWLNamedObject) b).getIRI(), result.getIRI()));

        // every similarity has a score
        OWLAnnotationProperty sp = df.getOWLAnnotationProperty(annotationIRI("has_score"));
        axioms.add(df.getOWLAnnotationAssertionAxiom(sp, result.getIRI(), df.getOWLLiteral(score)));

        translateResultsToOWLAxioms(id, result, axioms);

        return axioms;
    }
项目:owltools    文件:Reporter.java   
private void printOWLObject(OWLObject obj, String del) {
    String id;
    if (obj instanceof OWLNamedObject) {
        IRI iri = ((OWLNamedObject)obj).getIRI();
        if (iri.getFragment() != null) {
            id = iri.getFragment();
        }
        else {
            id = iri.toString();
            id = id.replaceAll(".*/", "");
        }
    }
    else {
        /*
        if (obj instanceof OWLObjectIntersectionOf) {
            s.print("and");
            for (OWLClassExpression sx : ((OWLObjectIntersectionOf)x).getOperands()) {
                printX(s, sx, depth+1);
            }
        }
        else if (x instanceof OWLObjectUnionOf) {
            s.print("or");
            for (OWLClassExpression sx : ((OWLObjectUnionOf)x).getOperands()) {
                printX(s, sx, depth+1);
            }
        }
        else if (x instanceof OWLQuantifiedRestriction) {
            OWLQuantifiedRestriction qr = (OWLQuantifiedRestriction)x;
            s.print(qr.getProperty().toString()+" "+qr.getClassExpressionType());
            printX(s, qr.getFiller(), depth+1);
        }
        */

        // todo - show class expressions
        id = obj.toString();
    }
    printStream.print(id);
    String label = graph.getLabel(obj);
    if (label == null) {
        label = "";
    }
    printStream.print(del);
    printStream.print("\'"+label+"\'");     
}
项目:owltools    文件:OWLRenderer.java   
@Override
@Deprecated
public void printAttributeSim(AttributesSimScores simScores, OWLGraphWrapper graph)
{
    this.graph = graph;

    OWLClass a = simScores.a;
    OWLClass b = simScores.b;

    IRI ai = a.getIRI();
    IRI bi = b.getIRI();
    //addLabel(ai, graph.getLabel(a));
    //addLabel(bi, graph.getLabel(b));

    IRI mi = IRI.create(ai + "-" + graph.getIdentifier(b));
    String mlabel = "match to "+graph.getLabel(b)+ " from "+graph.getLabel(a);
    addType(mi, "match");

    addMatch(ai, mi);
    addMatch(bi, mi);

    OWLIndividual m = getOWLDataFactory().getOWLNamedIndividual(mi);



    //scores
    if (simScores.simJScore != null) {
        mlabel += " EquivScore=" + doubleRenderer.format(simScores.simJScore);
        addScore(m, Metric.SIMJ.toString(), simScores.simJScore);
    }
    if (simScores.AsymSimJScore != null) {
        mlabel += " SubclassScore=" + doubleRenderer.format(simScores.AsymSimJScore);
        addScore(m, "AsymmetricSimJ", simScores.AsymSimJScore);
    }

    ScoreAttributePair lcs = simScores.lcsScore;
    if (lcs != null) {
        // LCS points to a class so we use an AP
        addFact(mi, getIRI("LCS"),  ((OWLNamedObject) lcs.attributeClass).getIRI());
        addScore(m, Metric.LCSIC.toString(), lcs.score);
    }

    addLabel(mi, mlabel);

}