@@ -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