Search code examples
javaannotationsontologyowl-api

How to get the annotations of concepts (annotations on class IRIs) with OWLAPI?


In the pato.owl ontology on the website http://www.obofoundry.org/, some concepts has more than one Annotation. For example, concept PATO_0001051 has Label "acute angle to" and the definition: "An angle which is less than 90 degrees". How can I get through owlapi this Definition? Many thanks.

    <owl:Class rdf:about="http://purl.obolibrary.org/obo/PATO_0001051">
       <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">acute angle to</rdfs:label>
       <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/PATO_0002326"/>
       <obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An angle which is less than 90 degrees.</obo:IAO_0000115>
       <oboInOwl:id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PATO:0001051</oboInOwl:id>
       <oboInOwl:hasOBONamespace rdf:datatype="http://www.w3.org/2001/XMLSchema#string">quality</oboInOwl:hasOBONamespace>
       <oboInOwl:inSubset rdf:resource="http://purl.obolibrary.org/obo/pato#relational_slim"/>
       <oboInOwl:inSubset rdf:resource="http://purl.obolibrary.org/obo/pato#value_slim"/>
   </owl:Class>

Solution

  • Dear Artemis and Ignazio, thank you very much for your answers. Here is the answer:

        for(OWLClass owl_class : localOntology.getClassesInSignature(true)){
             for(OWLAnnotationAssertionAxiom annotations:owl_class.getAnnotationAssertionAxioms(localOntology))
                 if(annotations.getProperty().getIRI().getFragment()==null) {
                                System.out.println("definition: "+annotations.getValue());
                                                                            }
                                                             }