From 11b546d68cd55a13c89b10a9c57d979349725cfd Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Fri, 5 Apr 2024 12:36:10 +0200 Subject: [PATCH 1/4] fix wrong natoms --- pyscal_rdf/structure.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyscal_rdf/structure.py b/pyscal_rdf/structure.py index 38bdf98..dfca601 100644 --- a/pyscal_rdf/structure.py +++ b/pyscal_rdf/structure.py @@ -248,6 +248,7 @@ def delete(self, ids=None, indices=None, condition=None, selection=False): masks = self.atoms._generate_bool_list(ids=ids, indices=indices, condition=condition, selection=selection) delete_list = [masks[self.atoms["head"][x]] for x in range(self.atoms.ntotal)] delete_ids = [x for x in range(self.atoms.ntotal) if delete_list[x]] + actual_natoms = self.natoms self.atoms._delete_atoms(delete_ids) if self.graph is not None: @@ -257,7 +258,7 @@ def delete(self, ids=None, indices=None, condition=None, selection=False): 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(self.natoms-val, datatype=XSD.integer))) + self.graph.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) @@ -295,9 +296,8 @@ def delete(self, ids=None, indices=None, condition=None, selection=False): species = data[species_identifier]['value'] #clean up items - positions = [pos for count, pos in enumerate(positions) if count not in delete_ids] - species = [pos for count, pos in enumerate(species) if count not in delete_ids] - + positions = self.schema.positions + species = self.schema.species datadict = { position_identifier:{ "value": positions, From eceed02b0487ff23dd94a159f4c4e080672d90c1 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Fri, 5 Apr 2024 12:37:45 +0200 Subject: [PATCH 2/4] fix attribute name --- pyscal_rdf/structure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyscal_rdf/structure.py b/pyscal_rdf/structure.py index dfca601..0716626 100644 --- a/pyscal_rdf/structure.py +++ b/pyscal_rdf/structure.py @@ -296,8 +296,8 @@ def delete(self, ids=None, indices=None, condition=None, selection=False): species = data[species_identifier]['value'] #clean up items - positions = self.schema.positions - species = self.schema.species + positions = self.schema.atom_attribute.positions + species = self.schema.atom_attribute.species datadict = { position_identifier:{ "value": positions, From 493aa77898106b3b6eabf515b88075f368d61106 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Fri, 5 Apr 2024 12:40:18 +0200 Subject: [PATCH 3/4] simplify rewwriting of files after deletion --- pyscal_rdf/structure.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pyscal_rdf/structure.py b/pyscal_rdf/structure.py index 0716626..d94f721 100644 --- a/pyscal_rdf/structure.py +++ b/pyscal_rdf/structure.py @@ -289,22 +289,14 @@ def delete(self, ids=None, indices=None, condition=None, selection=False): 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() - #open the file for reading - with open(filepath, 'r') as fin: - data = json.load(fin) - positions = data[position_identifier]['value'] - species = data[species_identifier]['value'] - #clean up items - positions = self.schema.atom_attribute.positions - species = self.schema.atom_attribute.species datadict = { position_identifier:{ - "value": positions, + "value": self.schema.atom_attribute.position(), "label": "position", }, species_identifier:{ - "value": species, + "value": self.schema.atom_attribute.species(), "label": "species", }, } From d3f2f54418de221e43aaedd24fb61bc5a8c05803 Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Fri, 5 Apr 2024 12:42:24 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Bump=20version:=200.2.5=20=E2=86=92=200.2.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 214760d..8aa8549 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.5 +current_version = 0.2.6 commit = True tag = False diff --git a/setup.py b/setup.py index edf4ab1..a2c8380 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='pyscal_rdf', - version='0.2.5', + version='0.2.6', author='Abril Azocar Guzman, Sarath Menon', author_email='sarath.menon@pyscal.org', description='Ontology based structural manipulation and quering',