Skip to content

Commit 7ad2ca2

Browse files
authored
Merge pull request #334 from OpenBioSim/backport_333
Backport fix from PR #333 into main
2 parents 39a880a + 8773874 commit 7ad2ca2

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

python/BioSimSpace/Align/_align.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,17 +1547,11 @@ def _rmsdAlign(molecule0, molecule1, mapping=None, property_map0={}, property_ma
15471547
mol0 = molecule0._getSireObject()
15481548
mol1 = molecule1._getSireObject()
15491549

1550-
# Do we have a monatomic ion?
1551-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
1552-
is_ion = True
1553-
else:
1554-
is_ion = False
1555-
15561550
# Convert the mapping to AtomIdx key:value pairs.
15571551
sire_mapping = _to_sire_mapping(mapping)
15581552

15591553
# Perform the alignment, mol0 to mol1.
1560-
if len(mapping) == 1 and is_ion:
1554+
if len(mapping) == 1:
15611555
idx0 = list(mapping.keys())[0]
15621556
idx1 = list(mapping.values())[0]
15631557
# Replace the coordinates of the mapped atom with those of the reference.
@@ -2534,12 +2528,6 @@ def _score_rdkit_mappings(
25342528
.commit()
25352529
)
25362530

2537-
# Do we have a monatomic ion?
2538-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
2539-
is_ion = True
2540-
else:
2541-
is_ion = False
2542-
25432531
# Get the set of matching substructures in each molecule. For some reason
25442532
# setting uniquify to True removes valid matches, in some cases even the
25452533
# best match! As such, we set uniquify to False and account for duplicate
@@ -2608,7 +2596,7 @@ def _score_rdkit_mappings(
26082596
if is_valid:
26092597
# If there is only a single atom in the mapping and one molecule
26102598
# has one atom, e.g. an ion, then skip the alignment.
2611-
if len(mapping) == 1 and is_ion:
2599+
if len(mapping) == 1:
26122600
mappings.append(mapping)
26132601
scores.append(0.0)
26142602
else:
@@ -2770,12 +2758,6 @@ def _score_sire_mappings(
27702758
.commit()
27712759
)
27722760

2773-
# Do we have a monatomic ion?
2774-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
2775-
is_ion = True
2776-
else:
2777-
is_ion = False
2778-
27792761
# Initialise a list to hold the mappings.
27802762
mappings = []
27812763

@@ -2797,7 +2779,7 @@ def _score_sire_mappings(
27972779
if is_valid:
27982780
# If there is only a single atom in the mapping and one molecule
27992781
# has one atom, e.g. an ion, then skip the alignment.
2800-
if len(mapping) == 1 and is_ion:
2782+
if len(mapping) == 1:
28012783
mappings.append(mapping)
28022784
scores.append(0.0)
28032785
else:

python/BioSimSpace/Sandpit/Exscientia/Align/_align.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,8 @@ def rmsdAlign(molecule0, molecule1, mapping=None, property_map0={}, property_map
11511151
# Convert the mapping to AtomIdx key:value pairs.
11521152
sire_mapping = _to_sire_mapping(mapping)
11531153

1154-
# Do we have a monatomic ion?
1155-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
1156-
is_ion = True
1157-
else:
1158-
is_ion = False
1159-
11601154
# Perform the alignment, mol0 to mol1.
1161-
if len(mapping) == 1 and is_ion:
1155+
if len(mapping) == 1:
11621156
idx0 = list(mapping.keys())[0]
11631157
idx1 = list(mapping.values())[0]
11641158
# Replace the coordinates of the mapped atom with those of the reference.
@@ -1785,12 +1779,6 @@ def _score_rdkit_mappings(
17851779
.commit()
17861780
)
17871781

1788-
# Do we have a monatomic ion?
1789-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
1790-
is_ion = True
1791-
else:
1792-
is_ion = False
1793-
17941782
# Get the set of matching substructures in each molecule. For some reason
17951783
# setting uniquify to True removes valid matches, in some cases even the
17961784
# best match! As such, we set uniquify to False and account for duplicate
@@ -1859,7 +1847,7 @@ def _score_rdkit_mappings(
18591847
if is_valid:
18601848
# If there is only a single atom in the mapping and one molecule
18611849
# has one atom, e.g. an ion, then skip the alignment.
1862-
if len(mapping) == 1 and is_ion:
1850+
if len(mapping) == 1:
18631851
mappings.append(mapping)
18641852
scores.append(0.0)
18651853
else:
@@ -2021,12 +2009,6 @@ def _score_sire_mappings(
20212009
.commit()
20222010
)
20232011

2024-
# Do we have a monatomic ion?
2025-
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
2026-
is_ion = True
2027-
else:
2028-
is_ion = False
2029-
20302012
# Initialise a list to hold the mappings.
20312013
mappings = []
20322014

@@ -2048,7 +2030,7 @@ def _score_sire_mappings(
20482030
if is_valid:
20492031
# If there is only a single atom in the mapping and one molecule
20502032
# has one atom, e.g. an ion, then skip the alignment.
2051-
if len(mapping) == 1 and is_ion:
2033+
if len(mapping) == 1:
20522034
mappings.append(mapping)
20532035
scores.append(0.0)
20542036
else:

0 commit comments

Comments
 (0)