Skip to content

Commit d074644

Browse files
committed
Add workaround for Windows ROI merge performance issue.
1 parent dc85557 commit d074644

2 files changed

Lines changed: 46 additions & 19 deletions

File tree

src/BioSimSpace/Align/_merge.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,15 +1318,28 @@ def merge(
13181318
sf14 = _SireMM.CLJScaleFactor(
13191319
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
13201320
)
1321-
merged_intrascale = _SireIO.mergeIntrascale(
1322-
molecule0.property("intrascale"),
1323-
molecule1.property("intrascale"),
1324-
conn0,
1325-
conn1,
1326-
sf14,
1327-
mol0_merged_mapping,
1328-
mol1_merged_mapping,
1329-
)
1321+
if roi is not None:
1322+
# For ROI protein merges, build the intrascale matrices directly from
1323+
# the per-state connectivity, bypassing mergeIntrascale. Protein
1324+
# mutations involve no ring-breaking and no GLYCAM-style per-pair
1325+
# overrides, so the overrideIntrascale step in mergeIntrascale is a
1326+
# no-op. Bypassing it avoids a Windows-specific performance issue
1327+
# where the O(n²) override loop is very slow for large proteins.
1328+
# TODO: investigate the root cause and remove this workaround.
1329+
merged_intrascale = [
1330+
_SireMM.CLJNBPairs(conn0, sf14),
1331+
_SireMM.CLJNBPairs(conn1, sf14),
1332+
]
1333+
else:
1334+
merged_intrascale = _SireIO.mergeIntrascale(
1335+
molecule0.property("intrascale"),
1336+
molecule1.property("intrascale"),
1337+
conn0,
1338+
conn1,
1339+
sf14,
1340+
mol0_merged_mapping,
1341+
mol1_merged_mapping,
1342+
)
13301343

13311344
# Store the two molecular components.
13321345
edit_mol.set_property("molecule0", molecule0)

src/BioSimSpace/Sandpit/Exscientia/Align/_merge.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,20 +1301,34 @@ def merge(
13011301
# Set the "connectivity" property.
13021302
edit_mol.set_property("connectivity", conn)
13031303

1304-
# Merge the intrascale properties of the two molecules.
13051304
ff = molecule0.property(ff0)
13061305
sf14 = _SireMM.CLJScaleFactor(
13071306
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
13081307
)
1309-
merged_intrascale = _SireIO.mergeIntrascale(
1310-
molecule0.property("intrascale"),
1311-
molecule1.property("intrascale"),
1312-
conn0,
1313-
conn1,
1314-
sf14,
1315-
mol0_merged_mapping,
1316-
mol1_merged_mapping,
1317-
)
1308+
1309+
# Merge the intrascale properties of the two molecules.
1310+
if roi is not None:
1311+
# For ROI protein merges, build the intrascale matrices directly from
1312+
# the per-state connectivity, bypassing mergeIntrascale. Protein
1313+
# mutations involve no ring-breaking and no GLYCAM-style per-pair
1314+
# overrides, so the overrideIntrascale step in mergeIntrascale is a
1315+
# no-op. Bypassing it avoids a Windows-specific performance issue
1316+
# where the O(n²) override loop is very slow for large proteins.
1317+
# TODO: investigate the root cause and remove this workaround.
1318+
merged_intrascale = [
1319+
_SireMM.CLJNBPairs(conn0, sf14),
1320+
_SireMM.CLJNBPairs(conn1, sf14),
1321+
]
1322+
else:
1323+
merged_intrascale = _SireIO.mergeIntrascale(
1324+
molecule0.property("intrascale"),
1325+
molecule1.property("intrascale"),
1326+
conn0,
1327+
conn1,
1328+
sf14,
1329+
mol0_merged_mapping,
1330+
mol1_merged_mapping,
1331+
)
13181332

13191333
# Store the two molecular components.
13201334
edit_mol.set_property("molecule0", molecule0)

0 commit comments

Comments
 (0)