Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WBO testing #430

Merged
merged 11 commits into from
Oct 31, 2019
50 changes: 50 additions & 0 deletions openforcefield/data/molecules/molecule_anion.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

-OEChem-10251911083D

21 22 0 0 0 0 0 0 0999 V2000
2.5846 -1.9672 -3.6367 C 0 0 0 0 0 0 0 0 0 0 0 0
2.0132 -0.9725 -4.3521 N 0 0 0 0 0 0 0 0 0 0 0 0
1.3994 0.0009 -3.6427 C 0 0 0 0 0 0 0 0 0 0 0 0
1.3301 0.0263 -2.2591 C 0 0 0 0 0 0 0 0 0 0 0 0
1.9298 -1.0142 -1.5584 C 0 0 0 0 0 0 0 0 0 0 0 0
2.5710 -2.0339 -2.2528 C 0 0 0 0 0 0 0 0 0 0 0 0
1.8851 -1.0363 -0.1124 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9210 -1.6309 0.6081 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8783 -1.6520 2.0022 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7997 -1.0786 2.6757 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7638 -0.4841 1.9551 C 0 0 0 0 0 0 0 0 0 0 0 0
0.8066 -0.4630 0.5610 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7601 -1.0977 3.9561 O 0 5 0 0 0 0 0 0 0 0 0 0
3.0702 -2.7390 -4.2250 H 0 0 0 0 0 0 0 0 0 0 0 0
0.9485 0.7897 -4.2356 H 0 0 0 0 0 0 0 0 0 0 0 0
0.8212 0.8393 -1.7512 H 0 0 0 0 0 0 0 0 0 0 0 0
3.0493 -2.8630 -1.7412 H 0 0 0 0 0 0 0 0 0 0 0 0
3.7679 -2.0828 0.0975 H 0 0 0 0 0 0 0 0 0 0 0 0
3.6997 -2.1226 2.5403 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.0895 -0.0300 2.4565 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.0086 0.0041 0.0131 H 0 0 0 0 0 0 0 0 0 0 0 0
1 6 1 0 0 0 0
1 2 2 0 0 0 0
2 3 1 0 0 0 0
3 4 2 0 0 0 0
4 5 1 0 0 0 0
5 6 2 0 0 0 0
5 7 1 0 0 0 0
7 12 1 0 0 0 0
7 8 2 0 0 0 0
8 9 1 0 0 0 0
9 10 2 0 0 0 0
10 11 1 0 0 0 0
11 12 2 0 0 0 0
10 13 1 0 0 0 0
1 14 1 0 0 0 0
3 15 1 0 0 0 0
4 16 1 0 0 0 0
6 17 1 0 0 0 0
8 18 1 0 0 0 0
9 19 1 0 0 0 0
11 20 1 0 0 0 0
12 21 1 0 0 0 0
M CHG 1 13 -1
M END
$$$$
51 changes: 51 additions & 0 deletions openforcefield/data/molecules/molecule_neutral.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

-OEChem-10251911073D

22 23 0 0 0 0 0 0 0999 V2000
2.5824 -1.9679 -3.6368 C 0 0 0 0 0 0 0 0 0 0 0 0
2.0102 -0.9737 -4.3521 N 0 0 0 0 0 0 0 0 0 0 0 0
1.3965 -0.0002 -3.6425 C 0 0 0 0 0 0 0 0 0 0 0 0
1.3282 0.0255 -2.2588 C 0 0 0 0 0 0 0 0 0 0 0 0
1.9287 -1.0146 -1.5582 C 0 0 0 0 0 0 0 0 0 0 0 0
2.5698 -2.0343 -2.2529 C 0 0 0 0 0 0 0 0 0 0 0 0
1.8851 -1.0363 -0.1124 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9210 -1.6309 0.6081 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8783 -1.6520 2.0022 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7997 -1.0786 2.6757 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7638 -0.4841 1.9551 C 0 0 0 0 0 0 0 0 0 0 0 0
0.8066 -0.4630 0.5610 C 0 0 0 0 0 0 0 0 0 0 0 0
1.7583 -1.0986 4.0360 O 0 0 0 0 0 0 0 0 0 0 0 0
3.0678 -2.7397 -4.2253 H 0 0 0 0 0 0 0 0 0 0 0 0
0.9449 0.7882 -4.2352 H 0 0 0 0 0 0 0 0 0 0 0 0
0.8194 0.8385 -1.7508 H 0 0 0 0 0 0 0 0 0 0 0 0
3.0487 -2.8631 -1.7414 H 0 0 0 0 0 0 0 0 0 0 0 0
3.7685 -2.0817 0.0975 H 0 0 0 0 0 0 0 0 0 0 0 0
3.6885 -2.1157 2.5587 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.0783 -0.0356 2.4747 H 0 0 0 0 0 0 0 0 0 0 0 0
-0.0086 0.0048 0.0140 H 0 0 0 0 0 0 0 0 0 0 0 0
2.5449 -1.5434 4.3899 H 0 0 0 0 0 0 0 0 0 0 0 0
1 6 1 0 0 0 0
1 2 2 0 0 0 0
2 3 1 0 0 0 0
3 4 2 0 0 0 0
4 5 1 0 0 0 0
5 6 2 0 0 0 0
5 7 1 0 0 0 0
7 12 1 0 0 0 0
7 8 2 0 0 0 0
8 9 1 0 0 0 0
9 10 2 0 0 0 0
10 11 1 0 0 0 0
11 12 2 0 0 0 0
10 13 1 0 0 0 0
1 14 1 0 0 0 0
3 15 1 0 0 0 0
4 16 1 0 0 0 0
6 17 1 0 0 0 0
8 18 1 0 0 0 0
9 19 1 0 0 0 0
11 20 1 0 0 0 0
12 21 1 0 0 0 0
13 22 1 0 0 0 0
M END
$$$$
65 changes: 63 additions & 2 deletions openforcefield/tests/test_toolkits.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,68 @@ def test_compute_wiberg_bond_orders(self):
print([bond.fractional_bond_order for bond in molecule.bonds])
# TODO: Add test for equivalent Wiberg orders for equivalent bonds



