Administrator
|
Hello,
There was a bug on imported ontologies, in particular when the ontology is loaded from its filename (instead of its IRI), or when it internal name changed during load (which is the case if the IRI is not of the basic form xxx.owl, such as in your example). I've fixed the bug in the development version of OwlReady2 on BitBucket. Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 > Hello, > > I am having difficulties working with imported ontologies. Specifically I > used Protege to define some ontology which imports other ontologies. > > I was expecting to be able to access these ontologies using the > /onto.imported_ontologies / attribute but this one only returns an empty > list. > > I can otherwise access the classes, attributes etc without a problem. > > Is there something I missed, especially with respect to namespace handling > in this case ? > > Cheers, > Guillaume > > owl file beginning: > <?xml version="1.0"?> > <rdf:RDF > xmlns="http://www.definiens.com/ontologies/TissuePhenomicsOntology#" > xml:base="http://www.definiens.com/ontologies/TissuePhenomicsOntology" > xmlns:uberon="http://purl.obolibrary.org/obo/uberon#" > xmlns:owl="http://www.w3.org/2002/07/owl#" > xmlns:oboInOwl="http://www.geneontology.org/formats/oboInOwl#" > xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#" > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > xmlns:x_1.1="http://purl.org/dc/elements/1.1/" > xmlns:ubprop="http://purl.obolibrary.org/obo/ubprop#" > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:doap="http://usefulinc.com/ns/doap#" > xmlns:xml="http://www.w3.org/XML/1998/namespace" > xmlns:pato="http://purl.obolibrary.org/obo/pato#" > xmlns:uo="http://purl.obolibrary.org/obo/uo#" > xmlns:obo="http://purl.obolibrary.org/obo/" > xmlns:foaf="http://xmlns.com/foaf/0.1/"> > <owl:Ontology > rdf:about="http://www.definiens.com/ontologies/TissuePhenomicsOntology"> > <owl:versionIRI > rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/0.1"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/uo/releases/2018-03-24/uo.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/obi/2018-02-12/obi.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/pato/releases/2018-03-28/pato.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/cl/releases/2017-12-11/cl.owl"/> > <owl:versionInfo > rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.1</owl:versionInfo> > <rdfs:isDefinedBy>[hidden email]</rdfs:isDefinedBy> > </owl:Ontology> > > [...] > > > > > > _______________________________________________ > If you reply to this email, your message will be added to the discussion below: > http://owlready.8326.n8.nabble.com/handling-of-imported-ontology-tp273.html > To start a new topic under Owlready, email [hidden email] > To unsubscribe from Owlready, visit |
Bonjour Jean-Baptiste,
Somehow I could not get it to work. After removing the existing installed version and installing the one I cloned from BitBucket I run into the following error: Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 181.4203.13\helpers\pydev\pydev_run_in_console.py", line 53, in run_file pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files\JetBrains\PyCharm 181.4203.13\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "C:/workspace/TissuePhenomicsOntologyDemonstrator/visualisationPrototype/ontoSerializer.py", line 9, in <module> tpo = god.TPOnto() File "C:\workspace\TissuePhenomicsOntologyDemonstrator\ontologyHelpers\getOntologyData.py", line 60, in TPOnto tpo.load(only_local=True) File "C:\winPython_365_onlyHoloViews\python-3.6.5\lib\site-packages\owlready2-0.8-py3.6.egg\owlready2\namespace.py", line 502, in load self._load_properties() File "C:\winPython_365_onlyHoloViews\python-3.6.5\lib\site-packages\owlready2-0.8-py3.6.egg\owlready2\namespace.py", line 527, in _load_properties props.append(Prop.python_name) File "C:\winPython_365_onlyHoloViews\python-3.6.5\lib\site-packages\owlready2-0.8-py3.6.egg\owlready2\entity.py", line 355, in __getattr__ if Prop is None: raise AttributeError("'%s' property is not defined." % attr) AttributeError: 'python_name' property is not defined. Indeed my ontology imports some external file (several now actually, in order to keep things clean) which I created using ontofox. Would you need the ontology file for reference? I am sorry I am not yet able to debug these stuff by myself, somehow still on the learning curve when it comes to handling rdf and specifically owl data. Cheers, Guillaume Hello, There was a bug on imported ontologies, in particular when the ontology is loaded from its filename (instead of its IRI), or when it internal name changed during load (which is the case if the IRI is not of the basic form xxx.owl, such as in your example). I've fixed the bug in the development version of OwlReady2 on BitBucket. Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 > Hello, > > I am having difficulties working with imported ontologies. Specifically I > used Protege to define some ontology which imports other ontologies. > > I was expecting to be able to access these ontologies using the > /onto.imported_ontologies / attribute but this one only returns an empty > list. > > I can otherwise access the classes, attributes etc without a problem. > > Is there something I missed, especially with respect to namespace handling > in this case ? > > Cheers, > Guillaume > > owl file beginning: > <?xml version="1.0"?> > <rdf:RDF > xmlns="http://www.definiens.com/ontologies/TissuePhenomicsOntology#" > xml:base="http://www.definiens.com/ontologies/TissuePhenomicsOntology" > xmlns:uberon="http://purl.obolibrary.org/obo/uberon#" > xmlns:owl="http://www.w3.org/2002/07/owl#" > xmlns:oboInOwl="http://www.geneontology.org/formats/oboInOwl#" > xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#" > xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > xmlns:x_1.1="http://purl.org/dc/elements/1.1/" > xmlns:ubprop="http://purl.obolibrary.org/obo/ubprop#" > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:doap="http://usefulinc.com/ns/doap#" > xmlns:xml="http://www.w3.org/XML/1998/namespace" > xmlns:pato="http://purl.obolibrary.org/obo/pato#" > xmlns:uo="http://purl.obolibrary.org/obo/uo#" > xmlns:obo="http://purl.obolibrary.org/obo/" > xmlns:foaf="http://xmlns.com/foaf/0.1/"> > <owl:Ontology > rdf:about="http://www.definiens.com/ontologies/TissuePhenomicsOntology"> > <owl:versionIRI > rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/0.1"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/uo/releases/2018-03-24/uo.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/obi/2018-02-12/obi.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/pato/releases/2018-03-28/pato.owl"/> > <owl:imports > rdf:resource="http://purl.obolibrary.org/obo/cl/releases/2017-12-11/cl.owl"/> > <owl:versionInfo > rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.1</owl:versionInfo> > <rdfs:isDefinedBy>[hidden email]</rdfs:isDefinedBy> > </owl:Ontology> > > [...] > > > > > > _______________________________________________ > If you reply to this email, your message will be added to the discussion below: > http://owlready.8326.n8.nabble.com/handling-of-imported-ontology-tp273.html > To start a new topic under Owlready, email [hidden email] > To unsubscribe from Owlready, visit http://owlready.8326.n8.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=amliYWxhbXlAZnJlZS5mcnwxfDE1MTUzNDAxNDM= |
Ok I figured that, fairly weirdly, the first call to . load() results in the above mentioned error, but a successive call to the same method works without a problem.
ie. tpo = owl.get_ontology(myfile_tissuePhenomics) try: tpo.load(only_local=True) except: tpo.load(only_local=True) will work for instance (however a poor syntax that is). Hope this helps, Guillaume |
Administrator
|
In reply to this post by gp
Bonjour,
> Would you need the ontology file for reference? Yes please. I would like to remove all bugs from Owlready! Your workaround suggests me that something gets wrong in ontology loading. Then "reloading" it does not reload but just returns a reference to the partially loaded ontology. Best regards, Jean-Baptiste Lamy MCF, LIMICS, Université Paris 13 |
Hello,
I had tried to contact you via email (using the Nabble forum interface) but I guess this did not work out. Anyway, using the development version (0.9) from gitbucket the error is gone. It does not seem like the imported ontologies get loaded though. Here is my code: import owlready2 as owl myonto = r'C:\workspace\TissuePhenomicsOntologyDefinition\TissuePhenomics.owl' owl.onto_path.append(r'C:\workspace\TissuePhenomicsOntologyDefinition') owl.onto_path.append(r'C:\workspace\TissuePhenomicsOntologyDefinition\imports') tpo = owl.get_ontology(myonto) tpo.load(only_local=True) tpo.imported_ontologies > [] obo = tpo.get_namespace("http://purl.obolibrary.org/obo/") print(obo.CHEBI_39077) > None obo.search(label='eosin b') >--------------------------------------------------------------------------- >TypeError Traceback (most recent call last) ><ipython-input-8-e2f5db6e2e85> in <module>() >----> 1 obo.search(label='eosin b') > >TypeError: 'NoneType' object is not callable My owl file starts like this <owl:Ontology rdf:about="http://www.definiens.com/ontologies/TissuePhenomicsOntology"> <owl:versionIRI rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/0.1"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/pr_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/pato_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/chebi_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/stato_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/uo_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/obi_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/uberon_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/go_import.owl"/> <owl:imports rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/cl_import.owl"/> <rdfs:isDefinedBy>gpotdevin@definiens.com</rdfs:isDefinedBy> <obo:IAO_0000117>Guillaume Potdevin</obo:IAO_0000117> <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.9</owl:versionInfo> </owl:Ontology> Changing it to explicit file pathes like the following does not change things. <owl:Ontology rdf:about="http://www.definiens.com/ontologies/TissuePhenomicsOntology"> <owl:versionIRI rdf:resource="http://www.definiens.com/ontologies/TissuePhenomicsOntology/0.1"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/pr_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/pato_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/chebi_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/stato_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/uo_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/obi_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/uberon_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/go_import.owl"/> <owl:imports rdf:resource="http://git.definiens.local/gpotdevin/TissuePhenomicsOntologyDefinition/raw/master/imports/cl_import.owl"/> <rdfs:isDefinedBy>gpotdevin@definiens.com</rdfs:isDefinedBy> <obo:IAO_0000117>Guillaume Potdevin</obo:IAO_0000117> <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">0.9</owl:versionInfo> </owl:Ontology> When using protege I make use of a catalog file. I can also pass you the files themselves by email (I cannot publish them right now, though this will come). Cheers, Guillaume |
Ok my bad, I was experiencing a version conflict: somehow pip uninstall owlready2 did not do the work completely and the egg coming from the setuptool installation (dev version) was living next to the older official pip installation.
Cleaning manually the packages made the trick and now things are working like expected. Sorry for the noise and congratulation again for the net package! Guillaume |
Hello,
Time for me to revive this thread as I seem to experience the very same problem with the last version of owlready2 (0.12). After importing some ontology which itselfs has several imports the .imported_ontologies is an empty list. The same is true with owlready2==0.11 but things work as expected with owlready2==0.10 (.imported_ontologies is populated with the expected imports and I can access the corresponding entities). Could it be the bug was re-introduced in 0.11 ? Cheers, Guillaume |
Administrator
|
Hello,
Many things have changed in 0.12 with the new quadstore; so it is possible that some old bugs are back. I tested importation on a single example and it worked. Could you send me a small example that reproduces your problem? Best regards, Jiba |
Hi,
You might give a try with the ontology placed in the following repo: https://github.com/Definiens/TissuePhenomicsOntology I could reproduce the issue using the following code: import owlready2 as owl owl.onto_path.append('.') owl.onto_path.append('./imports') tpo = owl.get_ontology('TissuePhenomics.owl').load(only_local=True) assuming the script is placed in the cloned directory. This worked on my machine after installing owlready2==0.10 but not with owlready2>=0.11 Cheers, GP |
Administrator
|
Hi,
I investigated the problem. It was caused by the fact that your ontologies use "TissuePhenomicsOntology" both as a path element (e.g. http://www.definiens.com/ontologies/TissuePhenomicsOntology/imports/uo_import.owl) and as a document (e.g. http://www.definiens.com/ontologies/TissuePhenomicsOntology#TPO0000044). Owlready was messing up and expected the ontology IRI to ends with a /. It should be fixed in the development version now. Could you try it ? Cheers, Jiba |
Hello,
I tried the dev version in different scenarios and so far I did not have any glitch w.r.t the imported ontologies. Thanks for the very quick fix! GP |
In reply to this post by gp
Thank you. Finally works for me too.
|
Hi there
is there an owlready2 web-page explaining the steps for loading/getting/writing imported ontologies? From this thread I gather that the required folder structure should be: ./ontology/X.owl ./ontology/imports/ImportYOfX.owl Are imports of imports also managed in the same structure? i.e., should they be stored as: ./ontology/imports/ImportZOfImportYOfX.owl Thank you, Jos Lehmann |
Administrator
|
Hi,
I would rather suggest to put all ontologies in the same directory (such as ./ontology), and then to add this directory to onto_path. If you have several directories, you need to add each of them to onto_path. Actually, you can put the imported ontologies in any directory that is listed in onto_path. Jiba |
Free forum by Nabble | Edit this page |