From 645ad5353d4bd3ee5b384975d7c59764e4ccf947 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Fri, 1 Dec 2023 15:43:08 +0000 Subject: [PATCH] Reconstruct intrascale matrices using the GroTop parser. [closes #213] --- python/BioSimSpace/IO/_io.py | 25 +++++++++++++++++-- .../BioSimSpace/Sandpit/Exscientia/IO/_io.py | 25 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/python/BioSimSpace/IO/_io.py b/python/BioSimSpace/IO/_io.py index fce3193e0..705e8f9d6 100644 --- a/python/BioSimSpace/IO/_io.py +++ b/python/BioSimSpace/IO/_io.py @@ -1100,9 +1100,13 @@ def readPerturbableSystem(top0, coords0, top1, coords1, property_map={}): # Flag that the molecule is perturbable. mol.setProperty("is_perturbable", _SireBase.wrap(True)) + # Get the two molecules. + mol0 = system0[idx]._sire_object + mol1 = system1[idx]._sire_object + # Add the molecule0 and molecule1 properties. - mol.setProperty("molecule0", system0[idx]._sire_object) - mol.setProperty("molecule1", system1[idx]._sire_object) + mol.setProperty("molecule0", mol0) + mol.setProperty("molecule1", mol1) # Get the connectivity property name. conn_prop = property_map.get("connectivity", "connectivity") @@ -1121,6 +1125,23 @@ def readPerturbableSystem(top0, coords0, top1, coords1, property_map={}): mol = mol.removeProperty(conn_prop + "0").molecule() mol = mol.removeProperty(conn_prop + "1").molecule() + # Reconstruct the intrascale matrices using the GroTop parser. + intra0 = ( + _SireIO.GroTop(_Molecule(mol0).toSystem()._sire_object) + .toSystem()[0] + .property("intrascale") + ) + intra1 = ( + _SireIO.GroTop(_Molecule(mol1).toSystem()._sire_object) + .toSystem()[0] + .property("intrascale") + ) + + # Set the "intrascale" properties. + intrascale_prop = property_map.get("intrascale", "intrascale") + mol.setProperty(intrascale_prop + "0", intra0) + mol.setProperty(intrascale_prop + "1", intra0) + # Commit the changes. mol = _Molecule(mol.commit()) diff --git a/python/BioSimSpace/Sandpit/Exscientia/IO/_io.py b/python/BioSimSpace/Sandpit/Exscientia/IO/_io.py index fce3193e0..705e8f9d6 100644 --- a/python/BioSimSpace/Sandpit/Exscientia/IO/_io.py +++ b/python/BioSimSpace/Sandpit/Exscientia/IO/_io.py @@ -1100,9 +1100,13 @@ def readPerturbableSystem(top0, coords0, top1, coords1, property_map={}): # Flag that the molecule is perturbable. mol.setProperty("is_perturbable", _SireBase.wrap(True)) + # Get the two molecules. + mol0 = system0[idx]._sire_object + mol1 = system1[idx]._sire_object + # Add the molecule0 and molecule1 properties. - mol.setProperty("molecule0", system0[idx]._sire_object) - mol.setProperty("molecule1", system1[idx]._sire_object) + mol.setProperty("molecule0", mol0) + mol.setProperty("molecule1", mol1) # Get the connectivity property name. conn_prop = property_map.get("connectivity", "connectivity") @@ -1121,6 +1125,23 @@ def readPerturbableSystem(top0, coords0, top1, coords1, property_map={}): mol = mol.removeProperty(conn_prop + "0").molecule() mol = mol.removeProperty(conn_prop + "1").molecule() + # Reconstruct the intrascale matrices using the GroTop parser. + intra0 = ( + _SireIO.GroTop(_Molecule(mol0).toSystem()._sire_object) + .toSystem()[0] + .property("intrascale") + ) + intra1 = ( + _SireIO.GroTop(_Molecule(mol1).toSystem()._sire_object) + .toSystem()[0] + .property("intrascale") + ) + + # Set the "intrascale" properties. + intrascale_prop = property_map.get("intrascale", "intrascale") + mol.setProperty(intrascale_prop + "0", intra0) + mol.setProperty(intrascale_prop + "1", intra0) + # Commit the changes. mol = _Molecule(mol.commit())