@pytest.mark.skipif(not OpenEyeToolkitWrapper.is_available(), reason='OpenEye Toolkit not available')
def test_compute_wiberg_bond_orders_neutral_charge_mol(self):
"""Test OpenEyeToolkitWrapper compute_wiberg_bond_orders() for neutral and charged molecule"""

toolkit_wrapper = OpenEyeToolkitWrapper()
# Reading neutral molecule from file
filename = get_data_file_path('molecules/molecule_neutral.sdf')
molecule1 = Molecule.from_file(filename)
# Reading negative molecule from file
filename = get_data_file_path('molecules/molecule_anion.sdf')
molecule2 = Molecule.from_file(filename)

# Checking that only one additional bond is present ihe neutral molecule
assert (len(molecule1.bonds)==len(molecule2.bonds)+1)

for charge_model in ['am1', 'pm3']:
molecule1.compute_wiberg_bond_orders(toolkit_registry=toolkit_wrapper, charge_model=charge_model)

for i in molecule1.bonds:
if i.is_aromatic:
# Checking aromatic bonds
assert (1.15 < i.fractional_bond_order < 1.60)
elif (i.atom1.atomic_number == 1 or i.atom2.atomic_number == 1):
# Checking bond order of C-H or O-H bonds are around 1
assert (0.85 < i.fractional_bond_order < 1.05)
elif (i.atom1.atomic_number == 8 or i.atom2.atomic_number == 8):
# Checking C-O single bond
wbo_C_O_neutral = i.fractional_bond_order
assert (1.0 < wbo_C_O_neutral < 1.5)
else:
# Should be C-C single bond
assert (i.atom1_index == 4 and i.atom2_index == 6) or (i.atom1_index == 6 and i.atom2_index == 4)
wbo_C_C_neutral = i.fractional_bond_order
assert (1.0 < wbo_C_C_neutral < 1.3)

molecule2.compute_wiberg_bond_orders(toolkit_registry=toolkit_wrapper, charge_model=charge_model)
for i in molecule2.bonds:
if i.is_aromatic:
# Checking aromatic bonds
assert (1.0 < i.fractional_bond_order < 1.6)
elif (i.atom1.atomic_number == 1 or i.atom2.atomic_number == 1):
# Checking bond order of C-H or O-H bonds are around 1
assert (0.85 < i.fractional_bond_order < 1.05)
elif (i.atom1.atomic_number == 8 or i.atom2.atomic_number == 8):
# Checking C-O single bond
wbo_C_O_anion = i.fractional_bond_order
assert (1.3 < wbo_C_O_anion < 1.8)
else:
# Should be C-C single bond
assert(i.atom1_index == 4 and i.atom2_index == 6) or (i.atom1_index == 6 and i.atom2_index == 4)
wbo_C_C_anion = i.fractional_bond_order
assert (1.0 < wbo_C_C_anion < 1.3)

# Wiberg bond order of C-C single bond is higher in the anion
assert (wbo_C_C_anion > wbo_C_C_neutral)
# Wiberg bond order of C-O bond is higher in the anion
assert (wbo_C_O_anion > wbo_C_O_neutral)



@pytest.mark.skipif(not OpenEyeToolkitWrapper.is_available(), reason='OpenEye Toolkit not available')
def test_compute_wiberg_bond_orders_charged(self):
"""Test OpenEyeToolkitWrapper compute_wiberg_bond_orders() on a molecule with net charge +1"""
Expand All @@ -463,8 +525,7 @@ def test_compute_wiberg_bond_orders_charged(self):
molecule.compute_wiberg_bond_orders(toolkit_registry=toolkit_wrapper, charge_model=charge_model)
# TODO: Add test for equivalent Wiberg orders for equivalent bonds

@pytest.mark.skipif(not OpenEyeToolkitWrapper.is_available(),
reason='OpenEye Toolkit not available')
@pytest.mark.skipif(not OpenEyeToolkitWrapper.is_available(), reason='OpenEye Toolkit not available')
def test_compute_wiberg_bond_orders_double_bond(self):
"""Test OpenEyeToolkitWrapper compute_wiberg_bond_orders() on a molecule with a double bond"""

Expand Down
2 changes: 1 addition & 1 deletion openforcefield/typing/engines/smirnoff/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,7 @@ def create_force(self, system, topology, **kwargs):
#temp_mol.compute_partial_charges(quantum_chemical_method=self._quantum_chemical_method,
# partial_charge_method=self._partial_charge_method)
temp_mol.compute_partial_charges_am1bcc(toolkit_registry=toolkit_registry)

temp_mol.compute_wiberg_bond_orders(toolkit_registry=toolkit_registry)
# Assign charges to relevant atoms
for topology_molecule in topology._reference_molecule_to_topology_molecules[ref_mol]:

Expand Down