Skip to content

Commit

Permalink
Merge pull request OpenBioSim#235 from OpenBioSim/feature_atomcoordma…
Browse files Browse the repository at this point in the history
…tcher

Update makeCompatibleWith to use the new AtomCoordMatcher
  • Loading branch information
lohedges authored Jan 26, 2024
2 parents 15e37d9 + 90b6e9d commit dff31eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
13 changes: 3 additions & 10 deletions python/BioSimSpace/Sandpit/Exscientia/_SireWrappers/_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,8 @@ def makeCompatibleWith(

# Have we matched all of the atoms?
if len(matches) < num_atoms0:
# Atom names might have changed. Try to match by residue index
# and coordinates.
matcher = _SireMol.ResIdxAtomCoordMatcher()
# Atom names or order might have changed. Try to match by coordinates.
matcher = _SireMol.AtomCoordMatcher()
matches = matcher.match(mol0, mol1)

# We need to rename the atoms.
Expand Down Expand Up @@ -989,9 +988,6 @@ def makeCompatibleWith(
# Tally counter for the total number of matches.
num_matches = 0

# Initialise the offset.
offset = 0

# Get the molecule numbers in the system.
mol_nums = mol1.molNums()

Expand All @@ -1001,16 +997,13 @@ def makeCompatibleWith(
mol = mol1[num]

# Initialise the matcher.
matcher = _SireMol.ResIdxAtomCoordMatcher(_SireMol.ResIdx(offset))
matcher = _SireMol.AtomCoordMatcher()

# Get the matches for this molecule and append to the list.
match = matcher.match(mol0, mol)
matches.append(match)
num_matches += len(match)

# Increment the offset.
offset += mol.nResidues()

# Have we matched all of the atoms?
if num_matches < num_atoms0:
raise _IncompatibleError("Failed to match all atoms!")
Expand Down
13 changes: 3 additions & 10 deletions python/BioSimSpace/_SireWrappers/_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,8 @@ def makeCompatibleWith(

# Have we matched all of the atoms?
if len(matches) < num_atoms0:
# Atom names might have changed. Try to match by residue index
# and coordinates.
matcher = _SireMol.ResIdxAtomCoordMatcher()
# Atom names or order might have changed. Try to match by coordinates.
matcher = _SireMol.AtomCoordMatcher()
matches = matcher.match(mol0, mol1)

# We need to rename the atoms.
Expand Down Expand Up @@ -945,9 +944,6 @@ def makeCompatibleWith(
# Tally counter for the total number of matches.
num_matches = 0

# Initialise the offset.
offset = 0

# Get the molecule numbers in the system.
mol_nums = mol1.molNums()

Expand All @@ -957,16 +953,13 @@ def makeCompatibleWith(
mol = mol1[num]

# Initialise the matcher.
matcher = _SireMol.ResIdxAtomCoordMatcher(_SireMol.ResIdx(offset))
matcher = _SireMol.AtomCoordMatcher()

# Get the matches for this molecule and append to the list.
match = matcher.match(mol0, mol)
matches.append(match)
num_matches += len(match)

# Increment the offset.
offset += mol.nResidues()

# Have we matched all of the atoms?
if num_matches < num_atoms0:
raise _IncompatibleError("Failed to match all atoms!")
Expand Down

0 comments on commit dff31eb

Please sign in to comment.