Skip to content

Commit 51e0c53

Browse files
committed
Backport fix from PR #490. [ci skip]
1 parent 0d616f5 commit 51e0c53

1 file changed

Lines changed: 1 addition & 202 deletions

File tree

python/BioSimSpace/Align/_merge.py

Lines changed: 1 addition & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,214 +1180,13 @@ def merge(
11801180
# Create the CLJNBPairs matrices.
11811181
ff = molecule0.property(ff0)
11821182

1183+
# Create the new intrascale matrices.
11831184
scale_factor_14 = _SireMM.CLJScaleFactor(
11841185
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
11851186
)
11861187
clj_nb_pairs0 = _SireMM.CLJNBPairs(conn0, scale_factor_14)
11871188
clj_nb_pairs1 = _SireMM.CLJNBPairs(conn1, scale_factor_14)
11881189

1189-
# Loop over all atoms unique to molecule0.
1190-
for idx0 in atoms0_idx:
1191-
# Map the index to its position in the merged molecule.
1192-
idx0 = mol0_merged_mapping[idx0]
1193-
1194-
# Loop over all atoms unique to molecule1.
1195-
for idx1 in atoms1_idx:
1196-
# Map the index to its position in the merged molecule.
1197-
idx1 = mol1_merged_mapping[idx1]
1198-
1199-
# Work out the connection type between the atoms, in molecule 0.
1200-
conn_type0 = conn0.connection_type(idx0, idx1)
1201-
1202-
# The atoms aren't bonded.
1203-
if conn_type0 == 0:
1204-
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
1205-
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)
1206-
1207-
# The atoms are part of a dihedral.
1208-
elif conn_type0 == 4:
1209-
clj_scale_factor = _SireMM.CLJScaleFactor(
1210-
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
1211-
)
1212-
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)
1213-
1214-
# The atoms are bonded
1215-
else:
1216-
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
1217-
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)
1218-
1219-
# Work out the connection type between the atoms, in molecule 1.
1220-
conn_type1 = conn1.connection_type(idx0, idx1)
1221-
1222-
# The atoms aren't bonded.
1223-
if conn_type1 == 0:
1224-
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
1225-
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)
1226-
1227-
# The atoms are part of a dihedral.
1228-
elif conn_type1 == 4:
1229-
clj_scale_factor = _SireMM.CLJScaleFactor(
1230-
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
1231-
)
1232-
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)
1233-
1234-
# The atoms are bonded
1235-
else:
1236-
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
1237-
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)
1238-
1239-
# Copy the intrascale from molecule1 into clj_nb_pairs0.
1240-
1241-
# Perform a triangular loop over atoms from molecule1.
1242-
if roi is None:
1243-
iterlen = molecule1.num_atoms()
1244-
iterrange = list(range(molecule1.num_atoms()))
1245-
# When region of interest is defined, perfrom loop from these indices
1246-
else:
1247-
for roi_res in roi:
1248-
# Get atom indices of ROI residue in molecule1
1249-
molecule1_roi = molecule1.residues()[roi_res]
1250-
molecule1_roi_idx = [a.index() for a in molecule1_roi]
1251-
iterlen = len(molecule1_roi_idx)
1252-
iterrange = molecule1_roi_idx
1253-
1254-
for x in range(0, iterlen):
1255-
# Convert to an AtomIdx.
1256-
idx = iterrange[x]
1257-
idx = _SireMol.AtomIdx(idx)
1258-
1259-
# Map the index to its position in the merged molecule.
1260-
idx_map = mol1_merged_mapping[idx]
1261-
1262-
for y in range(x + 1, iterlen):
1263-
idy = iterrange[y]
1264-
# Convert to an AtomIdx.
1265-
idy = _SireMol.AtomIdx(idy)
1266-
1267-
# Map the index to its position in the merged molecule.
1268-
idy_map = mol1_merged_mapping[idy]
1269-
1270-
conn_type = conn0.connection_type(idx_map, idy_map)
1271-
# The atoms aren't bonded.
1272-
if conn_type == 0:
1273-
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
1274-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1275-
1276-
# The atoms are part of a dihedral.
1277-
elif conn_type == 4:
1278-
clj_scale_factor = _SireMM.CLJScaleFactor(
1279-
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
1280-
)
1281-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1282-
1283-
# The atoms are bonded
1284-
else:
1285-
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
1286-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1287-
1288-
# Now copy in all intrascale values from molecule0 into clj_nb_pairs0.
1289-
1290-
# Work out the iteration length and range.
1291-
if roi is None:
1292-
iterlen = molecule0.num_atoms()
1293-
iterrange = list(range(molecule0.num_atoms()))
1294-
else:
1295-
for roi_res in roi:
1296-
# Get atom indices of ROI residue in molecule0.
1297-
molecule0_roi = molecule0.residues()[roi_res]
1298-
molecule0_roi_idx = [a.index() for a in molecule0_roi]
1299-
iterlen = len(molecule0_roi_idx)
1300-
iterrange = molecule0_roi_idx
1301-
1302-
# Perform a triangular loop over atoms from molecule0.
1303-
for x in range(0, iterlen):
1304-
# Convert to an AtomIdx.
1305-
idx = iterrange[x]
1306-
idx = _SireMol.AtomIdx(idx)
1307-
1308-
# Map the index to its position in the merged molecule.
1309-
idx_map = mol0_merged_mapping[idx]
1310-
1311-
for y in range(x + 1, iterlen):
1312-
idy = iterrange[y]
1313-
# Convert to an AtomIdx.
1314-
idy = _SireMol.AtomIdx(idy)
1315-
1316-
# Map the index to its position in the merged molecule.
1317-
idy_map = mol0_merged_mapping[idy]
1318-
1319-
# Get the connection type between the atoms.
1320-
conn_type = conn0.connection_type(idx_map, idy_map)
1321-
1322-
# The atoms aren't bonded.
1323-
if conn_type == 0:
1324-
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
1325-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1326-
1327-
# The atoms are part of a dihedral.
1328-
elif conn_type == 4:
1329-
clj_scale_factor = _SireMM.CLJScaleFactor(
1330-
ff.electrostatic14_scale_factor(),
1331-
ff.vdw14_scale_factor(),
1332-
)
1333-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1334-
1335-
# The atoms are bonded
1336-
else:
1337-
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
1338-
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)
1339-
1340-
# Finally, copy the intrascale from molecule1 into clj_nb_pairs1.
1341-
1342-
# Work out the iteration length and range.
1343-
if roi is None:
1344-
iterlen = molecule1.num_atoms()
1345-
iterrange = list(range(molecule1.num_atoms()))
1346-
1347-
else:
1348-
for roi_res in roi:
1349-
molecule1_roi = molecule1.residues()[roi_res]
1350-
molecule1_roi_idx = [a.index() for a in molecule1_roi]
1351-
iterlen = len(molecule1_roi_idx)
1352-
iterrange = molecule1_roi_idx
1353-
1354-
# Perform a triangular loop over atoms from molecule1.
1355-
for x in range(0, iterlen):
1356-
# Convert to an AtomIdx.
1357-
idx = iterrange[x]
1358-
idx = _SireMol.AtomIdx(idx)
1359-
1360-
# Map the index to its position in the merged molecule.
1361-
idx = mol1_merged_mapping[idx]
1362-
1363-
for y in range(x + 1, iterlen):
1364-
idy = iterrange[y]
1365-
# Convert to an AtomIdx.
1366-
idy = _SireMol.AtomIdx(idy)
1367-
1368-
# Map the index to its position in the merged molecule.
1369-
idy = mol1_merged_mapping[idy]
1370-
1371-
# Get the connection type between the atoms.
1372-
conn_type = conn1.connection_type(idx, idy)
1373-
1374-
if conn_type == 0:
1375-
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
1376-
clj_nb_pairs1.set(idx, idy, clj_scale_factor)
1377-
1378-
# The atoms are part of a dihedral.
1379-
elif conn_type == 4:
1380-
clj_scale_factor = _SireMM.CLJScaleFactor(
1381-
ff.electrostatic14_scale_factor(),
1382-
ff.vdw14_scale_factor(),
1383-
)
1384-
clj_nb_pairs1.set(idx, idy, clj_scale_factor)
1385-
1386-
# The atoms are bonded
1387-
else:
1388-
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
1389-
clj_nb_pairs1.set(idx, idy, clj_scale_factor)
1390-
13911190
# Store the two molecular components.
13921191
edit_mol.set_property("molecule0", molecule0)
13931192
edit_mol.set_property("molecule1", molecule1)

0 commit comments

Comments
 (0)