Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #192 #193

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def addMolecules(self, molecules):

# Remove velocities if any molecules are missing them.
if self.nMolecules() > 1:
# Search for water molecules in the system.
# Search for molecules with a velocity property.
try:
mols_with_velocities = self.search(
f"mols with property velocity"
Expand All @@ -638,6 +638,19 @@ def addMolecules(self, molecules):
except:
num_vels = 0

# Search for perturbable molecules with a velocity property.
# Only consider the lambda = 0 end state.
try:
pert_mols_with_velocities = self.search(
f"mols with property velocity0"
).molecules()
num_pert_vels = len(pert_mols_with_velocities)
except:
num_pert_vels = 0

# Compute the total number of molecules with velocities.
num_vels = num_vels + num_pert_vels

# Not all molecules have velocities.
if num_vels > 0 and num_vels != self.nMolecules():
_warnings.warn(
Expand All @@ -651,6 +664,18 @@ def addMolecules(self, molecules):
_warnings.warn(
"Failed to remove 'velocity' property from all molecules!"
)
if num_pert_vels > 0:
try:
self._sire_object = _SireIO.removeProperty(
self._sire_object, "velocity0"
)
self._sire_object = _SireIO.removeProperty(
self._sire_object, "velocity1"
)
except:
_warnings.warn(
"Failed to remove 'velocity0' and 'velocity1' property from molecules!"
)

def removeMolecules(self, molecules):
"""
Expand Down
27 changes: 26 additions & 1 deletion python/BioSimSpace/_SireWrappers/_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def addMolecules(self, molecules):

# Remove velocities if any molecules are missing them.
if self.nMolecules() > 1:
# Search for water molecules in the system.
# Search for molecules with a velocity property.
try:
mols_with_velocities = self.search(
f"mols with property velocity"
Expand All @@ -638,6 +638,19 @@ def addMolecules(self, molecules):
except:
num_vels = 0

# Search for perturbable molecules with a velocity property.
# Only consider the lambda = 0 end state.
try:
pert_mols_with_velocities = self.search(
f"mols with property velocity0"
).molecules()
num_pert_vels = len(pert_mols_with_velocities)
except:
num_pert_vels = 0

# Compute the total number of molecules with velocities.
num_vels = num_vels + num_pert_vels

# Not all molecules have velocities.
if num_vels > 0 and num_vels != self.nMolecules():
_warnings.warn(
Expand All @@ -651,6 +664,18 @@ def addMolecules(self, molecules):
_warnings.warn(
"Failed to remove 'velocity' property from all molecules!"
)
if num_pert_vels > 0:
try:
self._sire_object = _SireIO.removeProperty(
self._sire_object, "velocity0"
)
self._sire_object = _SireIO.removeProperty(
self._sire_object, "velocity1"
)
except:
_warnings.warn(
"Failed to remove 'velocity0' and 'velocity1' property from molecules!"
)

def removeMolecules(self, molecules):
"""
Expand Down
Loading