Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 1 addition & 204 deletions python/BioSimSpace/Align/_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,216 +1180,13 @@ def merge(
# Create the CLJNBPairs matrices.
ff = molecule0.property(ff0)

# Create the new intrascale matrices.
scale_factor_14 = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
)
clj_nb_pairs0 = _SireMM.CLJNBPairs(conn0, scale_factor_14)
clj_nb_pairs1 = _SireMM.CLJNBPairs(conn1, scale_factor_14)

# Loop over all atoms unique to molecule0.
for idx0 in atoms0_idx:
# Map the index to its position in the merged molecule.
idx0 = mol0_merged_mapping[idx0]

# Loop over all atoms unique to molecule1.
for idx1 in atoms1_idx:
# Map the index to its position in the merged molecule.
idx1 = mol1_merged_mapping[idx1]

# Work out the connection type between the atoms, in molecule 0.
conn_type0 = conn0.connection_type(idx0, idx1)

# The atoms aren't bonded.
if conn_type0 == 0:
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)

# The atoms are part of a dihedral.
elif conn_type0 == 4:
clj_scale_factor = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
)
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)

# The atoms are bonded
else:
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
clj_nb_pairs0.set(idx0, idx1, clj_scale_factor)

# Work out the connection type between the atoms, in molecule 1.
conn_type1 = conn1.connection_type(idx0, idx1)

# The atoms aren't bonded.
if conn_type1 == 0:
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)

# The atoms are part of a dihedral.
elif conn_type1 == 4:
clj_scale_factor = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
)
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)

# The atoms are bonded
else:
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
clj_nb_pairs1.set(idx0, idx1, clj_scale_factor)

# Copy the intrascale from molecule1 into clj_nb_pairs0.

# Perform a triangular loop over atoms from molecule1.
if roi is None:
iterlen = molecule1.num_atoms()
iterrange = list(range(molecule1.num_atoms()))
# When region of interest is defined, perfrom loop from these indices
else:
for roi_res in roi:
# Get atom indices of ROI residue in molecule1
molecule1_roi = molecule1.residues()[roi_res]
molecule1_roi_idx = [a.index() for a in molecule1_roi]
iterlen = len(molecule1_roi_idx)
iterrange = molecule1_roi_idx

for x in range(0, iterlen):
# Convert to an AtomIdx.
idx = iterrange[x]
idx = _SireMol.AtomIdx(idx)

# Map the index to its position in the merged molecule.
idx_map = mol1_merged_mapping[idx]

for y in range(x + 1, iterlen):
idy = iterrange[y]
# Convert to an AtomIdx.
idy = _SireMol.AtomIdx(idy)

# Map the index to its position in the merged molecule.
idy_map = mol1_merged_mapping[idy]

# Get the connection type between the atoms.
conn_type = conn0.connection_type(idx_map, idy_map)

# The atoms aren't bonded.
if conn_type == 0:
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# The atoms are part of a dihedral.
elif conn_type == 4:
clj_scale_factor = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(), ff.vdw14_scale_factor()
)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# The atoms are bonded
else:
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# Now copy in all intrascale values from molecule0 into clj_nb_pairs0.

# Work out the iteration length and range.
if roi is None:
iterlen = molecule0.num_atoms()
iterrange = list(range(molecule0.num_atoms()))
else:
for roi_res in roi:
# Get atom indices of ROI residue in molecule0.
molecule0_roi = molecule0.residues()[roi_res]
molecule0_roi_idx = [a.index() for a in molecule0_roi]
iterlen = len(molecule0_roi_idx)
iterrange = molecule0_roi_idx

# Perform a triangular loop over atoms from molecule0.
for x in range(0, iterlen):
# Convert to an AtomIdx.
idx = iterrange[x]
idx = _SireMol.AtomIdx(idx)

# Map the index to its position in the merged molecule.
idx_map = mol0_merged_mapping[idx]

for y in range(x + 1, iterlen):
idy = iterrange[y]
# Convert to an AtomIdx.
idy = _SireMol.AtomIdx(idy)

# Map the index to its position in the merged molecule.
idy_map = mol0_merged_mapping[idy]

# Get the connection type between the atoms.
conn_type = conn0.connection_type(idx_map, idy_map)

# The atoms aren't bonded.
if conn_type == 0:
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# The atoms are part of a dihedral.
elif conn_type == 4:
clj_scale_factor = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(),
ff.vdw14_scale_factor(),
)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# The atoms are bonded
else:
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
clj_nb_pairs0.set(idx_map, idy_map, clj_scale_factor)

# Finally, copy the intrascale from molecule1 into clj_nb_pairs1.

# Work out the iteration length and range.
if roi is None:
iterlen = molecule1.num_atoms()
iterrange = list(range(molecule1.num_atoms()))

else:
for roi_res in roi:
molecule1_roi = molecule1.residues()[roi_res]
molecule1_roi_idx = [a.index() for a in molecule1_roi]
iterlen = len(molecule1_roi_idx)
iterrange = molecule1_roi_idx

# Perform a triangular loop over atoms from molecule1.
for x in range(0, iterlen):
# Convert to an AtomIdx.
idx = iterrange[x]
idx = _SireMol.AtomIdx(idx)

# Map the index to its position in the merged molecule.
idx = mol1_merged_mapping[idx]

for y in range(x + 1, iterlen):
idy = iterrange[y]
# Convert to an AtomIdx.
idy = _SireMol.AtomIdx(idy)

# Map the index to its position in the merged molecule.
idy = mol1_merged_mapping[idy]

# Get the connection type between the atoms.
conn_type = conn1.connection_type(idx, idy)

if conn_type == 0:
clj_scale_factor = _SireMM.CLJScaleFactor(1, 1)
clj_nb_pairs1.set(idx, idy, clj_scale_factor)

# The atoms are part of a dihedral.
elif conn_type == 4:
clj_scale_factor = _SireMM.CLJScaleFactor(
ff.electrostatic14_scale_factor(),
ff.vdw14_scale_factor(),
)
clj_nb_pairs1.set(idx, idy, clj_scale_factor)

# The atoms are bonded
else:
clj_scale_factor = _SireMM.CLJScaleFactor(0, 0)
clj_nb_pairs1.set(idx, idy, clj_scale_factor)

# Store the two molecular components.
edit_mol.set_property("molecule0", molecule0)
edit_mol.set_property("molecule1", molecule1)
Expand Down
Loading