Skip to content

Behavior change in substruct match between 2024.9.6 and 2025.3.1 #8592

@dwhswenson

Description

@dwhswenson

Describe the bug
A change has occurred in substructure matching between version 2024.9.6 and 2025.3.1. The release notes mention a change that "AdjustQueryProperties now no longer ignores additional atom adjustments when makeAtomsGeneric is enabled", but I wouldn't have expected that to break this workflow:

To Reproduce

# mcve.py
# Usage: python mcve.py TEMPLATE.sdf MOLECULE.pdb
import sys
from rdkit import __version__ as v
from rdkit import Chem

print(f"rdkit {v}")

template_filename, molecule_filename = sys.argv[1:]

template = Chem.MolFromMolFile(template_filename, sanitize=True, removeHs=True)
params = Chem.AdjustQueryParameters()
params.makeAtomsGeneric = True
params.makeBondsGeneric = True
template = Chem.AdjustQueryProperties(template, params)

molecule = Chem.MolFromPDBFile(molecule_filename, removeHs=False)

assert molecule.HasSubstructMatch(template), \
        f"I thought this would work for {template_filename}"
print(f"It did work for {template_filename}")

Use pairs (hem.sdf / HEM.pdb) and (adamantine.sdf / ADM.pdb) as examples.

HEM.pdb.txt
ADM.pdb.txt
hem.sdf.txt
adamantane.sdf.txt

$ python mcve.py adamantane.sdf ADM.pdb
rdkit 2025.03.1
Traceback (most recent call last):
  File "/Users/dwhs/tmp/rdkit-pdbeccdutils-2025/mcve.py", line 19, in <module>
    assert molecule.HasSubstructMatch(template), \
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
AssertionError: I thought this would work for adamantane.sdf
$ pixi shell -e passing
$ python mcve.py adamantane.sdf ADM.pdb
rdkit 2024.09.6
It did work for adamantane.sdf
$ exit
$ python mcve.py hem.sdf HEM.pdb
rdkit 2025.03.1
Traceback (most recent call last):
  File "/Users/dwhs/tmp/rdkit-pdbeccdutils-2025/mcve.py", line 19, in <module>
    assert molecule.HasSubstructMatch(template), \
           ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
AssertionError: I thought this would work for hem.sdf
$ pixi shell -e passing
$ python mcve.py hem.sdf HEM.pdb
rdkit 2024.09.6
It did work for hem.sdf

Expected behavior
I expected these patterns to match, as they did in earlier RDKit versions.

Screenshots
Pairs of template, molecule for context:

Image

Image

Configuration (please complete the following information):

  • RDKit version: 2024.9.6 / 2025.3.1 (behavior continues in later releases)
  • OS: macOS 15.2
  • Python version (if relevant): 3.13.5
  • Are you using conda? yes (via pixi)
  • If you are using conda, which channel did you install the rdkit from? conda-forge
  • If you are not using conda: how did you install the RDKit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions