From 45f50ca747d36d0adfc220fba1c60009cc58fa5f Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Thu, 22 Apr 2021 18:19:47 +0100 Subject: [PATCH] Don't loop over original atoms when searching for ions. [ref #193] --- python/BioSimSpace/Solvent/_solvent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/BioSimSpace/Solvent/_solvent.py b/python/BioSimSpace/Solvent/_solvent.py index 31ddd9290..3e245c7cb 100644 --- a/python/BioSimSpace/Solvent/_solvent.py +++ b/python/BioSimSpace/Solvent/_solvent.py @@ -916,7 +916,10 @@ def _solvate(molecule, box, angles, shell, model, num_point, water_ion_lines = [] with open("solvated_ions.gro", "r") as file: - for line in file: + # Only loop over lines that don't include the original + # system/molecule, since that might also include ions. + lines = file.readlines()[molecule.nAtoms()+2:] + for line in lines: # This is a Sodium atom. if _re.search("NA", line): water_ion_lines.append(line)