Skip to content

Commit

Permalink
Recover missing molecule0 and molecule1 properties. [closes #248]
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Feb 22, 2024
1 parent c2aaf0b commit 50b5bb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 44 deletions.
28 changes: 6 additions & 22 deletions python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ def __init__(self, molecule):
if isinstance(molecule, _SireMol._Mol.Molecule):
super().__init__(molecule)
if self._sire_object.hasProperty("is_perturbable"):
self._convertFromMergedMolecule()
# Flag that the molecule is perturbable.
self._is_perturbable = True

# Extract the end states.
if molecule.hasProperty("molecule0"):
self._molecule = Molecule(molecule.property("molecule0"))
self._molecule0 = Molecule(molecule.property("molecule0"))
else:
self._molecule0, _ = self._extractMolecule()
if molecule.hasProperty("molecule1"):
self._molecule = Molecule(molecule.property("molecule1"))
self._molecule1 = Molecule(molecule.property("molecule1"))
else:
self._molecule1, _ = self._extractMolecule(is_lambda1=True)

Expand Down Expand Up @@ -1565,25 +1568,6 @@ def _getPropertyMap1(self):

return property_map

def _convertFromMergedMolecule(self):
"""Convert from a merged molecule."""

# Extract the components of the merged molecule.
try:
mol0 = self._sire_object.property("molecule0")
mol1 = self._sire_object.property("molecule1")
except:
raise _IncompatibleError(
"The merged molecule doesn't have the required properties!"
)

# Store the components.
self._molecule0 = Molecule(mol0)
self._molecule1 = Molecule(mol1)

# Flag that the molecule is perturbable.
self._is_perturbable = True

def _fixCharge(self, property_map={}):
"""
Make the molecular charge an integer value.
Expand Down
28 changes: 6 additions & 22 deletions python/BioSimSpace/_SireWrappers/_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ def __init__(self, molecule):
if isinstance(molecule, _SireMol._Mol.Molecule):
super().__init__(molecule)
if self._sire_object.hasProperty("is_perturbable"):
self._convertFromMergedMolecule()
# Flag that the molecule is perturbable.
self._is_perturbable = True

# Extract the end states.
if molecule.hasProperty("molecule0"):
self._molecule = Molecule(molecule.property("molecule0"))
self._molecule0 = Molecule(molecule.property("molecule0"))
else:
self._molecule0, _ = self._extractMolecule()
if molecule.hasProperty("molecule1"):
self._molecule = Molecule(molecule.property("molecule1"))
self._molecule1 = Molecule(molecule.property("molecule1"))
else:
self._molecule1, _ = self._extractMolecule(is_lambda1=True)

Expand Down Expand Up @@ -1521,25 +1524,6 @@ def _getPropertyMap1(self):

return property_map

def _convertFromMergedMolecule(self):
"""Convert from a merged molecule."""

# Extract the components of the merged molecule.
try:
mol0 = self._sire_object.property("molecule0")
mol1 = self._sire_object.property("molecule1")
except:
raise _IncompatibleError(
"The merged molecule doesn't have the required properties!"
)

# Store the components.
self._molecule0 = Molecule(mol0)
self._molecule1 = Molecule(mol1)

# Flag that the molecule is perturbable.
self._is_perturbable = True

def _fixCharge(self, property_map={}):
"""
Make the molecular charge an integer value.
Expand Down

0 comments on commit 50b5bb6

Please sign in to comment.