Skip to content

Commit 9410577

Browse files
committed
Store ring-breaking and ring-making bond pairs as molecule properties.
1 parent d7d3fc8 commit 9410577

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/BioSimSpace/Align/_merge.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,24 @@ def merge(
13411341
if _ring_making or _ring_breaking:
13421342
_mol_info = edit_mol.info()
13431343

1344+
# Store the changing bond pairs as molecule properties so the
1345+
# simulation engine can apply a softcore force to the pair in the
1346+
# end state where the bond is absent, preventing large repulsion at
1347+
# the bonded/nonbonded lambda boundary. Ring-breaking (absent at
1348+
# λ=1) and ring-making (absent at λ=0) are stored separately so
1349+
# the engine can apply different alpha schedules to each.
1350+
for _pairs, _prop in [
1351+
(_ring_breaking, "ring_breaking_bonds"),
1352+
(_ring_making, "ring_making_bonds"),
1353+
]:
1354+
if _pairs:
1355+
edit_mol.set_property(
1356+
_prop,
1357+
_SireBase.IntegerArrayProperty(
1358+
[_idx for _pair in sorted(_pairs) for _idx in _pair]
1359+
),
1360+
)
1361+
13441362
for _changing, _suffix in [(_ring_making, "0"), (_ring_breaking, "1")]:
13451363
if not _changing:
13461364
continue

tests/Align/test_align.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,3 +1225,19 @@ def test_ring_breaking_cross_bond_cleanup():
12251225
assert not (a in atoms and b in atoms), (
12261226
f"improper{suffix} spans absent bond ({a},{b})"
12271227
)
1228+
1229+
# Check that the ring-breaking and ring-making bond properties are set.
1230+
def _read_pairs(prop_name):
1231+
if not sire_mol.has_property(prop_name):
1232+
return set()
1233+
flat = list(sire_mol.property(prop_name).to_list())
1234+
return {(flat[i], flat[i + 1]) for i in range(0, len(flat), 2)}
1235+
1236+
stored_breaking = _read_pairs("ring_breaking_bonds")
1237+
stored_making = _read_pairs("ring_making_bonds")
1238+
assert stored_breaking == ring_breaking, (
1239+
f"ring_breaking_bonds property mismatch: {stored_breaking} != {ring_breaking}"
1240+
)
1241+
assert stored_making == ring_making, (
1242+
f"ring_making_bonds property mismatch: {stored_making} != {ring_making}"
1243+
)

0 commit comments

Comments
 (0)