Problem with the onto.search() method

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with the onto.search() method

Martina
Goood afternoon,

I have one problem with the usage of the onto.search() method for my small ontology.
Maybe the solution is trivial as usual in my case :-), but this method works differently for almost the same thing in my ontology.

Problem description in more details:
-------------------------------------------
Fragment of my ontology:
...
      - AutoimmuneDisease
        - LocalImmuneDisease
          - DermatologicAutoimmuneDisease
          - ...
        - OrganLocalisedAutoimmuneDisease
        - SystemicAutoimmuneDisease
 - System
  - BiomedicalSystem
      - Derma
      - EndocrineSystem
      - ...
...

I would like to print all subclasses of the System class from my ontology. I created the following piece of code:
---------------------------------
from owlready2 import *

onto = get_ontology("g:\Vyzkum\Ontologie\OntoProgramovani\OWLReady2\AD-OWLOntology-extension01-rdf-xml.owl").load()
systemList = onto.search(subclass_of=onto.System)
print(systemList)


Result: Everything seems well, because all of the direct subclasses and subclasses of these subclasses are printed.
---------------------------------

The problem is that I would like to do the same for the autoimmune diseases. I would like to print all of the subclasses of the AutoimmuneDisease class. I created the following pieces of code:

---------------------------------
from owlready2 import *

onto = get_ontology("g:\Vyzkum\Ontologie\OntoProgramovani\OWLReady2\AD-OWLOntology-extension01-rdf-xml.owl").load()

adList = onto.search(subclass_of=onto.AutoimmuneDisease)
print(adList)


Result: Only direct subclasses  of the AutoimmuneDisease class (Local..., Organ..., Systemic...) are printed and I do not know why :-(((
---------------------------------

I am sending my ontology with this message and I would be really really happy for any help form you :-)
I am using the Owlready2-0.9.dist-info.
AD-OWLOntology-extension01-rdf-xml.owl

Many greetings and best regards,
Martina
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the onto.search() method

Jiba
Administrator
Hi,

The problem is that the subclass_of relations are not explicitely declared: for example,  DermatologicAutoimmuneDisease  is defined as equivalent to "LocalImmuneDisease and (influences some Derma)". This definition implies that it is a subclass of LocalImmuneDisease, but it is not explicitely stated -- and thus not found by search().

You should explicitely declare the subclass_of relation, for example in Protege.

Best regards,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Problem with the onto.search() method

Martina
Good afternoon,

ouuu, my mistake. I did not notice that the subclass relation is not explicitly represented!!!
Just now everything works perfectly :-)

Thank you a lot for your help!

Best regards,
Martina