Skip to content

Commit

Permalink
Merge pull request #90 from molssi-seamm/dev
Browse files Browse the repository at this point in the history
Bugfix: Properties in SDF files
  • Loading branch information
seamm authored Dec 11, 2024
2 parents 2c47cf0 + c8b8fb2 commit f3abde8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
=======
History
=======
2024.12.11 -- Bugfix: Properties in SDF files
* Transferring properties to the Open Babel and RDKit molecules was incorrect after
recent changes to the handling of properties. This fixes the problem, and now SDF
files have the properties correctly.

2024.12.7 -- Significant internal enhancement to property handling.
* An internal change, allowing listing and getting properties with wildcards,
working with multiple values at once. This is a significant change, but should
Expand Down
1 change: 1 addition & 0 deletions molsystem/openbabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def to_OBMol(self, properties=None):
if properties is not None:
data = self.properties.get(properties, include_system_properties=True)
for key, value in data.items():
value = value["value"]
pair.SetAttribute(key)
pair.SetValue(str(value))
ob_mol.CloneData(pair)
Expand Down
1 change: 1 addition & 0 deletions molsystem/rdkit_.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def to_RDKMol(self, properties=None):
if properties is not None:
data = self.properties.get(properties, include_system_properties=True)
for key, value in data.items():
value = value["value"]
if isinstance(value, int):
rdk_mol.SetIntProp(key, value)
elif isinstance(value, float):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_openbabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,12 @@ def test_all_residue_search(configuration):
def test_to_OBMol(Acetate):
"""Test creating an OBMol object from a structure."""
correct = {
"float property": "{'sid': 1, 'cid': 1, 'value': 3.14}",
"float property": 3.14,
"float property,units": "kcal/mol",
"int property": "{'sid': 1, 'cid': 1, 'value': 2}",
"int property": 2,
"net charge": -1,
"spin multiplicity": 1,
"str property": "{'sid': 1, 'cid': 1, 'value': 'Hi!'}",
"str property": "Hi!",
}

mol = Acetate.to_OBMol(properties="*")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_rdkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def test_version():
def test_to_RDKMol(Acetate):
"""Test creating a RDKMol object from a structure."""
correct = {
"float property": "{'sid': 1, 'cid': 1, 'value': 3.14}",
"float property": 3.14,
"float property,units": "kcal/mol",
"int property": "{'sid': 1, 'cid': 1, 'value': 2}",
"int property": 2,
"net charge": -1,
"spin multiplicity": 1,
"str property": "{'sid': 1, 'cid': 1, 'value': 'Hi!'}",
"str property": "Hi!",
}

mol = Acetate.to_RDKMol(properties="*")
Expand Down

0 comments on commit f3abde8

Please sign in to comment.