Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ontology #169

Merged
merged 25 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ rdf_structure_store/
*.db
wf*
*.data
*.ipynb
*.dump
*POSCAR*
*.tar.gz
*.in
*.dot
*.png

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
394 changes: 385 additions & 9 deletions atomrdf/data/asmo.owl

Large diffs are not rendered by default.

125 changes: 119 additions & 6 deletions atomrdf/data/cmso.owl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:terms="http://purl.org/dc/terms/">
xmlns:terms="http://purl.org/dc/terms/"
xmlns:schema="https://schema.org/">
<owl:Ontology rdf:about="http://purls.helmholtz-metadaten.de/cmso/">
<terms:contributor>https://orcid.org/0000-0001-9560-4728</terms:contributor>
<terms:contributor>https://orcid.org/0000-0002-5149-603X</terms:contributor>
<terms:contributor>https://orcid.org/0000-0002-6776-1213</terms:contributor>
<terms:contributor>https://orcid.org/0000-0003-0698-4891</terms:contributor>
<terms:creator>https://orcid.org/0000-0001-7564-7990</terms:creator>
<terms:contributor rdf:resource="https://orcid.org/0000-0001-9560-4728"/>
<terms:contributor rdf:resource="https://orcid.org/0000-0002-5149-603X"/>
<terms:contributor rdf:resource="https://orcid.org/0000-0002-6776-1213"/>
<terms:contributor rdf:resource="https://orcid.org/0000-0003-0698-4891"/>
<terms:creator rdf:resource="https://orcid.org/0000-0001-7564-7990"/>
<terms:description>CMSO is an ontology that aims to describe computational materials science samples (or structures), including crystalline defects.</terms:description>
<terms:license rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://creativecommons.org/licenses/by/4.0/</terms:license>
<terms:title>Computational Material Sample Ontology (CMSO)</terms:title>
<rdfs:seeAlso rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://github.com/OCDO/cmso-ontology</rdfs:seeAlso>
<owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.0.1</owl:versionInfo>
<schema:citation rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Azocar Guzman, A., Menon, S., Hofmann, V., Hickel, T., Sandfeld. S. (2024), Computational Material Sample Ontology, https://purls.helmholtz-metadaten.de/cmso/</schema:citation>
<schema:creativeWorkStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Pre-release</schema:creativeWorkStatus>
<schema:funder rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://ror.org/05qj6w324</schema:funder>
<schema:logo rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://raw.githubusercontent.com/OCDO/.github/refs/heads/main/profile/ocdo_logo.png</schema:logo>
</owl:Ontology>


Expand All @@ -40,6 +47,12 @@



<!-- http://purl.obolibrary.org/obo/IAO_0000112 -->

<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000112"/>



<!-- http://purl.obolibrary.org/obo/IAO_0000114 -->

<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000114"/>
Expand Down Expand Up @@ -105,6 +118,18 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purl.obolibrary.org/obo/OBCS_0000221 -->

<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/OBCS_0000221">
<obo:IAO_0000112>A normal distribution probability density function has a formula of:
f(x) = 1/(√(2 π) σ) e^-((x - μ)^2/(2 σ^2))</obo:IAO_0000112>
<obo:IAO_0000115>An annotation property that represents a mathematical formula.</obo:IAO_0000115>
<obo:IAO_0000117>Asiyah Yu Lin, Jie Zheng, Yongqun He</obo:IAO_0000117>
<rdfs:label xml:lang="en">mathematical formula</rdfs:label>
</owl:AnnotationProperty>



<!-- http://purl.org/dc/elements/1.1/contributor -->

<owl:AnnotationProperty rdf:about="http://purl.org/dc/elements/1.1/contributor"/>
Expand Down Expand Up @@ -180,6 +205,16 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purl.org/dc/terms/license -->

<owl:AnnotationProperty rdf:about="http://purl.org/dc/terms/license">
<rdfs:label xml:lang="en-us">License</rdfs:label>
<skos:definition xml:lang="en-us">A legal document giving official permission to do something with the resource.</skos:definition>
<rdfs:range rdf:resource="http://purl.org/dc/terms/LicenseDocument"/>
</owl:AnnotationProperty>



<!-- http://purl.org/dc/terms/tableOfContents -->

<owl:AnnotationProperty rdf:about="http://purl.org/dc/terms/tableOfContents">
Expand Down Expand Up @@ -255,6 +290,30 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- https://schema.org/citation -->

<owl:AnnotationProperty rdf:about="https://schema.org/citation"/>



<!-- https://schema.org/creativeWorkStatus -->

