owlcs / owlapi

OWL API main repository
822 stars 315 forks source link

how to recognize obsolete classes in NCIT #1029

Closed marwa811 closed 2 years ago

marwa811 commented 2 years ago

Iam working with BioPortal ontologies where sometimes I found classes that are obsolete .. If I found any of them I don't want to consider them.. my question how can my code recognize them in OWL API? In other words, if I have an OWLClass how to check if it is obsolete or not? which function to use?

rwynne commented 2 years ago

Preface: There are many ontologies in BioPortal and not all ontologies express obsolete classes the same way.

The subject of this issue is the NCIT and in NCIT the meaning of Obsolete_Concept should not to be confused with Retired_Concept. The NCI EVS staff are the experts and could provide you input on what obsolete means to your use case. Please reach out to them with any questions: NCIThesaurus@nih.gov.

The following method specific to NCIT, with OWL API functions from version 4.1.4, should return true if the given OWLClass has an AnnotationProperty Concept_Status with value Obsolete_Concept:

private boolean isObsolete(OWLClass c) {
    for (OWLAnnotationAssertionAxiom anno : EntitySearcher.getAnnotationAssertionAxioms(c, this.ontology)) {
        if (anno.getProperty().getIRI().equals("http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#P310") //the IRI for AnnotationProperty Concept_Status
            && anno.getValue().toString().contains("Obsolete_Concept")) { //a valid filler value for the annotation based on Concept-Status-enum
                return true;
        }
    }
    return false;
}
marwa811 commented 2 years ago

Thanks will try this.