Skip to content

Commit 5fec8d7

Browse files
committed
Add unit test for fallback for failed formal charge calculation.
1 parent faee4ff commit 5fec8d7

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

tests/Parameters/test_parameters.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,20 @@ def test_acdoctor():
188188

189189
# Make sure parameterisation works when acdoctor is disabled.
190190
mol = BSS.Parameters.gaff(mol, acdoctor=False).getMolecule()
191+
192+
193+
def test_broken_sdf_formal_charge():
194+
"""
195+
Test that the PDB fallback works when using a broken SDF file
196+
as input for calculating the total formal charge.
197+
"""
198+
199+
# Load the molecule.
200+
mol = BSS.IO.readMolecules(f"{url}/broken.sdf")[0]
201+
202+
# Compute the formal charge.
203+
charge = BSS.Parameters._utils.formalCharge(mol)
204+
205+
from math import isclose
206+
207+
assert isclose(charge.value(), 0.0, abs_tol=1e-6)

tests/Sandpit/Exscientia/Parameters/test_parameters.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,20 @@ def test_acdoctor():
193193

194194
# Make sure parameterisation works when acdoctor is disabled.
195195
mol = BSS.Parameters.gaff(mol, acdoctor=False).getMolecule()
196+
197+
198+
def test_broken_sdf_formal_charge():
199+
"""
200+
Test that the PDB fallback works when using a broken SDF file
201+
as input for calculating the total formal charge.
202+
"""
203+
204+
# Load the molecule.
205+
mol = BSS.IO.readMolecules(f"{url}/broken.sdf")[0]
206+
207+
# Compute the formal charge.
208+
charge = BSS.Parameters._utils.formalCharge(mol)
209+
210+
from math import isclose
211+
212+
assert isclose(charge.value(), 0.0, abs_tol=1e-6)

0 commit comments

Comments
 (0)