I have a problem with simple queries like subclass_of, is_a, type, etc.
I have created the ontology in the Protege 5 (rdf/xml syntax). It is about autoimmune diseases.
I can see that my Ontology IRI is http://www.autoimmunediseases-ontology/ in the Protege tab. Classes have the same IRI as ontology, ... of course ... the end of their IRI is different according to the name of the class, etc. My goal is to print all subclasses of the class named Symptom. This class has the following IRI http://www.autoimmunediseases-ontology/Symptom.
I wrote the following code with the Owlready2 and Python 3 where the first three printing methods are only for testing purposes:
from owlready2 import *
The output of the above mentioned code is that nothing is displayed, but I am sure that the Symptom class has 10 subclasses. I feel that the problem can be in the namespaces, but I am not sure. I have already read everything about namespaces and Owlready, but this did not help me.
I would be very very glad for any feedback.
Thank you a lot in advance.
.search() can find any entity, including individuals and classes.
I've started investigating your problem, and I found some bugs related to ontologies whose IRI ends with /(which is your case). I fixed those bugs in the development version on BitBucket, could you try it ?
It it still don't work, please send me your ontology (or at least a small part).
thank you very much for your fast feedback!
I tried to instal the new version of the OWLReady2 (https://bitbucket.org/jibalamy/owlready2/overview). The problem still exist, but one difference occurred. The following error appeared: "TypeError: descriptor '_obj' for 'CallbackList' objects doesn't apply to 'CallbackList' object."
I am sending my small ontology about autoimmune diseases (AD-OWLOntology-rdf-xml-jiba.owl) to you.
I would be very glad for any feedback. Maybe, I make mistake somewhere, but I do not know where :-( :-)
Ontology was developed in the Protégé 5.2.0. I use the Anaconda software for working with the OWLReady2.
Best regards and many thanks for any help,
thank you for your feedback! If I look into the documentation (https://pythonhosted.org/Owlready2/onto.html#simple-queries) there is the information that search() method with the subclass_of keyword should search subclasses of the particular class. The symptom class has several subclasses in my ontology, but the search method did not search them.
I would like not to use the Protégé, because I would like to build own application which will be able to work with the ontology without the Protégé.
thank you a lot for your feedback! I think that you will laugh, because I forgot the print() method before onto.search(subclass_of = onto. Symptom) :-o :-o Really trivial mistake! It works just now :-))
I did not see this mistake at all :-))