0
votes

I have the following owl file and want to retrieve the related data to a given class.

<owl:Class rdf:about="http://purl.obolibrary.org/obo/DOID_0001">
            <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/DOID_11"/>   
            <obo:IAO_11 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A def def def def.</obo:IAO_0000115> 
            <oboInOwl:hasDbXref rdf:datatype="http://www.w3.org/2001/XMLSchema#string">AA:006394</oboInOwl:hasDbXref>
            <oboInOwl:hasExactSynonym rdf:datatype="http://www.w3.org/2001/XMLSchema#string">abcde</oboInOwl:hasExactSynonym> 
            <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">ABCDEFG</rdfs:label>
        </owl:Class>

For example I wanted to retrieve the subClassOf which should be DOID_11 without success using the following code:

//create the reasoning model using the base
 OntModel inf = ModelFactory.createOntologyModel();

 // use the FileManager to find the input file
 InputStream in = FileManager.get().open(inputFileName);
 if ( in == null) {
     throw new IllegalArgumentException("File: " + inputFileName + " not found");
 }

 inf.read( in , "");

 ExtendedIterator <? > classes = inf.listClasses();
 while (classes.hasNext()) {
     OntClass essaClasse = (OntClass) classes.next();

     System.out.println("Classe: " + essaClasse.getLocalName());
     for (Iterator <? > i = essaClasse.listSubClasses(); i.hasNext();) {

         OntClass c = (OntClass) i.next();
         System.out.print("   " + c.getLocalName() + "\n");
     } // end for 
 }

I get just "DOID_0001" instead of "DOID_0001" and "DOID_11". I need also to get all of the other information such as "" and "

1
No, you are wrong. The statement in your ontology is DOID_0001 rdfs:subClassOf DOID_11. That means, DOID_11 is the superclass of ` DOID_0001` not vice versa. And if you ask for all subclasses of DOID_0001 it's indeed only the class itself as trivial inference.UninformedUser
I need just to have the following result: SuperClass: DOID_11, SubClass: DOID_11, Def: A def A def .. , Synonym: abcde, label: ABCDEFG. So I need to retrieve the data as it is in order.StaOver
Ok, but did you understand that what you expected was wrong?UninformedUser
There is no order in RDF resp. OWL. An RDF graph is a set of triples and an OWL ontology a set of OWL axioms respectively. You can retrieve all data for a given subject via SPARQL or via a convenience method, see my updated answerUninformedUser

1 Answers

0
votes

No, you are wrong. The statement in your ontology is

DOID_0001 rdfs:subClassOf DOID_11

That means, DOID_11 is the superclass of DOID_0001 not vice versa. And if you ask for all subclasses of DOID_0001, it's indeed only the class itself as trivial inference.

Update

Statements for each class can be retrieved via

    StmtIterator stmtIterator = inf.listStatements(essaClasse, null, (RDFNode) null);
    while(stmtIterator.hasNext()) {
        Statement st = stmtIterator.next();
        Property p = st.getPredicate();
        RDFNode o = st.getObject();
        System.out.println(p + ":" + o);
    }