From c011e22a7ef4bc89aaebcb0c4e8c7b64a8aeb71b Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Mon, 13 Nov 2023 13:19:03 +0000 Subject: [PATCH 1/3] Sire.IO.AmberRst7.box_angles now returns correct units. [ref OpenBioSim/sire#119] --- .../BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py | 5 ++--- python/BioSimSpace/Trajectory/_trajectory.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py b/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py index e3d747ca0..2a62c42a3 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py @@ -1120,11 +1120,10 @@ def _split_molecules(frame, pdb, reference, work_dir, property_map={}): # Create a triclinic space from the information in the frame file. if isinstance(frame, _SireIO.AmberRst7): - # Get the box dimensions and angles. Take the values, since the - # units are wrong. + # Get the box dimensions and angles. degree = _SireUnits.degree dimensions = [x.value() for x in frame.box_dimensions()] - angles = [x.value() * degree for x in frame.box_angles()] + angles = [x.to(degree) for x in frame.box_angles()] box = _SireVol.TriclinicBox(*dimensions, *angles) else: box = _SireVol.TriclinicBox(frame.box_v1(), frame.box_v2(), frame.box_v3()) diff --git a/python/BioSimSpace/Trajectory/_trajectory.py b/python/BioSimSpace/Trajectory/_trajectory.py index e3d747ca0..2a62c42a3 100644 --- a/python/BioSimSpace/Trajectory/_trajectory.py +++ b/python/BioSimSpace/Trajectory/_trajectory.py @@ -1120,11 +1120,10 @@ def _split_molecules(frame, pdb, reference, work_dir, property_map={}): # Create a triclinic space from the information in the frame file. if isinstance(frame, _SireIO.AmberRst7): - # Get the box dimensions and angles. Take the values, since the - # units are wrong. + # Get the box dimensions and angles. degree = _SireUnits.degree dimensions = [x.value() for x in frame.box_dimensions()] - angles = [x.value() * degree for x in frame.box_angles()] + angles = [x.to(degree) for x in frame.box_angles()] box = _SireVol.TriclinicBox(*dimensions, *angles) else: box = _SireVol.TriclinicBox(frame.box_v1(), frame.box_v2(), frame.box_v3()) From 84660b2527823659b7c270848984088036550130 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Mon, 13 Nov 2023 13:25:24 +0000 Subject: [PATCH 2/3] Now cursor.rotate rotates velocities too. [ref OpenBioSim/sire#120] --- .../Sandpit/Exscientia/_SireWrappers/_system.py | 9 ++++++++- python/BioSimSpace/_SireWrappers/_system.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py index c1fed655f..3b9a22aa3 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py +++ b/python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_system.py @@ -1228,7 +1228,10 @@ def rotateBoxVectors( try: prop_name = property_map.get("velocity", "velocity") cursor = cursor.rotate( - center=center, matrix=rotation_matrix, map={"coordinates": prop_name} + center=center, + matrix=rotation_matrix, + rotate_velocities=False, + map={"coordinates": prop_name}, ) except: pass @@ -1241,12 +1244,14 @@ def rotateBoxVectors( cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) prop_name = property_map.get("coordinates", "coordinates") + "1" cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) except: @@ -1258,12 +1263,14 @@ def rotateBoxVectors( cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) prop_name = property_map.get("velocity", "velocity") + "1" cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) except: diff --git a/python/BioSimSpace/_SireWrappers/_system.py b/python/BioSimSpace/_SireWrappers/_system.py index 8208eb0da..3ab8258f9 100644 --- a/python/BioSimSpace/_SireWrappers/_system.py +++ b/python/BioSimSpace/_SireWrappers/_system.py @@ -1167,7 +1167,10 @@ def rotateBoxVectors( try: prop_name = property_map.get("coordinates", "coordinates") cursor = cursor.rotate( - center=center, matrix=rotation_matrix, map={"coordinates": prop_name} + center=center, + matrix=rotation_matrix, + rotate_velocities=False, + map={"coordinates": prop_name}, ) except: pass @@ -1176,7 +1179,10 @@ def rotateBoxVectors( try: prop_name = property_map.get("velocity", "velocity") cursor = cursor.rotate( - center=center, matrix=rotation_matrix, map={"coordinates": prop_name} + center=center, + matrix=rotation_matrix, + rotate_velocities=False, + map={"coordinates": prop_name}, ) except: pass @@ -1189,12 +1195,14 @@ def rotateBoxVectors( cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) prop_name = property_map.get("coordinates", "coordinates") + "1" cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) except: @@ -1206,12 +1214,14 @@ def rotateBoxVectors( cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) prop_name = property_map.get("velocity", "velocity") + "1" cursor = cursor.rotate( center=center, matrix=rotation_matrix, + rotate_velocities=False, map={"coordinates": prop_name}, ) except: From 90c476f83aa38e335d269d64345ed6a663160db1 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Mon, 13 Nov 2023 14:35:35 +0000 Subject: [PATCH 3/3] Still need to apply units to angles. --- python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py | 2 +- python/BioSimSpace/Trajectory/_trajectory.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py b/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py index 2a62c42a3..b49a05d7d 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py +++ b/python/BioSimSpace/Sandpit/Exscientia/Trajectory/_trajectory.py @@ -1123,7 +1123,7 @@ def _split_molecules(frame, pdb, reference, work_dir, property_map={}): # Get the box dimensions and angles. degree = _SireUnits.degree dimensions = [x.value() for x in frame.box_dimensions()] - angles = [x.to(degree) for x in frame.box_angles()] + angles = [x.to(degree) * degree for x in frame.box_angles()] box = _SireVol.TriclinicBox(*dimensions, *angles) else: box = _SireVol.TriclinicBox(frame.box_v1(), frame.box_v2(), frame.box_v3()) diff --git a/python/BioSimSpace/Trajectory/_trajectory.py b/python/BioSimSpace/Trajectory/_trajectory.py index 2a62c42a3..b49a05d7d 100644 --- a/python/BioSimSpace/Trajectory/_trajectory.py +++ b/python/BioSimSpace/Trajectory/_trajectory.py @@ -1123,7 +1123,7 @@ def _split_molecules(frame, pdb, reference, work_dir, property_map={}): # Get the box dimensions and angles. degree = _SireUnits.degree dimensions = [x.value() for x in frame.box_dimensions()] - angles = [x.to(degree) for x in frame.box_angles()] + angles = [x.to(degree) * degree for x in frame.box_angles()] box = _SireVol.TriclinicBox(*dimensions, *angles) else: box = _SireVol.TriclinicBox(frame.box_v1(), frame.box_v2(), frame.box_v3())