<owl:AnnotationProperty rdf:about="https://schema.org/creativeWorkStatus"/>



<!-- https://schema.org/funder -->

<owl:AnnotationProperty rdf:about="https://schema.org/funder"/>



<!-- https://schema.org/logo -->

<owl:AnnotationProperty rdf:about="https://schema.org/logo"/>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -392,6 +451,18 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purls.helmholtz-metadaten.de/cmso/hasNormalVector -->

<owl:ObjectProperty rdf:about="http://purls.helmholtz-metadaten.de/cmso/hasNormalVector">
<rdfs:subPropertyOf rdf:resource="http://purls.helmholtz-metadaten.de/cmso/hasVector"/>
<rdfs:domain rdf:resource="http://purls.helmholtz-metadaten.de/cmso/Plane"/>
<rdfs:range rdf:resource="http://purls.helmholtz-metadaten.de/cmso/NormalVector"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The relation between a plane and a vector normal to it.</obo:IAO_0000115>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">has normal vector</rdfs:label>
</owl:ObjectProperty>



<!-- http://purls.helmholtz-metadaten.de/cmso/hasSimulationCell -->

<owl:ObjectProperty rdf:about="http://purls.helmholtz-metadaten.de/cmso/hasSimulationCell">
Expand Down Expand Up @@ -634,6 +705,17 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purls.helmholtz-metadaten.de/cmso/hasDistanceFromOrigin -->

<owl:DatatypeProperty rdf:about="http://purls.helmholtz-metadaten.de/cmso/hasDistanceFromOrigin">
<rdfs:domain rdf:resource="http://purls.helmholtz-metadaten.de/cmso/Plane"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A data property linking an plane with the value of distance from its origin.</obo:IAO_0000115>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">has distance from origin</rdfs:label>
</owl:DatatypeProperty>



<!-- http://purls.helmholtz-metadaten.de/cmso/hasElementRatio -->

<owl:DatatypeProperty rdf:about="http://purls.helmholtz-metadaten.de/cmso/hasElementRatio">
Expand Down Expand Up @@ -1080,6 +1162,16 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purls.helmholtz-metadaten.de/cmso/LatticePlane -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/LatticePlane">
<rdfs:subClassOf rdf:resource="http://purls.helmholtz-metadaten.de/cmso/Plane"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In crystallography, lattice planes are sets of parallel mathematical planes, where each lattice point is on a lattice plane. The lattice plane of a crystal is represented by three integers —h,k,l— which are referred to as the Miller indices.</obo:IAO_0000115>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Lattice Plane</rdfs:label>
</owl:Class>



<!-- http://purls.helmholtz-metadaten.de/cmso/LatticeVector -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/LatticeVector">
Expand Down Expand Up @@ -1174,6 +1266,16 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purls.helmholtz-metadaten.de/cmso/NormalVector -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/NormalVector">
<rdfs:subClassOf rdf:resource="http://purls.helmholtz-metadaten.de/cmso/Vector"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The normal vector is a vector perpendicular to a given object.</obo:IAO_0000115>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Normal Vector</rdfs:label>
</owl:Class>



<!-- http://purls.helmholtz-metadaten.de/cmso/Occupancy -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/Occupancy">
Expand All @@ -1185,6 +1287,17 @@ We also have the outstanding issue of how to aim different definitions to differ



<!-- http://purls.helmholtz-metadaten.de/cmso/Plane -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/Plane">
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In mathematics, a plane is a two-dimensional space or flat surface that extends indefinitely.</obo:IAO_0000115>
<obo:OBCS_0000221 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">𝑎 𝑥 + 𝑏 𝑦 + 𝑐 𝑧 + 𝑑 = 0</obo:OBCS_0000221>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The equation of a plane is 𝑎 𝑥 + 𝑏 𝑦 + 𝑐 𝑧 + 𝑑 = 0 , where 𝑎 , 𝑏 , and 𝑐 are the components of the normal vector ⃑ 𝑛 = ( 𝑎 , 𝑏 , 𝑐 ) , which is perpendicular to the plane or any vector parallel to the plane.</rdfs:comment>
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Plane</rdfs:label>
</owl:Class>



<!-- http://purls.helmholtz-metadaten.de/cmso/SimulationCell -->

