From 38b9b3280330189ecd063b60ceb6785e4d1eef36 Mon Sep 17 00:00:00 2001 From: Sarath Date: Tue, 20 Aug 2024 16:57:31 +0200 Subject: [PATCH] replace triples --- atomrdf/structure.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/atomrdf/structure.py b/atomrdf/structure.py index 535ab35..fb01178 100644 --- a/atomrdf/structure.py +++ b/atomrdf/structure.py @@ -1158,7 +1158,7 @@ def delete(self, ids=None, indices=None, condition=None, selection=False, copy_s #write mapping for the operation if self.sample.toPython() != sys.sample.toPython(): - activity = self.graph.create_node(f"activity:{uuid.uuid4()}", PROV.Activity, label='DeleteAtom') + activity = self.graph.create_node(f"activity:{uuid.uuid4()}", UNSAFEASMO.DeleteAtom) sys.graph.add((sys.sample, PROV.wasDerivedFrom, self.sample)) sys.graph.add((sys.sample, PROV.wasGeneratedBy, activity)) @@ -1371,7 +1371,7 @@ def substitute_atoms( #write mapping for the operation if self.sample.toPython() != sys.sample.toPython(): - activity = self.graph.create_node(f"activity:{uuid.uuid4()}", PROV.Activity, label='SubstituteAtom') + activity = self.graph.create_node(f"activity:{uuid.uuid4()}", UNSAFEASMO.SubstituteAtom) sys.graph.add((sys.sample, PROV.wasDerivedFrom, self.sample)) sys.graph.add((sys.sample, PROV.wasGeneratedBy, activity)) @@ -1567,7 +1567,7 @@ def add_interstitial_impurities( sys.add_triples_for_interstitial_impurities(conc_of_impurities, no_of_impurities=no_of_impurities, label=void_type) #write mapping for the operation if self.sample.toPython() != sys.sample.toPython(): - activity = self.graph.create_node(f"activity:{uuid.uuid4()}", PROV.Activity, label='AddAtom') + activity = self.graph.create_node(f"activity:{uuid.uuid4()}", UNSAFEASMO.AddAtom) sys.graph.add((sys.sample, PROV.wasDerivedFrom, self.sample)) sys.graph.add((sys.sample, PROV.wasGeneratedBy, activity)) return sys @@ -2512,7 +2512,7 @@ def rotate(self, rotation_vectors, graph=None, label=None): def add_rotation_triples(self, rotation_vectors, child_sample_id): activity_id = f"operation:{uuid.uuid4()}" - activity = self.graph.create_node(activity_id, UNSAFEASMO.RotationOperation) + activity = self.graph.create_node(activity_id, UNSAFEASMO.Rotation) self.graph.add((child_sample_id, PROV.wasGeneratedBy, activity)) self.graph.add((child_sample_id, PROV.wasDerivedFrom, self.sample)) @@ -2594,7 +2594,7 @@ def translate(self, translation_vector, def add_translation_triples(self, translation_vector, plane, distance, ): activity_id = f"operation:{uuid.uuid4()}" - activity = self.graph.create_node(activity_id, UNSAFEASMO.TranslationOperation) + activity = self.graph.create_node(activity_id, UNSAFEASMO.Translation) self.graph.add((self.sample, PROV.wasGeneratedBy, activity)) #now add specifics @@ -2634,7 +2634,7 @@ def shear(self, shear_vector, def add_shear_triples(self, translation_vector, plane, distance, ): activity_id = f"operation:{uuid.uuid4()}" - activity = self.graph.create_node(activity_id, UNSAFEASMO.ShearOperation) + activity = self.graph.create_node(activity_id, UNSAFEASMO.Shear) self.graph.add((self.sample, PROV.wasGeneratedBy, activity)) #now add specifics @@ -2647,12 +2647,14 @@ def add_shear_triples(self, translation_vector, plane, distance, ): #if plane is provided, add that as well if plane is not None: - plane_vector = self.graph.create_node(f"{activity_id}_PlaneVector", CMSO.Vector) - self.graph.add((activity, UNSAFECMSO.hasPlane, plane_vector)) + plane = self.graph.create_node(f"{activity_id}_Plane", CMSO.Plane) + plane_vector = self.graph.create_node(f"{activity_id}_PlaneVector", UNSAFECMSO.NormalVector) + self.graph.add((activity, UNSAFECMSO.hasPlane, plane)) + self.graph.add((plane, UNSAFECMSO.hasNormalVector, plane_vector)) self.graph.add((plane_vector, CMSO.hasComponent_x, Literal(plane[0], datatype=XSD.float),)) self.graph.add((plane_vector, CMSO.hasComponent_y, Literal(plane[1], datatype=XSD.float),)) self.graph.add((plane_vector, CMSO.hasComponent_z, Literal(plane[2], datatype=XSD.float),)) - self.graph.add((activity, UNSAFECMSO.hasDistance, Literal(distance, datatype=XSD.float))) + self.graph.add((plane, UNSAFECMSO.hasDistanceFromOrigin, Literal(distance, datatype=XSD.float))) def copy_defects(self, parent_sample): if self.sample is None: