Skip to content

Commit

Permalink
working copy_defects function
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Aug 15, 2024
1 parent 3772047 commit c0ddf11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions atomrdf/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,13 +1264,18 @@ def iterate_and_rename_triples(self, item):
else:
uri_dict[triple[0].toPython()] = triple[0].toPython()

new_triples = []
for triple in triples:
if triple[0].toPython() in uri_dict.keys():
triples[0] = URIRef(uri_dict[triple[0].toPython()])
if triple[2].toPython() in uri_dict.keys():
triples[2] = URIRef(uri_dict[triple[2].toPython()])
subject = triple[0]
if subject.toPython() in uri_dict.keys():
subject = URIRef(uri_dict[subject.toPython()])
predicate = triple[1]
object = triple[2]
if object.toPython() in uri_dict.keys():
object = URIRef(uri_dict[object.toPython()])
new_triples.append((subject, predicate, object))

return URIRef(uri_dict[item.toPython()]), triples
return URIRef(uri_dict[item.toPython()]), new_triples

def get_sample(self, sample, no_atoms=False, stop_at_sample=True):
"""
Expand Down
3 changes: 2 additions & 1 deletion atomrdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2573,4 +2573,5 @@ def copy_defects(self, parent_sample):
self.graph.add((material, CMSO.hasDefect, new_defect))
#add the triples to the graph
for triple in defect_triples:
self.graph.add((triple))
#print(triple)
self.graph.add(triple)

0 comments on commit c0ddf11

Please sign in to comment.