geneontology / obographs

Basic and Advanced OBO Graphs: specification and reference implementation
63 stars 12 forks source link

About getting nodes in obographs #33

Open yy20716 opened 6 years ago

yy20716 commented 6 years ago

Suppose that we have the following owl snippet.

    <owl:Class rdf:resource="http://purl.obolibrary.org/obo/MONDO_0005017">
        <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">d6</rdfs:label>
    </owl:Class>

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/MONDO_0007648">
        <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/MONDO_0005017"/>
        <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">hereditary diffuse gastric cancer</rdfs:label>
    </owl:Class>

When I parse the above snippet using obograph and request the list of nodes from the obograph object, the list I got contains Subject node only, i.e. in this case MONDO_0007648 only without MONDO_0005017. I would like to know whether this is an intended behavior or I misunderstood something. Is this because of subClassOf? I am using the following codes to retrive node objects.

    OWLOntologyManager m = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = m.loadOntologyFromOntologyDocument(file); // file here is a File object for an owl file.
    FromOwl fromOwl = new FromOwl();
    GraphDocument gd = fromOwl.generateGraphDocument(ontology);
    Graph obograph = gd.getGraphs().get(0);
    List<Node> gNodes = obograph.getNodes();

Any suggestions or tips would be appreciated.

cmungall commented 6 years ago

This sounds like a bug

yy20716 commented 6 years ago

I am sorry but I realized that I put a wrong tag in the above example. I made a copy-and-paste error, i.e.

   <owl:Class rdf:resource="http://purl.obolibrary.org/obo/MONDO_0005017">

but this should be

   <owl:Class rdf:about="http://purl.obolibrary.org/obo/MONDO_0005017">

In other words, because of this resource tag, owlapi does not consider MONDO_0005017 as a class, so obograph does not basically execute the codes that parse OWLDeclarationAxiom and convert them as nodes.

Nonetheless, it would be more intelligent if we could add codes that treat subjects and objects as classes when we encounter rdfs:subClassOf property. The current codes only does this for subject; can I add codes that treat the object as class as well? Thank you.

balhoff commented 6 years ago

I don't think it's valid RDF/XML to use rdf:resource here. If it is used to indicate the object of a predicate, the predicate is the element name. But owl:Class is not a predicate. At least that's my reading of https://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-empty-property-elements

yy20716 commented 6 years ago

Thanks for your clarification. Yes, in other words, owlapi's behavior and interpretation is correct, i.e. rdf:resource should not be used there.