diff --git a/atomrdf/data/asmo.owl b/atomrdf/data/asmo.owl
index ec013b0..347c68e 100644
--- a/atomrdf/data/asmo.owl
+++ b/atomrdf/data/asmo.owl
@@ -15,6 +15,7 @@
https://orcid.org/0000-0001-7564-7990
ASMO is an ontology that aims to define the concepts needed to describe commonly used atomic scale simulation methods, i.e. density functional theory, molecular dynamics, Monte Carlo methods, etc. ASMO uses the Provenance Ontology (PROV-O) to describe the simulation process.
Atomistic Simulation Methods Ontology (ASMO)
+ 0.0.1
diff --git a/atomrdf/graph.py b/atomrdf/graph.py
index 1852a5a..7baac99 100644
--- a/atomrdf/graph.py
+++ b/atomrdf/graph.py
@@ -4,7 +4,7 @@
object is stored in triplets.
"""
-from rdflib import Graph, Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef, FOAF, SKOS, DCTERMS
+from rdflib import Graph, Literal, XSD, RDF, RDFS, BNode, URIRef
import os
import numpy as np
@@ -29,11 +29,7 @@
from atomrdf.stores import create_store
import atomrdf.json_io as json_io
-
-
-CMSO = Namespace("http://purls.helmholtz-metadaten.de/cmso/")
-PLDO = Namespace("http://purls.helmholtz-metadaten.de/pldo/")
-PODO = Namespace("http://purls.helmholtz-metadaten.de/podo/")
+from atomrdf.namespace import Namespace, CMSO, PLDO, PODO, ASMO
#read element data file
file_location = os.path.dirname(__file__).split('/')
@@ -112,11 +108,38 @@ def add_structure(self, structure):
structure.graph = self
structure.to_graph()
+ def _modify_triple(self, triple):
+ modified_triple = []
+ for term in triple:
+ if type(term).__name__ == 'OntoTerm':
+ modified_triple.append(term.namespace_object)
+ else:
+ modified_triple.append(term)
+ return tuple(modified_triple)
+
def add(self, triple):
- if str(triple[2].toPython()) != 'None':
- self.graph.add(triple)
-
+ """
+ Force assumes that you are passing rdflib terms, defined with
+ RDFLib Namespace
+ """
+ modified_triple = self._modify_triple(triple)
+ if str(modified_triple[2].toPython()) != 'None':
+ self.graph.add(modified_triple)
+
+ def triples(self, triple):
+ modified_triple = self._modify_triple(triple)
+ return self.graph.triples(modified_triple)
+
+ def value(self, arg1, arg2):
+ modified_double = self._modify_triple((arg1, arg2))
+ return self.graph.value(modified_double[0], modified_double[1])
+
+ def remove(self, triple):
+ modified_triple = self._modify_triple(triple)
+ return self.graph.remove(modified_triple)
+
+
def _initialize_graph(self):
"""
Create the RDF Graph from the data stored
@@ -159,19 +182,19 @@ def add_calculated_quantity(self, sample, propertyname, value, unit=None):
def inspect_sample(self):
- natoms = self.graph.value(sample, CMSO.hasNumberOfAtoms).toPython()
- material = list([k[2] for k in self.graph.triples((sample, CMSO.hasMaterial, None))])[0]
- defects = list([k[2] for k in self.graph.triples((material, CMSO.hasDefect, None))])
- composition = list([k[2].toPython() for k in self.graph.triples((material, CMSO.hasElementRatio, None))])
- crystalstructure = self.graph.value(material, CMSO.hasStructure)
- spacegroupsymbol = self.graph.value(crystalstructure, CMSO.hasSpaceGroupSymbol).toPython()
-
- lattice = self.graph.value(sample, CMSO.hasNumberOfAtoms).toPython()
- defect_types = list([self.graph.value(d, RDF.type).toPython() for d in defects])
- prop_nodes = list([k[2] for k in self.graph.triples((sample, CMSO.hasCalculatedProperty, None))])
- props = list([self.graph.value(prop_node, RDFS.label) for prop_node in prop_nodes])
- propvals = list([self.graph.value(d, CMSO.hasValue).toPython() for d in prop_nodes])
- units = list([self.graph.value(d, CMSO.hasUnit).toPython() for d in prop_nodes])
+ natoms = self.value(sample, CMSO.hasNumberOfAtoms).toPython()
+ material = list([k[2] for k in self.triples((sample, CMSO.hasMaterial, None))])[0]
+ defects = list([k[2] for k in self.triples((material, CMSO.hasDefect, None))])
+ composition = list([k[2].toPython() for k in self.triples((material, CMSO.hasElementRatio, None))])
+ crystalstructure = self.value(material, CMSO.hasStructure)
+ spacegroupsymbol = self.value(crystalstructure, CMSO.hasSpaceGroupSymbol).toPython()
+
+ lattice = self.value(sample, CMSO.hasNumberOfAtoms).toPython()
+ defect_types = list([self.value(d, RDF.type).toPython() for d in defects])
+ prop_nodes = list([k[2] for k in self.triples((sample, CMSO.hasCalculatedProperty, None))])
+ props = list([self.value(prop_node, RDFS.label) for prop_node in prop_nodes])
+ propvals = list([self.value(d, CMSO.hasValue).toPython() for d in prop_nodes])
+ units = list([self.value(d, CMSO.hasUnit).toPython() for d in prop_nodes])
st = []
st.append(f'Sample with {natoms} atoms.\n')
st.append("Material:\n")
@@ -330,12 +353,12 @@ def archive(self, package_name, format='turtle', compress=True):
#now go through each sample, and copy the file, at the same time fix the paths
for sample in self.samples:
- filepath = self.graph.value(URIRef(f'{sample}_Position'), CMSO.hasPath).toPython()
+ filepath = self.value(URIRef(f'{sample}_Position'), CMSO.hasPath).toPython()
shutil.copy(filepath, structure_store)
#now we have to remove the old path, and fix new
for val in ['Position', 'Species']:
- self.graph.remove((URIRef(f'{sample}_{val}'), CMSO.hasPath, None))
+ self.remove((URIRef(f'{sample}_{val}'), CMSO.hasPath, None))
#assign corrected path
new_relpath = "/".join(['rdf_structure_store', filepath.split('/')[-1]])
@@ -428,7 +451,7 @@ def n_samples(self):
Number of samples in the Graph
"""
- return len([x for x in self.graph.triples((None, RDF.type, CMSO.AtomicScaleSample))])
+ return len([x for x in self.triples((None, RDF.type, CMSO.AtomicScaleSample))])
@property
def samples(self):
@@ -436,12 +459,12 @@ def samples(self):
Returns a list of all Samples in the graph
"""
- return [x[0] for x in self.graph.triples((None, RDF.type, CMSO.AtomicScaleSample))]
+ return [x[0] for x in self.triples((None, RDF.type, CMSO.AtomicScaleSample))]
def iterate_graph(self, item, create_new_graph=False):
if create_new_graph:
self.sgraph = KnowledgeGraph()
- triples = list(self.graph.triples((item, None, None)))
+ triples = list(self.triples((item, None, None)))
for triple in triples:
self.sgraph.graph.add(triple)
self.iterate_graph(triple[2])
@@ -467,7 +490,7 @@ def get_sample(self, sample, no_atoms=False):
self.iterate_graph(sample, create_new_graph=True)
if no_atoms:
- na = self.sgraph.graph.value(sample, CMSO.hasNumberOfAtoms).toPython()
+ na = self.sgraph.value(sample, CMSO.hasNumberOfAtoms).toPython()
return self.sgraph, na
return self.sgraph
@@ -486,18 +509,18 @@ def get_system_from_sample(self, sample):
corresponding system
"""
- simcell = self.graph.value(sample, CMSO.hasSimulationCell)
+ simcell = self.value(sample, CMSO.hasSimulationCell)
cell_vectors = [[], [], []]
- for s in self.graph.triples((simcell, CMSO.hasVector, None)):
- cell_vectors[0].append(self.graph.value(s[2], CMSO.hasComponent_x).toPython())
- cell_vectors[1].append(self.graph.value(s[2], CMSO.hasComponent_y).toPython())
- cell_vectors[2].append(self.graph.value(s[2], CMSO.hasComponent_z).toPython())
+ for s in self.triples((simcell, CMSO.hasVector, None)):
+ cell_vectors[0].append(self.value(s[2], CMSO.hasComponent_x).toPython())
+ cell_vectors[1].append(self.value(s[2], CMSO.hasComponent_y).toPython())
+ cell_vectors[2].append(self.value(s[2], CMSO.hasComponent_z).toPython())
#cell_vectors
- filepath = self.graph.value(URIRef(f'{sample}_Position'), CMSO.hasPath).toPython()
- position_identifier = self.graph.value(URIRef(f'{sample}_Position'), CMSO.hasIdentifier).toPython()
- species_identifier = self.graph.value(URIRef(f'{sample}_Species'), CMSO.hasIdentifier).toPython()
+ filepath = self.value(URIRef(f'{sample}_Position'), CMSO.hasPath).toPython()
+ position_identifier = self.value(URIRef(f'{sample}_Position'), CMSO.hasIdentifier).toPython()
+ species_identifier = self.value(URIRef(f'{sample}_Species'), CMSO.hasIdentifier).toPython()
#open the file for reading
with open(filepath, 'r') as fin:
diff --git a/atomrdf/namespace.py b/atomrdf/namespace.py
new file mode 100644
index 0000000..1af9c91
--- /dev/null
+++ b/atomrdf/namespace.py
@@ -0,0 +1,35 @@
+import os
+from rdflib import Literal, URIRef
+from rdflib import Namespace as RDFLibNamespace
+from pyscal3.atoms import AttrSetter
+
+from atomrdf.network.network import OntologyNetwork
+
+class Namespace(AttrSetter, RDFLibNamespace):
+ def __init__(self, infile, delimiter='/'):
+ AttrSetter.__init__(self)
+ self.network = OntologyNetwork(infile, delimiter=delimiter)
+ #print(type(self.network.onto.tree.base_iri))
+ #self.namespace = RDFLibNamespace(self.network.onto.tree.base_iri)
+ RDFLibNamespace.__init__(self.network.onto.tree.base_iri)
+ #self.namespace = RDFLibNamespace("http://purls.helmholtz-metadaten.de/cmso/")
+ self.name = self.network.onto.tree.name
+ mapdict = {}
+
+ #now iterate over all attributes
+ for k1 in ['class', 'object_property', 'data_property']:
+ for k2, val in self.network.onto.attributes[k1].items():
+ if val.namespace == self.name:
+ mapdict[val.name_without_prefix] = val
+
+ #add attributes
+ self._add_attribute(mapdict)
+
+
+file_location = os.path.dirname(__file__)
+
+CMSO = Namespace(os.path.join(file_location, 'data/cmso.owl'))
+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'))
+PROV = RDFLibNamespace("http://www.w3.org/ns/prov#")
\ No newline at end of file
diff --git a/atomrdf/network/parser.py b/atomrdf/network/parser.py
index 1a93d97..0a80ffc 100644
--- a/atomrdf/network/parser.py
+++ b/atomrdf/network/parser.py
@@ -181,19 +181,33 @@ def _parse_class_basic(self):
iri = c.iri
#print(iri)
#print(iri)
- try:
- subclasses = self.tree.search(subclass_of=getattr(self.tree, c.name))
- for sb in subclasses:
- term = OntoTerm(sb.iri, delimiter=self.delimiter)
- term.node_type ='class'
- self.attributes['class'][term.name] = term
- subclasses = [strip_name(sb.iri, self.delimiter) for sb in subclasses]
- classes.append(subclasses)
- except:
- term = OntoTerm(c.iri, delimiter=self.delimiter)
+ #CHILDREN
+ children = self.tree.get_children_of(c)
+ named_instances = self.tree.get_instances_of(c)
+ equiv_classes = c.equivalent_to
+ subclasses = [*children, *named_instances, *equiv_classes]
+ subclasses.append(c)
+ for sb in subclasses:
+ term = OntoTerm(sb.iri, delimiter=self.delimiter)
term.node_type ='class'
- self.attributes['class'][term.name] = term
- classes.append([strip_name(c.iri, self.delimiter)])
+ self.attributes['class'][term.name] = term
+ subclasses = [strip_name(sb.iri, self.delimiter) for sb in subclasses]
+ classes.append(subclasses)
+
+
+ #try:
+ # subclasses = self.tree.search(subclass_of=getattr(self.tree, c.name))
+ # for sb in subclasses:
+ # term = OntoTerm(sb.iri, delimiter=self.delimiter)
+ # term.node_type ='class'
+ # self.attributes['class'][term.name] = term
+ # subclasses = [strip_name(sb.iri, self.delimiter) for sb in subclasses]
+ # classes.append(subclasses)
+ #except:
+ # term = OntoTerm(c.iri, delimiter=self.delimiter)
+ # term.node_type ='class'
+ # self.attributes['class'][term.name] = term
+ # classes.append([strip_name(c.iri, self.delimiter)])
return classes
def _aggregate_keys(self, dd):
diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py
index 8186658..6fc0f7e 100644
--- a/atomrdf/network/term.py
+++ b/atomrdf/network/term.py
@@ -91,7 +91,10 @@ def uri(self, val):
@property
def name_without_prefix(self):
- return _get_name(self.uri, self.delimiter)
+ name = _get_name(self.uri, self.delimiter)
+ name = name.replace('–', '')
+ name = name.replace('-', '')
+ return name
@property
def name(self):
@@ -142,6 +145,9 @@ def query_name_without_prefix(self):
return self.name_without_prefix + "value"
return self.name_without_prefix
+ def toPython(self):
+ return self.uri
+
def __repr__(self):
return str(self.name)
diff --git a/atomrdf/structure.py b/atomrdf/structure.py
index 58b1672..0cef9e9 100644
--- a/atomrdf/structure.py
+++ b/atomrdf/structure.py
@@ -21,11 +21,8 @@
import atomrdf.json_io as json_io
import atomrdf.properties as prp
-from rdflib import Graph, Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef, FOAF, SKOS, DCTERMS
-
-CMSO = Namespace("http://purls.helmholtz-metadaten.de/cmso/")
-PLDO = Namespace("http://purls.helmholtz-metadaten.de/pldo/")
-PODO = Namespace("http://purls.helmholtz-metadaten.de/podo/")
+from rdflib import Graph, Literal, Namespace, XSD, RDF, RDFS, BNode, URIRef
+from atomrdf.namespace import CMSO, PLDO, PODO
#read element data file
file_location = os.path.dirname(__file__).split('/')
@@ -257,37 +254,37 @@ def delete(self, ids=None, indices=None, condition=None, selection=False):
c = (val/self.natoms)
self.add_vacancy(c, number=val)
#now we need to re-add atoms, so at to remove
- self.graph.graph.remove((self.sample, CMSO.hasNumberOfAtoms, None))
- self.graph.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(actual_natoms-val, datatype=XSD.integer)))
+ self.graph.remove((self.sample, CMSO.hasNumberOfAtoms, None))
+ self.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(actual_natoms-val, datatype=XSD.integer)))
#revamp composition
#remove existing chem composution
- chemical_species = self.graph.graph.value(self.sample, CMSO.hasSpecies)
+ chemical_species = self.graph.value(self.sample, CMSO.hasSpecies)
#start by cleanly removing elements
- for s in self.graph.graph.triples((chemical_species, CMSO.hasElement, None)):
+ for s in self.graph.triples((chemical_species, CMSO.hasElement, None)):
element = s[2]
- self.graph.graph.remove((element, None, None))
- self.graph.graph.remove((chemical_species, None, None))
- self.graph.graph.remove((self.sample, CMSO.hasSpecies, None))
+ self.graph.remove((element, None, None))
+ self.graph.remove((chemical_species, None, None))
+ self.graph.remove((self.sample, CMSO.hasSpecies, None))
#now recalculate and add it again
composition = self.schema.material.element_ratio()
chemical_species = URIRef(f'{self._name}_ChemicalSpecies')
- self.graph.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
- self.graph.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
+ self.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
+ self.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
for e, r in composition.items():
if e in element_indetifiers.keys():
element = URIRef(element_indetifiers[e])
self.graph.add((chemical_species, CMSO.hasElement, element))
- self.graph.add((element, RDF.type, CMSO.Element))
+ self.graph.add((element, RDF.type, CMSO.ChemicalElement))
self.graph.add((element, CMSO.hasSymbol, Literal(e, datatype=XSD.string)))
self.graph.add((element, CMSO.hasElementRatio, Literal(r, datatype=XSD.float)))
#we also have to read in file and clean it up
- filepath = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
- position_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
- species_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
+ filepath = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
+ position_identifier = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
+ species_identifier = self.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
#clean up items
datadict = {
@@ -321,33 +318,33 @@ def substitute_atoms(self, substitution_element, ids=None, indices=None, conditi
#operate on the graph
if self.graph is not None:
- chemical_species = self.graph.graph.value(self.sample, CMSO.hasSpecies)
+ chemical_species = self.graph.value(self.sample, CMSO.hasSpecies)
#start by cleanly removing elements
- for s in self.graph.graph.triples((chemical_species, CMSO.hasElement, None)):
+ for s in self.graph.triples((chemical_species, CMSO.hasElement, None)):
element = s[2]
- self.graph.graph.remove((element, None, None))
- self.graph.graph.remove((chemical_species, None, None))
- self.graph.graph.remove((self.sample, CMSO.hasSpecies, None))
+ self.graph.remove((element, None, None))
+ self.graph.remove((chemical_species, None, None))
+ self.graph.remove((self.sample, CMSO.hasSpecies, None))
#now recalculate and add it again
composition = self.schema.material.element_ratio()
chemical_species = URIRef(f'{self._name}_ChemicalSpecies')
- self.graph.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
- self.graph.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
+ self.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
+ self.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
for e, r in composition.items():
if e in element_indetifiers.keys():
element = URIRef(element_indetifiers[e])
self.graph.add((chemical_species, CMSO.hasElement, element))
- self.graph.add((element, RDF.type, CMSO.Element))
+ self.graph.add((element, RDF.type, CMSO.ChemicalElement))
self.graph.add((element, CMSO.hasSymbol, Literal(e, datatype=XSD.string)))
self.graph.add((element, CMSO.hasElementRatio, Literal(r, datatype=XSD.float)))
#we also have to read in file and clean it up
- filepath = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
- position_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
- species_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
+ filepath = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
+ position_identifier = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
+ species_identifier = self.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
#clean up items
datadict = {
@@ -441,37 +438,37 @@ def add_interstitial_impurities(self, element, void_type='tetrahedral', lattice_
#now we have to verify the triples correctly and add them in
if self.graph is not None:
- self.graph.graph.remove((self.sample, CMSO.hasNumberOfAtoms, None))
- self.graph.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(sysn.natoms, datatype=XSD.integer)))
+ self.graph.remove((self.sample, CMSO.hasNumberOfAtoms, None))
+ self.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(sysn.natoms, datatype=XSD.integer)))
#revamp composition
#remove existing chem composution
- chemical_species = self.graph.graph.value(self.sample, CMSO.hasSpecies)
+ chemical_species = self.graph.value(self.sample, CMSO.hasSpecies)
#start by cleanly removing elements
- for s in self.graph.graph.triples((chemical_species, CMSO.hasElement, None)):
+ for s in self.graph.triples((chemical_species, CMSO.hasElement, None)):
element = s[2]
- self.graph.graph.remove((element, None, None))
- self.graph.graph.remove((chemical_species, None, None))
- self.graph.graph.remove((self.sample, CMSO.hasSpecies, None))
+ self.graph.remove((element, None, None))
+ self.graph.remove((chemical_species, None, None))
+ self.graph.remove((self.sample, CMSO.hasSpecies, None))
#now recalculate and add it again
composition = sysn.schema.material.element_ratio()
chemical_species = URIRef(f'{self._name}_ChemicalSpecies')
- self.graph.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
- self.graph.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
+ self.graph.add((self.sample, CMSO.hasSpecies, chemical_species))
+ self.graph.add((chemical_species, RDF.type, CMSO.ChemicalSpecies))
for e, r in composition.items():
if e in element_indetifiers.keys():
element = URIRef(element_indetifiers[e])
self.graph.add((chemical_species, CMSO.hasElement, element))
- self.graph.add((element, RDF.type, CMSO.Element))
+ self.graph.add((element, RDF.type, CMSO.ChemicalElement))
self.graph.add((element, CMSO.hasSymbol, Literal(e, datatype=XSD.string)))
self.graph.add((element, CMSO.hasElementRatio, Literal(r, datatype=XSD.float)))
#we also have to read in file and clean it up
- filepath = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
- position_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
- species_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
+ filepath = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasPath).toPython()
+ position_identifier = self.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
+ species_identifier = self.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()
#clean up items
datadict = {
@@ -566,7 +563,7 @@ def _add_chemical_composition(self):
if e in element_indetifiers.keys():
element = URIRef(element_indetifiers[e])
self.graph.add((chemical_species, CMSO.hasElement, element))
- self.graph.add((element, RDF.type, CMSO.Element))
+ self.graph.add((element, RDF.type, CMSO.ChemicalElement))
self.graph.add((element, CMSO.hasChemicalSymbol, Literal(e, datatype=XSD.string)))
self.graph.add((element, CMSO.hasElementRatio, Literal(r, datatype=XSD.float)))
@@ -712,7 +709,7 @@ def _add_unit_cell(self):
bv = self.schema.material.crystal_structure.unit_cell.bravais_lattice()
if bv is not None:
bv = URIRef(bv)
- self.graph.add((self.unit_cell, CMSO.hasBravaisLattice, bv))
+ self.graph.add((self.unit_cell, Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasBravaisLattice, bv))
def _add_lattice_properties(self):
"""
@@ -788,7 +785,7 @@ def _add_atoms(self):
if "positions" in self.atoms.keys():
position = URIRef(f'{self._name}_Position')
- self.graph.add((self.sample, CMSO.hasAttribute, position))
+ self.graph.add((self.sample, Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasAttribute, position))
self.graph.add((position, RDF.type, CMSO.AtomAttribute))
self.graph.add((position, CMSO.hasName, Literal('Position', datatype=XSD.string)))
self.graph.add((position, CMSO.hasIdentifier, Literal(position_identifier, datatype=XSD.string)))
@@ -796,7 +793,7 @@ def _add_atoms(self):
if "species" in self.atoms.keys():
species = URIRef(f'{self._name}_Species')
- self.graph.add((self.sample, CMSO.hasAttribute, species))
+ self.graph.add((self.sample, Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasAttribute, species))
self.graph.add((species, RDF.type, CMSO.AtomAttribute))
self.graph.add((species, CMSO.hasName, Literal('Species', datatype=XSD.string)))
self.graph.add((species, CMSO.hasIdentifier, Literal(species_identifier, datatype=XSD.string)))
@@ -892,7 +889,7 @@ def add_gb(self, gb_dict):
self.graph.add((self.material, CMSO.hasDefect, plane_defect))
self.graph.add((plane_defect, PLDO.hasSigmaValue, Literal(gb_dict["sigma"], datatype=XSD.integer)))
- self.graph.add((plane_defect, PLDO.hasGBPlane, Literal(gb_dict["GBPlane"],
+ self.graph.add((plane_defect, PLDO.hasGBplane, Literal(gb_dict["GBPlane"],
datatype=XSD.string)))
self.graph.add((plane_defect, PLDO.hasRotationAxis, Literal(gb_dict["RotationAxis"],
datatype=XSD.string)))
diff --git a/atomrdf/workflow/pyiron.py b/atomrdf/workflow/pyiron.py
index 255e698..8a01032 100644
--- a/atomrdf/workflow/pyiron.py
+++ b/atomrdf/workflow/pyiron.py
@@ -51,13 +51,13 @@ def _identify_method(job):
if int(input_dict['run']) == 0:
method = 'static'
md_method = 'MolecularStatics'
- ensemble = 'NVE'
+ ensemble = 'MicrocanonicalEnsemble'
elif int(input_dict['run']) > 0:
method = 'md_nve'
dof.append('AtomicPosition')
md_method = 'MolecularDynamics'
- ensemble = 'NVE'
+ ensemble = 'MicrocanonicalEnsemble'
elif 'nvt' in input_dict['fix___ensemble']:
@@ -66,7 +66,7 @@ def _identify_method(job):
temp = float(raw[3])
dof.append('AtomicPosition')
md_method = 'MolecularDynamics'
- ensemble = 'NVT'
+ ensemble = 'CanonicalEnsemble'
elif 'npt' in input_dict['fix___ensemble']:
dof.append('AtomicPosition')
@@ -80,7 +80,7 @@ def _identify_method(job):
raw = input_dict['fix___ensemble'].split()
temp = float(raw[3])
press = float(raw[7])
- ensemble = 'NPT'
+ ensemble = 'IsothermalisobaricEnsemble'
mdict = {}
mdict['md'] = {}
diff --git a/atomrdf/workflow/workflow.py b/atomrdf/workflow/workflow.py
index 6214358..1934944 100644
--- a/atomrdf/workflow/workflow.py
+++ b/atomrdf/workflow/workflow.py
@@ -26,10 +26,7 @@
from atomrdf.structure import System
#Move imports to another file
-PROV = Namespace("http://www.w3.org/ns/prov#")
-CMSO = Namespace("http://purls.helmholtz-metadaten.de/cmso/")
-PODO = Namespace("http://purls.helmholtz-metadaten.de/podo/")
-ASO = Namespace("http://purls.helmholtz-metadaten.de/aso/")
+from atomrdf.namespace import PROV, CMSO, PODO, ASMO
#custom imports as needed
import atomrdf.workflow.pyiron as pi
@@ -84,63 +81,63 @@ def _add_inherited_properties(self, ):
if self.parent_sample is None:
return
- parent_material = list([k[2] for k in self.kg.graph.triples((self.parent_sample, CMSO.hasMaterial, None))])[0]
- parent_defects = list([x[2] for x in self.kg.graph.triples((parent_material, CMSO.hasDefect, None))])
+ parent_material = list([k[2] for k in self.kg.triples((self.parent_sample, CMSO.hasMaterial, None))])[0]
+ parent_defects = list([x[2] for x in self.kg.triples((parent_material, CMSO.hasDefect, None))])
#now for each defect we copy add this to the final sample
- material = list([k[2] for k in self.kg.graph.triples((self.sample, CMSO.hasMaterial, None))])[0]
+ material = list([k[2] for k in self.kg.triples((self.sample, CMSO.hasMaterial, None))])[0]
for defect in parent_defects:
new_defect = URIRef(defect.toPython())
self.kg.graph.add((material, CMSO.hasDefect, new_defect))
#now fetch all defect based info
- for triple in self.kg.graph.triples((defect, None, None)):
+ for triple in self.kg.triples((defect, None, None)):
self.kg.graph.add((new_defect, triple[1], triple[2]))
#now add the special props for vacancy
- parent_simcell = self.kg.graph.value(self.sample, CMSO.hasSimulationCell)
- simcell = self.kg.graph.value(self.parent_sample, CMSO.hasSimulationCell)
+ parent_simcell = self.kg.value(self.sample, CMSO.hasSimulationCell)
+ simcell = self.kg.value(self.parent_sample, CMSO.hasSimulationCell)
- for triple in self.kg.graph.triples((parent_simcell, PODO.hasVacancyConcentration, None)):
+ for triple in self.kg.triples((parent_simcell, PODO.hasVacancyConcentration, None)):
self.kg.graph.add((simcell, triple[1], triple[2]))
- for triple in self.kg.graph.triples((parent_simcell, PODO.hasNumberOfVacancies, None)):
+ for triple in self.kg.triples((parent_simcell, PODO.hasNumberOfVacancies, None)):
self.kg.graph.add((simcell, triple[1], triple[2]))
def _get_lattice_properties(self, ):
if self.parent_sample is None:
return
- parent_material = list([k[2] for k in self.kg.graph.triples((self.parent_sample, CMSO.hasMaterial, None))])[0]
- parent_crystal_structure = self.kg.graph.value(parent_material, CMSO.hasStructure)
- parent_altname = self.kg.graph.value(parent_crystal_structure, CMSO.hasAltName)
+ parent_material = list([k[2] for k in self.kg.triples((self.parent_sample, CMSO.hasMaterial, None))])[0]
+ parent_crystal_structure = self.kg.value(parent_material, CMSO.hasStructure)
+ parent_altname = self.kg.value(parent_crystal_structure, CMSO.hasAltName)
#add this to new structure
- material = list([k[2] for k in self.kg.graph.triples((self.sample, CMSO.hasMaterial, None))])[0]
- crystal_structure = self.kg.graph.value(material, CMSO.hasStructure)
+ material = list([k[2] for k in self.kg.triples((self.sample, CMSO.hasMaterial, None))])[0]
+ crystal_structure = self.kg.value(material, CMSO.hasStructure)
self.kg.add((crystal_structure, CMSO.hasAltName, parent_altname))
#space group
- parent_space_group = self.kg.graph.value(parent_crystal_structure, CMSO.hasSpaceGroup)
- space_group = self.kg.graph.value(crystal_structure, CMSO.hasSpaceGroup)
- for triple in self.kg.graph.triples((parent_space_group, None, None)):
+ parent_space_group = self.kg.value(parent_crystal_structure, CMSO.hasSpaceGroup)
+ space_group = self.kg.value(crystal_structure, CMSO.hasSpaceGroup)
+ for triple in self.kg.triples((parent_space_group, None, None)):
self.kg.graph.add((space_group, triple[1], triple[2]))
#unit cell
- parent_unit_cell = self.kg.graph.value(parent_crystal_structure, CMSO.hasUnitCell)
- parent_bv = self.kg.graph.value(parent_unit_cell, CMSO.hasBravaisLattice)
+ parent_unit_cell = self.kg.value(parent_crystal_structure, CMSO.hasUnitCell)
+ parent_bv = self.kg.value(parent_unit_cell, Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasBravaisLattice)
- unit_cell = self.kg.graph.value(crystal_structure, CMSO.hasUnitCell)
- self.kg.graph.add((unit_cell, CMSO.hasBravaisLattice, parent_bv))
+ unit_cell = self.kg.value(crystal_structure, CMSO.hasUnitCell)
+ self.kg.graph.add((unit_cell, Namespace("http://purls.helmholtz-metadaten.de/cmso/").hasBravaisLattice, parent_bv))
#lattice parameter
- parent_lattice_parameter = self.kg.graph.value(parent_unit_cell, CMSO.hasLatticeParameter)
- lattice_parameter = self.kg.graph.value(unit_cell, CMSO.hasLatticeParameter)
- for triple in self.kg.graph.triples((parent_lattice_parameter, None, None)):
+ parent_lattice_parameter = self.kg.value(parent_unit_cell, CMSO.hasLatticeParameter)
+ lattice_parameter = self.kg.value(unit_cell, CMSO.hasLatticeParameter)
+ for triple in self.kg.triples((parent_lattice_parameter, None, None)):
self.kg.graph.add((lattice_parameter, triple[1], triple[2]))
#lattice angle
- parent_lattice_angle = self.kg.graph.value(parent_unit_cell, CMSO.hasAngle)
- lattice_angle = self.kg.graph.value(unit_cell, CMSO.hasAngle)
- for triple in self.kg.graph.triples((parent_lattice_angle, None, None)):
+ parent_lattice_angle = self.kg.value(parent_unit_cell, CMSO.hasAngle)
+ lattice_angle = self.kg.value(unit_cell, CMSO.hasAngle)
+ for triple in self.kg.triples((parent_lattice_angle, None, None)):
self.kg.graph.add((lattice_angle, triple[1], triple[2]))
@@ -202,62 +199,62 @@ def add_method(self, ):
if method_type == 'md':
method = URIRef(f'method:{main_id}')
if mdict['method'] == 'MolecularStatics':
- self.kg.add((method, RDF.type, ASO.MolecularStatics))
+ self.kg.add((method, RDF.type, ASMO.MolecularStatics))
elif mdict['method'] == 'MolecularDynamics':
- self.kg.add((method, RDF.type, ASO.MolecularDynamics))
+ self.kg.add((method, RDF.type, ASMO.MolecularDynamics))
elif method_type == 'dft':
method = URIRef(f'method:{main_id}')
if mdict['method'] == 'DensityFunctionalTheory':
- self.kg.add((method, RDF.type, ASO.DensityFunctionalTheory))
- self.kg.add((activity, ASO.hasMethod, method))
+ self.kg.add((method, RDF.type, ASMO.DensityFunctionalTheory))
+ self.kg.add((activity, ASMO.hasComputationalMethod, method))
if len(mdict['dof']) == 0:
- self.kg.add((activity, RDF.type, ASO.RigidEnergyCalculation))
+ self.kg.add((activity, RDF.type, ASMO.RigidEnergyCalculation))
else:
- self.kg.add((activity, RDF.type, ASO.StructureOptimization))
+ self.kg.add((activity, RDF.type, ASMO.StructureOptimization))
for dof in mdict['dof']:
- self.kg.add((activity, ASO.hasRelaxationDOF, getattr(ASO, dof)))
+ self.kg.add((activity, ASMO.hasRelaxationDOF, getattr(ASMO, dof)))
if method_type == 'md':
- self.kg.add((method, ASO.hasStatisticalEnsemble, getattr(ASO, mdict['ensemble'])))
+ self.kg.add((method, ASMO.hasStatisticalEnsemble, getattr(ASMO, mdict['ensemble'])))
#add temperature if needed
if mdict['temperature'] is not None:
temperature = URIRef(f'temperature:{main_id}')
- self.kg.add((temperature, RDF.type, ASO.InputParameter))
+ self.kg.add((temperature, RDF.type, ASMO.InputParameter))
self.kg.add((temperature, RDFS.label, Literal('temperature', datatype=XSD.string)))
- self.kg.add((activity, ASO.hasInputParameter, temperature))
- self.kg.add((temperature, ASO.hasValue, Literal(mdict['temperature'], datatype=XSD.float)))
- self.kg.add((temperature, ASO.hasUnit, URIRef('http://qudt.org/vocab/unit/K')))
+ self.kg.add((activity, ASMO.hasInputParameter, temperature))
+ self.kg.add((temperature, ASMO.hasValue, Literal(mdict['temperature'], datatype=XSD.float)))
+ self.kg.add((temperature, ASMO.hasUnit, URIRef('http://qudt.org/vocab/unit/K')))
if mdict['pressure'] is not None:
pressure = URIRef(f'pressure:{main_id}')
- self.kg.add((pressure, RDF.type, ASO.InputParameter))
+ self.kg.add((pressure, RDF.type, ASMO.InputParameter))
self.kg.add((pressure, RDFS.label, Literal('pressure', datatype=XSD.string)))
- self.kg.add((activity, ASO.hasInputParameter, pressure))
- self.kg.add((pressure, ASO.hasValue, Literal(mdict['pressure'], datatype=XSD.float)))
- self.kg.add((pressure, ASO.hasUnit, URIRef('http://qudt.org/vocab/unit/GigaPA')))
+ self.kg.add((activity, ASMO.hasInputParameter, pressure))
+ self.kg.add((pressure, ASMO.hasValue, Literal(mdict['pressure'], datatype=XSD.float)))
+ self.kg.add((pressure, ASMO.hasUnit, URIRef('http://qudt.org/vocab/unit/GigaPA')))
#potentials need to be mapped
potential = URIRef(f'potential:{main_id}')
if 'meam' in mdict['potential']['type']:
- self.kg.add((potential, RDF.type, ASO.MEAM))
+ self.kg.add((potential, RDF.type, ASMO.ModifiedEmbeddedAtomModel))
elif 'eam' in mdict['potential']['type']:
- self.kg.add((potential, RDF.type, ASO.EAM))
+ self.kg.add((potential, RDF.type, ASMO.EmbeddedAtomModel))
elif 'lj' in mdict['potential']['type']:
- self.kg.add((potential, RDF.type, ASO.LennardJones))
+ self.kg.add((potential, RDF.type, ASMO.LennardJonesPotential))
elif 'ace' in mdict['potential']['type']:
- self.kg.add((potential, RDF.type, ASO.MLPotential))
+ self.kg.add((potential, RDF.type, ASMO.MachineLearningPotential))
else:
- self.kg.add((potential, RDF.type, ASO.InteratomicPotential))
+ self.kg.add((potential, RDF.type, ASMO.InteratomicPotential))
if 'uri' in mdict['potential'].keys():
- self.kg.add((potential, ASO.hasReference, Literal(mdict['potential']['uri'])))
+ self.kg.add((potential, CMSO.hasReference, Literal(mdict['potential']['uri'])))
if 'label' in mdict['potential'].keys():
self.kg.add((potential, RDFS.label, Literal(mdict['potential']['label'])))
- self.kg.add((method, ASO.hasInteratomicPotential, potential))
+ self.kg.add((method, ASMO.hasInteratomicPotential, potential))
self.kg.add((self.sample, PROV.wasGeneratedBy, activity))
@@ -283,11 +280,11 @@ def add_method(self, ):
prop = URIRef(f'{main_id}_{key}')
self.kg.add((prop, RDF.type, CMSO.CalculatedProperty))
self.kg.add((prop, RDFS.label, Literal(key)))
- self.kg.add((prop, ASO.hasValue, Literal(val["value"])))
+ self.kg.add((prop, ASMO.hasValue, Literal(val["value"])))
if "unit" in val.keys():
unit = val['unit']
- self.kg.add((prop, ASO.hasUnit, URIRef(f'http://qudt.org/vocab/unit/{unit}')))
- self.kg.add((prop, CMSO.wasCalculatedBy, activity))
+ self.kg.add((prop, ASMO.hasUnit, URIRef(f'http://qudt.org/vocab/unit/{unit}')))
+ self.kg.add((prop, ASMO.wasCalculatedBy, activity))
if val['associate_to_sample']:
self.kg.add((self.sample, CMSO.hasCalculatedProperty, prop))
diff --git a/examples/01_getting_started.ipynb b/examples/01_getting_started.ipynb
index 6a16e36..4b0c35b 100644
--- a/examples/01_getting_started.ipynb
+++ b/examples/01_getting_started.ipynb
@@ -115,684 +115,684 @@
"\n",
"\n",
- "