Skip to content

Commit 82877ed

Browse files
committed
Return unsquashed system from getFrame(). [closes #402]
1 parent 9ed2d1f commit 82877ed

File tree

1 file changed

+48
-21
lines changed

1 file changed

+48
-21
lines changed

python/BioSimSpace/Process/_amber.py

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -732,31 +732,58 @@ def getFrame(self, index):
732732
# Create a copy of the existing system object.
733733
old_system = self._system.copy()
734734

735-
# Update the coordinates and velocities and return a mapping between
736-
# the molecule indices in the two systems.
737-
sire_system, mapping = _SireIO.updateCoordinatesAndVelocities(
738-
old_system._sire_object,
739-
new_system._sire_object,
740-
self._mapping,
741-
is_lambda1,
742-
self._property_map,
743-
self._property_map,
744-
)
735+
if isinstance(self._protocol, _Protocol._FreeEnergyMixin):
736+
# Udpate the coordinates and velocities and return a mapping between
737+
# the molecule indices in the two systems.
738+
mapping = {
739+
_SireMol.MolIdx(x): _SireMol.MolIdx(x)
740+
for x in range(0, self._squashed_system.nMolecules())
741+
}
742+
(
743+
self._squashed_system._sire_object,
744+
_,
745+
) = _SireIO.updateCoordinatesAndVelocities(
746+
self._squashed_system._sire_object,
747+
new_system._sire_object,
748+
mapping,
749+
is_lambda1,
750+
self._property_map,
751+
self._property_map,
752+
)
753+
754+
# Update the unsquashed system based on the updated squashed system.
755+
old_system = _unsquash(
756+
old_system,
757+
self._squashed_system,
758+
self._mapping,
759+
explicit_dummies=self._explicit_dummies,
760+
)
761+
762+
else:
763+
# Update the coordinates and velocities and return a mapping between
764+
# the molecule indices in the two systems.
765+
sire_system, mapping = _SireIO.updateCoordinatesAndVelocities(
766+
old_system._sire_object,
767+
new_system._sire_object,
768+
self._mapping,
769+
is_lambda1,
770+
self._property_map,
771+
self._property_map,
772+
)
745773

746-
# Update the underlying Sire object.
747-
old_system._sire_object = sire_system
774+
# Update the underlying Sire object.
775+
old_system._sire_object = sire_system
748776

749-
# Store the mapping between the MolIdx in both systems so we don't
750-
# need to recompute it next time.
751-
self._mapping = mapping
777+
# Store the mapping between the MolIdx in both systems so we don't
778+
# need to recompute it next time.
779+
self._mapping = mapping
752780

753781
# Update the box information in the original system.
754-
if self._has_box:
755-
if "space" in new_system._sire_object.propertyKeys():
756-
box = new_system._sire_object.property("space")
757-
old_system._sire_object.setProperty(
758-
self._property_map.get("space", "space"), box
759-
)
782+
if "space" in new_system._sire_object.propertyKeys():
783+
box = new_system._sire_object.property("space")
784+
old_system._sire_object.setProperty(
785+
self._property_map.get("space", "space"), box
786+
)
760787

761788
return old_system
762789

0 commit comments

Comments
 (0)