<owl:Class rdf:about="http://purls.helmholtz-metadaten.de/cmso/SimulationCell">
Expand Down
2 changes: 2 additions & 0 deletions atomrdf/data/pldo.owl
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ We also have the outstanding issue of how to aim different definitions to differ
<rdfs:domain rdf:resource="http://purls.helmholtz-metadaten.de/pldo/GrainBoundary"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#float"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A data property indicating the misorientation angle (θ) of the grains with respect to each other.</obo:IAO_0000115>
<obo:IAO_0000119 rdf:datatype="http://www.w3.org/2001/XMLSchema#anyURI">https://doi.org/10.1016/j.actamat.2022.118006</obo:IAO_0000119>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A disorientation angle can also be used to describe the grain boundary and is defined by the minimum misorientation angle when the misorientation axis is found in the standard stereographic triangle.</rdfs:comment>
<rdfs:label>has misorientation angle</rdfs:label>
</owl:DatatypeProperty>

Expand Down
7 changes: 5 additions & 2 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,8 @@ def archive(self, package_name, format="turtle", compress=True, add_simulations=
# now go through each sample, and copy the file, at the same time fix the paths
for sample in self.sample_ids:
filepath = self.value(URIRef(f"{sample}_Position"), CMSO.hasPath).toPython()
#filepath has to fixed with the correct prefix as needed
filepath = os.path.join(self.structure_store, os.path.basename(filepath))
shutil.copy(filepath, structure_store)

# now we have to remove the old path, and fix new
Expand Down Expand Up @@ -1500,10 +1502,11 @@ def _get_ancestor(self, prop, prov):
propname = _name(prop)

operation = [x[1] for x in self.triples((prop, ASMO.wasCalculatedBy, None))]

if len(operation) > 0:
parent = [x[2] for x in self.triples((prop, ASMO.wasCalculatedBy, None))]
operation = operation[0]
parent = parent[0]
parent = parent[0]
prov[propname]['operation'] = 'output_parameter'
prov[propname]['inputs'] = {}
prov[propname]['inputs']['0'] = _name(parent)
Expand Down Expand Up @@ -1583,7 +1586,7 @@ def _get_ancestor(self, prop, prov):
prov[propname]['inputs']['1'] = _name(dividend)
self._add_to_dict(divisor, prov)
self._add_to_dict(dividend, prov)

print(operation)
prov[propname]['found'] = True
return prov

Expand Down
4 changes: 2 additions & 2 deletions atomrdf/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def __init__(self, infile, delimiter="/"):
PLDO = Namespace(os.path.join(file_location, "data/pldo.owl"))
PODO = Namespace(os.path.join(file_location, "data/podo.owl"))
ASMO = Namespace(os.path.join(file_location, "data/asmo.owl"))
MATH = Namespace(os.path.join(file_location, "data/asmo.owl"))

PROV = RDFLibNamespace("http://www.w3.org/ns/prov#")
MDO = RDFLibNamespace("https://w3id.org/mdo/calculation/")

MATH = RDFLibNamespace("http://purls.helmholtz-metadaten.de/asmo/")
UNSAFECMSO = RDFLibNamespace("http://purls.helmholtz-metadaten.de/cmso/")
UNSAFEASMO = RDFLibNamespace("http://purls.helmholtz-metadaten.de/asmo/")
6 changes: 3 additions & 3 deletions atomrdf/network/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def read_ontology():
file_location = os.path.dirname(__file__).split("/")
file_location = "/".join(file_location[:-1])

cmso = OntologyNetwork(os.path.join(file_location, "data/cmso.owl")) #eb8a58a60af1759afc4115ae395ad62ddffb6844
pldo = OntologyNetwork(os.path.join(file_location, "data/pldo.owl")) #d15d27712e3f64b405d75c70ad970c9d54ff0b51
cmso = OntologyNetwork(os.path.join(file_location, "data/cmso.owl")) #b7c8f3544d16d0ec9a9aace682da0e6abba1c57f
pldo = OntologyNetwork(os.path.join(file_location, "data/pldo.owl")) #688ce36a3e6520a6e280bb248789c231d3c36f25
podo = OntologyNetwork(os.path.join(file_location, "data/podo.owl")) #6a74d511c5b78042e1cb7a6e76e948fa56de598e
asmo = OntologyNetwork(os.path.join(file_location, "data/asmo.owl")) #c7e2da99b9126844f19f225c6a10cdb01aeb55e6
asmo = OntologyNetwork(os.path.join(file_location, "data/asmo.owl")) #688ce36a3e6520a6e280bb248789c231d3c36f25
ldo = OntologyNetwork(os.path.join(file_location, "data/ldo.owl")) #e23fa9930351787e701347878a3e1a0e3924d084

# combine them
Expand Down
2 changes: 1 addition & 1 deletion atomrdf/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,4 @@ def _get_symmetry_dict(system):
atom_types = system._structure_dict["species"]

results = spglib.get_symmetry_dataset((box, direct_coordinates, atom_types))
return results["international"], results["number"]
return results.international, results.number
42 changes: 28 additions & 14 deletions atomrdf/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
In this module a new Sample class is defined.
"""
from pyscal3.atoms import AttrSetter
from atomrdf.namespace import CMSO, PLDO, PODO, ASMO, PROV, Literal
from atomrdf.namespace import CMSO, PLDO, PODO, ASMO, PROV, Literal, UNSAFEASMO
from rdflib import RDFS, Namespace, RDF, URIRef
import numpy as np
import uuid
Expand All @@ -22,8 +22,9 @@ def __init__(self, name, sample_id, graph):
#create attributes
self.properties = AttrSetter()
mapdict = {
'volume': self._volume,
'no_of_atoms': self._no_of_atoms,
'SimulationCellVolume': self._volume,
'NumberOfAtoms': self._no_of_atoms,
'SimulationCellLengths': self._simulation_cell_lengths,
}
self.properties._add_attribute(mapdict)

Expand Down Expand Up @@ -55,37 +56,50 @@ def structure(self):

@property
def _volume(self):
"""
Volume of the sample, PhysicalQuantity
"""
#get the simulation cell
simcell = self._graph.value(self._sample_id, CMSO.hasSimulationCell)
#get the volume, these are volume objects now!
volume = self._graph.value(simcell, CMSO.hasVolume)
volume_value = self._graph.value(volume, ASMO.hasValue)

#initially query if there is property with label volume
#find there are already volume attached as calculated property
inps = [k[2] for k in self._graph.triples((self._sample_id, CMSO.hasCalculatedProperty, None))]
#initially query if there is property with label volume
labels = [self._graph.value(inp, RDFS.label) for inp in inps]
if not "Volume" in labels:
parent = self._graph.create_node(URIRef(f'property:{uuid.uuid4()}'), CMSO.CalculatedProperty)
self._graph.add((parent, ASMO.hasValue, Literal(volume.toPython())))
self._graph.add((parent, RDFS.label, Literal("Volume")))
self._graph.add((self._sample_id, CMSO.hasCalculatedProperty, parent))
self._graph.add((parent, ASMO.hasUnit, URIRef(f"http://qudt.org/vocab/unit/ANGSTROM3")))
if not "SimulationCellVolume" in labels:
#add this as a calculated property
self._graph.add((self._sample_id, CMSO.hasCalculatedProperty, volume))
parent = volume
else:
parent = inps[labels.index("Volume")]
return Property(volume.toPython(), graph=self._graph, parent=parent, unit='ANGSTROM3', sample_parent=self._sample_id)
parent = inps[labels.index("SimulationCellVolume")]
return Property(volume_value.toPython(), graph=self._graph, parent=parent, unit='ANGSTROM3', sample_parent=self._sample_id)

@property
def _no_of_atoms(self):
no_atoms = self._graph.value(self._sample_id, CMSO.hasNumberOfAtoms)
inps = [k[2] for k in self._graph.triples((self._sample_id, CMSO.hasCalculatedProperty, None))]
labels = [self._graph.value(inp, RDFS.label) for inp in inps]
if not "NumberOfAtoms" in labels:
parent = self._graph.create_node(URIRef(f'property:{uuid.uuid4()}'), CMSO.CalculatedProperty)
parent = self._graph.create_node(URIRef(f'property:{uuid.uuid4()}'), UNSAFEASMO.InputParameter)
self._graph.add((parent, ASMO.hasValue, Literal(no_atoms.toPython())))
self._graph.add((parent, RDFS.label, Literal("NumberOfAtoms")))
self._graph.add((self._sample_id, CMSO.hasCalculatedProperty, parent))
else:
parent = inps[labels.index("NumberOfAtoms")]
return Property(no_atoms.toPython(), graph=self._graph, parent=parent, sample_parent=self._sample_id)


@property
def _simulation_cell_lengths(self):
simcell = self._graph.value(self._sample_id, CMSO.hasSimulationCell)
simcelllength = self._graph.value(simcell, CMSO.hasLength)
x = self._graph.value(simcelllength, CMSO.hasLength_x).toPython()
y = self._graph.value(simcelllength, CMSO.hasLength_y).toPython()
z = self._graph.value(simcelllength, CMSO.hasLength_z).toPython()
return Property([x, y, z], graph=self._graph, parent=simcelllength, sample_parent=self._sample_id)

@property
def _input_properties(self):
activity = self._graph.value(self._sample_id, PROV.wasGeneratedBy)
Expand Down
Loading
Loading