Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #332 #333

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 3 additions & 21 deletions python/BioSimSpace/Align/_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,17 +1547,11 @@ def _rmsdAlign(molecule0, molecule1, mapping=None, property_map0={}, property_ma
mol0 = molecule0._getSireObject()
mol1 = molecule1._getSireObject()

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Convert the mapping to AtomIdx key:value pairs.
sire_mapping = _to_sire_mapping(mapping)

# Perform the alignment, mol0 to mol1.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
idx0 = list(mapping.keys())[0]
idx1 = list(mapping.values())[0]
# Replace the coordinates of the mapped atom with those of the reference.
Expand Down Expand Up @@ -2534,12 +2528,6 @@ def _score_rdkit_mappings(
.commit()
)

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Get the set of matching substructures in each molecule. For some reason
# setting uniquify to True removes valid matches, in some cases even the
# best match! As such, we set uniquify to False and account for duplicate
Expand Down Expand Up @@ -2608,7 +2596,7 @@ def _score_rdkit_mappings(
if is_valid:
# If there is only a single atom in the mapping and one molecule
# has one atom, e.g. an ion, then skip the alignment.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
mappings.append(mapping)
scores.append(0.0)
else:
Expand Down Expand Up @@ -2770,12 +2758,6 @@ def _score_sire_mappings(
.commit()
)

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Initialise a list to hold the mappings.
mappings = []

Expand All @@ -2797,7 +2779,7 @@ def _score_sire_mappings(
if is_valid:
# If there is only a single atom in the mapping and one molecule
# has one atom, e.g. an ion, then skip the alignment.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
mappings.append(mapping)
scores.append(0.0)
else:
Expand Down
24 changes: 3 additions & 21 deletions python/BioSimSpace/Sandpit/Exscientia/Align/_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -1151,14 +1151,8 @@ def rmsdAlign(molecule0, molecule1, mapping=None, property_map0={}, property_map
# Convert the mapping to AtomIdx key:value pairs.
sire_mapping = _to_sire_mapping(mapping)

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Perform the alignment, mol0 to mol1.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
idx0 = list(mapping.keys())[0]
idx1 = list(mapping.values())[0]
# Replace the coordinates of the mapped atom with those of the reference.
Expand Down Expand Up @@ -1785,12 +1779,6 @@ def _score_rdkit_mappings(
.commit()
)

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Get the set of matching substructures in each molecule. For some reason
# setting uniquify to True removes valid matches, in some cases even the
# best match! As such, we set uniquify to False and account for duplicate
Expand Down Expand Up @@ -1859,7 +1847,7 @@ def _score_rdkit_mappings(
if is_valid:
# If there is only a single atom in the mapping and one molecule
# has one atom, e.g. an ion, then skip the alignment.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
mappings.append(mapping)
scores.append(0.0)
else:
Expand Down Expand Up @@ -2021,12 +2009,6 @@ def _score_sire_mappings(
.commit()
)

# Do we have a monatomic ion?
if (molecule0.nAtoms() == 1) or (molecule1.nAtoms() == 1):
is_ion = True
else:
is_ion = False

# Initialise a list to hold the mappings.
mappings = []

Expand All @@ -2048,7 +2030,7 @@ def _score_sire_mappings(
if is_valid:
# If there is only a single atom in the mapping and one molecule
# has one atom, e.g. an ion, then skip the alignment.
if len(mapping) == 1 and is_ion:
if len(mapping) == 1:
mappings.append(mapping)
scores.append(0.0)
else:
Expand Down
Loading