From 29e8ebe71ff7d62be7114588a2330d1e2b2ef4e6 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Fri, 7 May 2021 19:15:00 +0200 Subject: [PATCH] Ensure that we can open the ontology from url. --- atomistic.ttl | 51 +++++++++++++++++++++++---------------------- catalog-v001.xml | 2 +- domain-atomistic.py | 40 ++++++++++++++++++++++------------- 3 files changed, 53 insertions(+), 40 deletions(-) diff --git a/atomistic.ttl b/atomistic.ttl index 72c4fb8..85e97ef 100644 --- a/atomistic.ttl +++ b/atomistic.ttl @@ -1,13 +1,14 @@ -@prefix : . +@prefix : . @prefix core: . @prefix emmo: . @prefix owl: . @prefix rdf: . @prefix rdfs: . @prefix term: . +@prefix xml: . @prefix xsd: . - a owl:Ontology ; + a owl:Ontology ; emmo:EMMO_5525a055_dda5_4556_8b91_f0d22fa676cc "https://creativecommons.org/licenses/by/4.0/legalcode"@en ; term:abstract "An EMMO-based domain ontology for atomistic and electronic modelling.Atomistic is released under the Creative Commons Attribution 4.0 International license (CC BY 4.0)."@en ; term:contributor "SINTEF"@en ; @@ -23,13 +24,13 @@ email: jesper.friis@sintef.no Francesca L. Bleken SINTEF email: francesca.l.bleken@sintef.no"""@en, - "The EMMO requires FacT++ reasoner plugin in order to visualize allinferences and class hierarchy (ctrl+R hotkey in Protege)."@en, + "The EMMO requires FaCT++ reasoner plugin in order to visualize allinferences and class hierarchy (ctrl+R hotkey in Protege)."@en, "This ontology is generated with data from the ASE Python package."@en ; - owl:imports ; - owl:versionIRI ; + owl:imports ; + owl:versionIRI ; owl:versionInfo "0.0.1"@en . -:atomistic_21c6ff70-4800-555e-b642-74ba2aaeb039 a owl:Class ; + a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "Physical dimensionality of charge density."@en ; rdfs:subClassOf emmo:EMMO_9895a1b4_f0a5_4167_ac5e_97db40b8bfcc ; owl:equivalentClass [ a owl:Restriction ; @@ -37,51 +38,51 @@ email: francesca.l.bleken@sintef.no"""@en, owl:onProperty emmo:EMMO_23b579e1_8088_45b5_9975_064014026c42 ] ; core:prefLabel "ChargeDensityDimension"@en . -:atomistic_83a69cf2-00c1-58b8-915b-76cb3549890a a owl:Class ; + a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """An efficient computional method for solving the many-electron (time-independent) Schrödinger equation."""@en ; rdfs:subClassOf emmo:EMMO_6eca09be_17e9_445e_abc9_000aa61b7a11 ; core:prefLabel "DensityFunctionalTheory"@en . -:atomistic_b65fe3b6-8477-5508-a066-2f7edcf25126 a owl:Class ; +:b65fe3b6-8477-5508-a066-2f7edcf25126 a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """The Schrödinger equation for a fictious "Kohn-Sham" system of non-interacting electrons that generates the same charge density as the real interacting system."""@en ; rdfs:comment "This is the equation that is solved with density functional theory."^^xsd:string ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty emmo:EMMO_b2282816_b7a3_44c6_b2cb_3feff1ceb7fe ; - owl:someValuesFrom :atomistic_513b1e52-5e37-5ba0-b4cc-89369f9b41c5 ], - :atomistic_acaafcb6-b65f-5996-93ed-2f486f5f2b30 ; + owl:someValuesFrom ], + :acaafcb6-b65f-5996-93ed-2f486f5f2b30 ; core:prefLabel "KohnShamEquation"@en . -:atomistic_fac61002-4a3d-5810-a430-ad5dad69c9a0 a owl:Class ; +:fac61002-4a3d-5810-a430-ad5dad69c9a0 a owl:Class ; emmo:EMMO_21ae69b4_235e_479d_8dd8_4f756f694c1b "TimeDependentSchrödingerEquation"@en ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "The full time-dependent Schrödinger equation."@en ; - rdfs:subClassOf :atomistic_c4dd4450-cc80-5de4-a8d6-db0651115a2c ; + rdfs:subClassOf :c4dd4450-cc80-5de4-a8d6-db0651115a2c ; core:prefLabel "TimeDependentSchrodingerEquation"@en . -:atomistic_08fd7117-66ac-5b6d-b65e-34a826675877 a owl:Class ; + a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "A mathematical operator with a physical interpretation."@en ; rdfs:subClassOf emmo:EMMO_f6d0c26a_98b6_4cf8_8632_aa259131faaa ; core:prefLabel "PhysicalOperator"@en . -:atomistic_42244404-98d1-582a-8fc0-3cdd2a9b3df6 a owl:Class ; + a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """An operator corresponding to the sum of the kinetic energies plus the potential energies for all the particles in the system."""@en ; rdfs:subClassOf [ a owl:Restriction ; - owl:onProperty :atomistic_42812fef-145a-56e9-9c18-72bd32214455 ; + owl:onProperty ; owl:someValuesFrom emmo:EMMO_31ec09ba_1713_42cb_83c7_b38bf6f9ced2 ], - :atomistic_08fd7117-66ac-5b6d-b65e-34a826675877, + , emmo:EMMO_6f5af708_f825_4feb_a0d1_a8d813d3022b ; core:prefLabel "Hamiltonian"@en . -:atomistic_42812fef-145a-56e9-9c18-72bd32214455 a owl:ObjectProperty ; + a owl:ObjectProperty ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "Relates a mathematical (or physical) operator to its eigenvalue."@en ; rdfs:domain emmo:EMMO_f6d0c26a_98b6_4cf8_8632_aa259131faaa ; rdfs:subPropertyOf emmo:EMMO_e1097637_70d2_4895_973f_2396f04fa204 ; core:prefLabel "hasEigenvalue"@en . -:atomistic_513b1e52-5e37-5ba0-b4cc-89369f9b41c5 a owl:Class ; + a owl:Class ; emmo:EMMO_50c298c2_55a2_4068_b3ac_4e948c33181f "http://www.electropedia.org/iev/iev.nsf/display?openform&ievref=121-11-07"^^rdf:PlainLiteral ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "Electric charge per volume."@en ; emmo:EMMO_c84c6752_6d64_48cc_9500_e54a3c34898d "https://en.wikipedia.org/wiki/Charge_density"^^xsd:string ; @@ -91,14 +92,14 @@ the potential energies for all the particles in the system."""@en ; rdfs:subClassOf emmo:EMMO_2946d40b_24a1_47fa_8176_e3f79bb45064 ; core:prefLabel "ChargeDensity"@en . -:atomistic_acaafcb6-b65f-5996-93ed-2f486f5f2b30 a owl:Class ; +:acaafcb6-b65f-5996-93ed-2f486f5f2b30 a owl:Class ; emmo:EMMO_21ae69b4_235e_479d_8dd8_4f756f694c1b "TimeIndependentSchrödingerEquation"@en ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """If the external potential does not depende on time, the Schrödinger equation can be reduced to this time-independent form."""@en ; - rdfs:subClassOf :atomistic_c4dd4450-cc80-5de4-a8d6-db0651115a2c ; + rdfs:subClassOf :c4dd4450-cc80-5de4-a8d6-db0651115a2c ; core:prefLabel "TimeIndependentSchrodingerEquation"@en . -:atomistic_df750ce7-fda1-5e9b-ba32-db96ec170577 a owl:Class ; +:df750ce7-fda1-5e9b-ba32-db96ec170577 a owl:Class ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """A mathematical description of the quantum state of an isolated quantum system. A wave function is a function of the degrees of freedom corresponding to some maximal set of commuting @@ -109,7 +110,7 @@ function can be derived from the quantum state."""@en ; rdfs:subClassOf emmo:EMMO_a66427d1_9932_4363_9ec5_7d91f2bfda1e ; core:prefLabel "WaveFunction"@en . -:atomistic_c4dd4450-cc80-5de4-a8d6-db0651115a2c a owl:Class ; +:c4dd4450-cc80-5de4-a8d6-db0651115a2c a owl:Class ; emmo:EMMO_21ae69b4_235e_479d_8dd8_4f756f694c1b "SchrödingerEquation"@en ; emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 """A linear partial differential equation describing the wave function of a quantum-mechanical system. @@ -120,13 +121,13 @@ time-dependent Schrödinger equation."""@en ; emmo:EMMO_c84c6752_6d64_48cc_9500_e54a3c34898d "https://en.wikipedia.org/wiki/Schr%C3%B6dinger_equation"^^rdf:PlainLiteral ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty emmo:EMMO_b2282816_b7a3_44c6_b2cb_3feff1ceb7fe ; - owl:someValuesFrom :atomistic_42244404-98d1-582a-8fc0-3cdd2a9b3df6 ], + owl:someValuesFrom :df750ce7-fda1-5e9b-ba32-db96ec170577 ], [ a owl:Restriction ; owl:onProperty emmo:EMMO_b2282816_b7a3_44c6_b2cb_3feff1ceb7fe ; - owl:someValuesFrom :atomistic_df750ce7-fda1-5e9b-ba32-db96ec170577 ], + owl:someValuesFrom emmo:EMMO_31ec09ba_1713_42cb_83c7_b38bf6f9ced2 ], [ a owl:Restriction ; owl:onProperty emmo:EMMO_b2282816_b7a3_44c6_b2cb_3feff1ceb7fe ; - owl:someValuesFrom emmo:EMMO_31ec09ba_1713_42cb_83c7_b38bf6f9ced2 ], + owl:someValuesFrom ], emmo:EMMO_27c5d8c6_8af7_4d63_beb1_ec37cd8b3fa3 ; core:prefLabel "SchrodingerEquation"@en . diff --git a/catalog-v001.xml b/catalog-v001.xml index 2004d5f..3c893a8 100644 --- a/catalog-v001.xml +++ b/catalog-v001.xml @@ -2,6 +2,6 @@ - + diff --git a/domain-atomistic.py b/domain-atomistic.py index 62fd4d2..e902cef 100755 --- a/domain-atomistic.py +++ b/domain-atomistic.py @@ -21,21 +21,19 @@ def pl(s): # Load crystallography, which imports emmo -crystallography_url = ( +emmo_url = ( 'https://raw.githubusercontent.com/emmo-repo/emmo-repo.github.io/' 'master/versions/1.0.0-beta/emmo-inferred-chemistry2.ttl') world = World() -cryst = world.get_ontology(crystallography_url) -cryst.load() -cryst.sync_python_names() # Syncronize annotations -cryst.base_iri = cryst.base_iri.rstrip('/#') -catalog_mappings = {cryst.base_iri: crystallography_url} - +emmo = world.get_ontology(emmo_url) +emmo.load() +emmo.sync_python_names() # Syncronize annotations +emmo.base_iri = emmo.base_iri.rstrip('/#') +catalog_mappings = {emmo.base_iri: emmo_url} # Create new ontology -onto = world.get_ontology('http://emmo.info/atomistic#') -onto.base_iri = 'http://emmo.info/atomistic#' -onto.imported_ontologies.append(cryst) +onto = world.get_ontology('http://emmo.info/domain-atomistic#') +onto.imported_ontologies.append(emmo) onto.sync_python_names() @@ -126,12 +124,12 @@ class KohnShamEquation(onto.TimeIndependentSchrodingerEquation): # Save new ontology as owl onto.sync_attributes(name_policy='uuid', class_docstring='elucidation', - name_prefix='atomistic_') -version_iri = "http://emmo.info/%s/atomistic" % __version__ + name_prefix='') +version_iri = "http://emmo.info/%s/domain-atomistic" % __version__ onto.set_version(version_iri=version_iri) onto.dir_label = False -catalog_mappings[version_iri] = '.atomistic.ttl' +catalog_mappings[version_iri] = 'atomistic.ttl' ################################################################# # Annotate the ontology metadata @@ -152,7 +150,7 @@ class KohnShamEquation(onto.TimeIndependentSchrodingerEquation): 'https://creativecommons.org/licenses/by/4.0/legalcode')) onto.metadata.versionInfo.append(en(__version__)) onto.metadata.comment.append(en( - 'The EMMO requires FacT++ reasoner plugin in order to visualize all' + 'The EMMO requires FaCT++ reasoner plugin in order to visualize all' 'inferences and class hierarchy (ctrl+R hotkey in Protege).')) onto.metadata.comment.append(en( 'This ontology is generated with data from the ASE Python package.')) @@ -172,3 +170,17 @@ class KohnShamEquation(onto.TimeIndependentSchrodingerEquation): write_catalog(catalog_mappings) # onto.sync_reasoner() # onto.save('atomistic-inferred.ttl', overwrite=True) + + +# Manually change url of EMMO to `emmo_url` when importing it to make +# it resolvable without consulting the catalog file. This makes it possible +# to open the ontology from url in Protege +import rdflib # noqa: E402, F401 +g = rdflib.Graph() +g.parse('atomistic.ttl', format='turtle') +for s, p, o in g.triples( + (None, rdflib.URIRef('http://www.w3.org/2002/07/owl#imports'), None)): + if 'emmo-inferred' in o: + g.remove((s, p, o)) + g.add((s, p, rdflib.URIRef(emmo_url))) +g.serialize(destination='atomistic.ttl', format='turtle')