Skip to content

Commit

Permalink
replace triples
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Aug 20, 2024
1 parent 6208dce commit 38b9b32
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 38b9b32

Please sign in to comment.