Commit Graph

5779 Commits

Author SHA1 Message Date
Ricardo Rodriguez
92d5d2c657 Refactor to stop using iterator definitions in types.h (#9275)
* clean up iterator defs in types.h

* do not use auto for inline constexpr

* restore undef max,min

* restore types.h declarations
2026-05-21 19:19:38 +02:00
Steven Kearnes
169a1b2b67 Build: tag dev-only install rules with COMPONENT dev (#9287)
Headers under Code/RDGeneral/hash and the generated cmake package config
files (rdkit-config*.cmake, rdkit-targets*.cmake, rdkitpython-config*.cmake,
rdkitpython-targets*.cmake) are currently installed without an explicit
COMPONENT, so they default to "Unspecified" and cannot be cleanly separated
from runtime artifacts by packagers that use cmake's per-component install
(e.g. -DCMAKE_INSTALL_COMPONENT=dev).

In conda-forge we split the package into librdkit (runtime) and librdkit-dev
(headers + cmake config), with librdkit installing components
"Unspecified base data runtime" and librdkit-dev installing the "dev"
component. With the current upstream tagging, the hash headers and all
cmake config files end up in librdkit instead of librdkit-dev, which both
ships build-time artifacts in a runtime package and leaves librdkit-dev
without the cmake config needed for find_package(RDKit) to work.

This commit tags all five affected install() calls with COMPONENT dev so
per-component installs work correctly. Default (non-component) installs
are unaffected.
2026-05-21 19:16:05 +02:00
Greg Landrum
1dfc9b7a1b Fixes #9231: improve escaping values in CXSMILES (#9273)
* this is a fix, but it breaks other tests

* all tests pass.

This undoes the changes made as part of the "fix" for #5466

* update js tests

* response to review

---------

Co-authored-by: = <=>
2026-05-17 11:51:14 -04:00
Ricardo Rodriguez
434714e7d4 Fixes #9270 (#9272)
* fix handling double bond stereo extraction

* add tests

* Update Code/GraphMol/Subset.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-05-16 07:01:25 +02:00
Steven Kearnes
d1b8874851 PgSQL: preserve toolchain LDFLAGS on macOS (#9285)
The previous `set(CMAKE_EXE_LINKER_FLAGS ...)` replaced the variable
wholesale, which clobbers any toolchain-supplied linker flags. In
particular, conda-forge's clang_osx-64 / clangxx_osx-64 packages set
`-stdlib=libc++ -L${PREFIX}/lib -Wl,-rpath,${PREFIX}/lib` via
`CMAKE_EXE_LINKER_FLAGS`. Losing those flags causes the postgres
extension link to pick up the wrong libc++ and fail to resolve
ABI-tagged symbols on libc++ 19+:

    [ 94%] Linking CXX executable rdkit.dylib
    Undefined symbols for architecture x86_64:
      "VTT for std::__1::basic_stringstream<...>"
      "vtable for std::__1::basic_stringbuf<...>"
      "vtable for std::__1::basic_stringstream<...>"
      "vtable for std::__1::basic_istringstream<...>"
    ld: symbol(s) not found for architecture x86_64

The missing symbols carry the `[abi:ne190107]` ABI tag introduced by
libc++ 19+ — references that only resolve against the conda-forge
libc++, not the system one the link was falling back to.

Append to `CMAKE_EXE_LINKER_FLAGS` instead so the toolchain flags
survive. The other rdkit `.dylib`s in the same build are linked via
the standard cmake toolchain path and were never affected.

Verified by building rdkit-postgresql on osx-64 + osx-arm64 via the
conda-forge feedstock (https://github.com/conda-forge/rdkit-feedstock)
with this fix applied as a downstream patch.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 07:00:01 +02:00
Gareth Jones
8e9adcd467 Adds some features to the C# SWIG wrappers (#9274) 2026-05-14 09:07:56 +02:00
github-actions[bot]
2f6bbe03b0 [bot] Update molecular templates header (#9269)
Co-authored-by: github-actions[bot] <github-actions[bot]@noreply.github.com>
2026-05-07 05:16:48 +02:00
reza bagheri alashti
bd73a574ad Docs: fix CosineSimilarity formula and clarify similarity metric names in BitOps.h (#9264)
* Fix CosineSimilarity doc formula and clarify similarity metric names in BitOps.h

* Fix CosineSimilarity formula in BitOps.h and adjust similarity docs
2026-05-06 17:12:53 +02:00
Dan Nealschneider
67fc0708e5 CIPLabeler performance: Store vector of bonds (#9250)
* CIPLabeler performance: Store vector of bonds

CIPLabelling refers to bonds by index over and over again. This
causes a measurable hit in performance in findConfigs() because
we iterate over a bitset of "allowed" bonds. For very large
molecules with many bonds, this can be a rate-limiting step!

This affects many PDB-sized structures.

2J3N goes from 0.7s to 0.25s with this change.

I had another example for which the findBondWithIdx() call was
taking 500ms of a 700ms call (after the performance update
in #9171 was implemented)

* yikes, XXL reserve

thanks, greg

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-05-06 11:57:28 +02:00
Dan Nealschneider
1663989053 CIP labeller performance: Don't calculate auxiliary descriptors unnecessarily (#9171)
* CIP labeller: Don't calculate auxiliary descriptors unnecessarily

The first 3 rules (the constitutional rules) are pretty easy
to understand. After rule 3, we need to calculate auxiliary
stereo descriptors to break ties.

However, we _were actually_ calculating auxiliary stereodescriptors
for all centers! We should only need to calculate auxiliary
stereocenters for sites that are needed to break ties.

This cost time - it also caused errors if the auxiliary descriptors
needed a graph expansion, because bonds in the digraph might be
pointed in the wrong direction.

Example case PDB ID 4AXM
Before this commit, errored with "Could not calculate parity! Carrier mismatch"
after 14s. After this commit, completes successfully in 0.036s.
Labelled centers all match (for the centers that had labels in
the failure case).

Includes a test that I can imagine breaking with this optimization.
The reference labels are from before this change

* Ensure all "arms" of stereo bonds and atropisomer bonds are expanded

For tetrahedral centers, ranking using the constitutional rules
always expands as far as is needed (but no further). For SP2bond
and atropisomers, if the first side is not resolvable, the
second side is never visited.

If the constitutional rules don't resolve a side, we need to
label the auxiliary centers. It's important to label all
auxiliary centers that _will_ be visited, so we need to know
what centers will be visited.

This commit updates the label() call in SP2 and Atropisomer
bonds to always attempt to label both sides if using the
constitutional rule set.

The constitutional rules are cheap, and if they fail, we
always go on to the full rule set. It is not a savings to skip
the search on the second side if we're going to keep going
anyway!

Includes a test that reproduces Ricardo's example.

This has no measurable effect on performance relative to the
original solution

* If any parts of the center have been seen, label it.

I couldn't make an example hit this, but Ric is totally
theoretically right

* Greg's ranges suggestion #2

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* any_of for container search

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-05-06 06:12:50 +02:00
Raul Sofia
372fbad131 Extended fix for #9101 (#9255)
* fix extended boundary issue (3 mols)

* clang pass

* no change. retrigger CI for failed java test

there's a failing java test that seems to be failing by chance rather than by changes, as it depends on rng. this is just to retrigger the CI pipeline to confirm this

* no change. retrigger the CI (yet again)

* raw strings and removed garbage collector
2026-05-06 06:10:37 +02:00
Emily Rhodes
3836049ab2 Add optional default_val parameter to GetProp() (#9242)
* SHARED-12256: Add test and change function.

* SHARED-12256: Update to only wrapping changes.

* SHARED-12256: Parameterize tests.

* SHARED-12256: GetPropIfPresent changes.

* Revert "SHARED-12256: GetPropIfPresent changes."

This reverts commit f598f8c161.

* SHARED-12256: Make default the keyword in the boost wrappings.

* SHARED-12256: Overload function instead of using a sentinel.

* SHARED-12256: Extend GetProp changes.

* SHARED-12256: Add entry point for tests and fix tests.
2026-05-06 06:09:11 +02:00
Greg Landrum
6d75052459 Support using iterators with MolSuppliers (#9230)
* iterators for random-access MolSuppliers
add optional caching to SDMolSupplier

* add support to SmilesMolSupplier too
There is a lot of duplicate code between the random-access suppliers that would be worth trying to remove
but at the moment it looks like it would require multiple inheritance, and I think we want to avoid that

* add input iterators for ForwardSDMolSupplier()

* throw when calling begin() on a used supplier

* switch to use the spaceship operator

* init() should reset the mol cache

* Make SDMolSupplier and SmilesMolSupplier safe for multi-threaded reads

* add benchmarking

* add TDTMolSupplier support
improved testing
add benchmarks for parallel iteration
optional TBB support

* better const handling, add reverse iterators

doesn't look like const_iterator is possible since getting data from the underlyng supplier object is non-const

* improve docs
more usings
add reverse iterator to TDTMolSupplier

* tests only try execution::par when it is there

* fix typo

* more testing/demo

* remove accidentally added files

* review changes

* add default ctors

* disable a false-positive compiler warning
it is stupid to have to do this

---------

Co-authored-by: = <=>
2026-05-05 13:36:15 +02:00
Kevin Boyd
232e4ffc84 Add Getter functions to MMFF property python interface (#9254) 2026-04-30 17:06:31 +02:00
Greg Landrum
251353a217 Ensure that StereoGroups don't have duplicate atoms or bonds (#9258)
* check for duplicate atoms/bonds in StereoGroups

* explicit handling of duplicate stereogroup atoms in CTAB and CXSMILES parsers

---------

Co-authored-by: = <=>
2026-04-29 16:54:00 +02:00
Eloy Félix
cb251343b9 Tautomer insensitive hash v2, E/Z and stereocenter-preservation (#9128)
* Tautomer insensitive hash v2, E/Z and stereocenter-preservation

* Preserve E/Z stereochemistry and stereocenters in TautomerHashv2

Simplify extension logic to better protect stereocenters connected via
single bonds to aromatic systems. Preserve E/Z stereo on exocyclic
double bonds to distinguish geometric isomers (e.g., E/Z hydrazones).

* add helper function to remove duplicated code

* Fix ring info and bond aromaticity handling in MolHash

- Add fastFindRings check in TautomerHashv2 before ring queries
- Set isAromatic consistent with bond type (true for AROMATIC bonds)
- Fix inverted condition in RegioisomerHash

* more consistent hashes regardless of stereo annotation
2026-04-24 14:19:47 +02:00
Nic Zonta
6cac6afcb3 If templates match, skip ring number check (#9217)
* remove ring mathcing for templates

* remove extra code

* remove empty lines

* fix build error
2026-04-23 19:21:29 +02:00
Kevin Boyd
bbee5fedb0 Fix bug in inversion term for UFF, add finite difference checker. (#9228)
* Fix copyright

* Address review comments

Removed finite diff from RDKit headers

Used explicit coordinates
2026-04-23 06:21:42 +02:00
Greg Landrum
e35f7db009 Cleanup/get atoms and bonds (#9243) 2026-04-18 05:22:09 +02:00
Ricardo Rodriguez
db025bd6b0 make sorting more consistent (#9239) 2026-04-16 05:05:14 +02:00
Brandon Novy
efa7a32c3c MolDraw2D: configurable legend position and vertical side legends (Issue #9023) (#9183)
* Configurable legend position (Top/Left/Right/Bottom) and vertical text (GitHub #9023)

- Add LegendPosition enum and legendPosition, legendVerticalText to MolDrawOptions
- Support legend at Top, Left, Right, Bottom; vertical text for Left/Right
- Python: MolDrawOptions.legendPosition, .legendVerticalText; LegendPosition enum
- Python: MolToSVG() wrapper with legend/drawOptions; doc updates for MolToImage
- JSON: legendPosition (string), legendVerticalText (bool) in draw options
- C++ and Python tests; release note and Cartridge.md docs

* MolDraw2D: legend gutter for horizontal side legends; vertical side height fit

- Reserve horizontal gap between molecule and left/right horizontal legends
  (scale mol to molWidth-gutter, align toward legend strip).
- Position horizontal side legend by measured text width from partition edge.
- Vertical side legends: iterative scale so n*max_h+(n-1)*gap fits panel.
- Catch: long vertical side legend section.

* Update legend-position tests and review-driven cleanup

Use enum/default wording for legendPosition docs, move the lightweight Python test to Wrap, add regex-based placement checks (including horizontal side and vertical stacking), and refactor extractLegend helpers per style guidance.

* Fix MolDraw2D legend edge cases

* MolDraw2D: review follow-up (legend tests, bounds, DRY Top/Bottom)

* Update no-FT legend test coords

* Address PR review: document constants, remove release-note text, and simplify extra-padding logic
2026-04-16 04:59:00 +02:00
Chris Von Bargen
d8f4afb558 Add getSGroupDataLabels() to MolDraw2D_detail namespace (#9189)
Adds a new function MolDraw2D_detail::getSGroupDataLabels() that returns
the text and molecule-coordinate positions of DAT SGroup labels, using
the same placement logic as the drawing code. This allows external
renderers to display SGroup labels consistently with RDKit's placement.

Refactors DrawMol::extractSGroupData() to call getSGroupDataLabels()
internally, eliminating the duplicate FIELDDISP parsing and position
computation logic.

Closes #7829

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 04:56:00 +02:00
Greg Landrum
2c6efb4a65 Add some std::ranges support (#9218)
* initial ranges support for Atom/Bond iterators.
needs more testing

* support random access
test sort

more testing please

* compiles on windows

* fix size()
more testing
add some benchmarking

* disable benchmarking code by default

* do not allow modifying the graph through the iterators

---------

Co-authored-by: = <=>
2026-04-13 17:13:04 +02:00
github-actions[bot]
f150381c13 [bot] Update molecular templates header (#9234)
Co-authored-by: github-actions[bot] <github-actions[bot]@noreply.github.com>
2026-04-10 15:02:46 +02:00
David Cosgrove
eaf546b037 Misplaced parentheses in shape code (#9222)
* Move stray bracket.

* Lots of consts.

* Another bad bracket.

* Response to review.
2026-04-07 16:59:56 +02:00
Ricardo Rodriguez
9e301c15d6 Normalize rings (#9208)
* normalize rings

* update tests

* update doctests

* update release notes
2026-04-01 05:37:02 +02:00
Yakov Pechersky
c6cabf4153 Speed-up tautomer canonicalization, no API changes (#9134)
* Speed up tautomer canonicalization by deferring on SSSR calc

* Lazy kekulization for tautomer enumeration

Defer kekulization of tautomers until they are actually needed for
transform matching. This avoids creating kekulized copies for:
1. The initial tautomer (until first iteration)
2. New tautomers that may never be processed (if enumeration ends early)

The Tautomer class now supports lazy initialization of the kekulized
form via getKekulized() method.

Performance improvement: ~7% additional speedup (total ~22-24% from baseline)

* Use count-only substructure matching in tautomer scoring

* Add SubstructMatchCount regression test

* MolStandardize: reduce enumerate overhead

* MolStandardize: avoid per-tautomer ring recomputation

* Atom: cache PeriodicTable pointer in valence calcs

* Atom: reuse PeriodicTable in getEffectiveAtomicNum

* PeriodicTable: add atomic fast path for getTable

* GraphMol: reduce ROMol copy reallocations

* MolStandardize: use quickCopy for per-match product copies

Use RWMol(*kmol, true) in tautomer enumeration to avoid copying properties/bookmarks/conformers for each candidate. This reduces deep-copy overhead without changing chemistry.

* MolStandardize: pre-filter scoring patterns by element/connectivity

For tautomer scoring, pre-compute which SubstructTerms are relevant for
a given input molecule. Since tautomerization only moves H atoms and
changes bond orders (never creates/destroys heavy-atom bonds), patterns
requiring missing elements or connectivity can be skipped for all
tautomers of that molecule.

Two-stage filtering:
1. Element check: skip patterns requiring atoms not in the molecule
2. Connectivity check: skip patterns whose bond-order-agnostic structure
   doesn't match the input molecule's connectivity

This reduces the number of VF2 substructure calls per tautomer from 12
to typically 3-5, depending on the molecule's composition.

* MolStandardize: preserve molecule properties for canonical tautomer

Copy molecule properties from the original input to the canonical tautomer
result. Since quickCopy during enumeration skips d_props to avoid overhead,
extended SMILES data like link nodes (LN) was lost. This restores them
on the final result.

* TautomerQuery: preserve molecule properties (e.g. link nodes) in tautomers

TautomerQuery::fromMol() uses TautomerEnumerator::enumerate() which uses
quickCopy for performance. This doesn't copy molecule properties like
_molLinkNodes. Without this fix, XQMol output would lose link node
extensions in the SMILES.

Copy properties from the original query molecule to all enumerated
tautomers before constructing the TautomerQuery. This preserves extended
SMILES data without impacting enumeration performance.

* MolStandardize: use parallel iteration and cache bond lookups

Replace O(n) getAtomWithIdx/getBondWithIdx calls with parallel iteration
over atom/bond ranges in canonicalizeInPlace and enumerate. Cache bond
lookups in setTautomerStereoAndIsoHs to avoid repeated O(n) searches.

* perf: add specialized matchers for simple tautomer scoring patterns

Replace VF2 graph matching with O(n) loops for 6 simple patterns:
- countDoubleOrAromaticBonds: C=O, N=O, P=O patterns
- countMethyls: [CX4H3] methyl groups
- countCarbonDoubleHetero: [C]=[/home/dcvuser/rdkit;Code/GraphMol/MolStandardize/Tautomer.h] aliphatic C=hetero
- countAromaticCarbonExocyclicN: [c]=aromatic C=exocyclic N
Complex patterns (benzoquinone, oxim, guanidine, aci-nitro) still use VF2.
Combined with the pre-filtering optimization, this achieves ~3.7x speedup
(~2500ms vs ~9300ms original) for tautomer canonicalization.

* Fix tautomer canonicalize dropping conformers from quickCopy

quickCopy (RWMol(*mol, true)) skips conformers, so tautomer
enumeration products lose 2D/3D coordinates. This causes InChI
generation to omit the /b (double bond E/Z stereo) layer, since
E/Z is derived from atomic coordinates.

Fix: copy conformers from the original molecule onto the canonical
tautomer after pickCanonical in TautomerEnumerator::canonicalize().

Tests: SMILES-based E/Z check in testTautomer.cpp, molblock-based
conformer preservation check in catch_tests.cpp.

* add test on canonicalize losing stereo

* add regression test for exocyclic C=C tautomer canonicalization

The getTautomerStateKey() pre-filter (commit 2595ef748) can falsely
deduplicate distinct tautomers when their atom-index-ordered state
patterns happen to match, leading canonicalize() to pick the wrong
canonical form for molecules with STEREOTRANS-pinned exocyclic C=C
bonds after RemoveHs.

Test verifies that O=C(CC1=CC2=CC=COC2)NC1=O canonicalizes to the
exocyclic form O=C1CC(=CC2=CC=COC2)C(=O)N1, not the endocyclic form
O=C1C=C(C=C2CC=COC2)C(=O)N1.

Currently expected to FAIL until the state key dedup bug is fixed.

* MolStandardize: expand tautomer connectivity SMARTS

* MolStandardize: scope tautomer pattern enum

* MolStandardize: trim tautomer pattern enum

* MolStandardize: use symmetric ring scoring
2026-03-31 06:42:40 +02:00
Ricardo Rodriguez
f3dd424d28 make ringdecomposerlib a mandatory dependency (#9209) 2026-03-27 18:17:27 +01:00
Nic Zonta
2096c7fe33 Enable templating for macrocycles (#9203)
* parse templates as smarts

* accept ring templates in SMARTS format

* undo CLAUDE mistake

* rename files

* enable templating for macrocycles

* enable macrocycle templating

* Add test for macrocycle templating

Tests that ring system templates are used only for macrocycles (rings
with size > 8). The test verifies the exact threshold by generating
coordinates with and without templates for rings of size 4-14.

Addresses review feedback on PR #9203.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-27 06:25:20 +01:00
github-actions[bot]
c9dfd5a40e [bot] Update molecular templates header (#9205)
Co-authored-by: github-actions[bot] <github-actions[bot]@noreply.github.com>
2026-03-27 06:21:02 +01:00
David Cosgrove
5235f53910 Gaussian shape overlays (#9095) 2026-03-26 21:53:54 +01:00
Paolo Tosco
adf060c881 - implement #9194 (#9197)
- remove redundant #include
- avoid unnecessary copy of match
- expose SubstructMatchParams to JS MinimalLib
- add JS SubstructMatchParams test

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2026-03-26 05:00:42 +01:00
Ricardo Rodriguez
d90a73aa6b Leak fixes for 2026.03.1 (#9198)
* fix mols leaked in tests

* own invariant generators

* clean up MorganFeatureAtomInvGenerator patterns

* address review suggestions
2026-03-25 05:56:26 +01:00
Greg Landrum
cacba34a47 simple substructure optimization (#9201)
Co-authored-by: = <=>
2026-03-24 15:38:13 +01:00
Greg Landrum
9d1b988799 Fixes #9143 (#9195)
* Fixes #9143
There is still some weirdness in the matching of ET bonds in macrocycles, but it is not connected to this change.

* adjust test to work on win (and mac?)

* tweak expected results for win ci
2026-03-24 10:03:02 +01:00
github-actions[bot]
fd2ea88fdb [bot] Update molecular templates header (#9193) 2026-03-21 09:09:40 +01:00
Andrew Dirksen
cbedbb7819 Hide data representation inside RDKit::Dict (#9113)
* Remove Dict::getData() for a strict abstraction boundary

Replace direct access to Dict's internal std::vector<Pair> with
encapsulated methods: size(), empty(), const iteration via
begin()/end(), appendPair(), markNonPOD(), and getRawVal().

This enables future changes to Dict's internal representation
without breaking callers.

Ref: rdkit/rdkit#9112

* Harden Dict::appendPair to take a populated Pair by move

appendPair(Pair&&) now auto-detects non-POD status via
RDValue::needsCleanup(), eliminating markNonPOD() and the
risk of dangling references or uninitialized entries.

needsCleanup() is placed next to destroy() on RDValue to
keep the POD/non-POD distinction in one place.

* Remove vestigial dictHasNonPOD param from streamReadProp

Both callers ignored the output. Non-POD detection is now handled
by Dict::appendPair via RDValue::needsCleanup().

* unbork java build

* Address PR review: bulk append, rename getRawVal, add custom data test

- Add Dict::append(vector<Pair>&&) for bulk insertion with reserve
- Use bulk append in streamReadProps to restore pre-allocation
- Rename getRawVal -> getRDValue per reviewer preference
- Add test verifying custom AnyTag data is destroyed through Dict lifecycle

* heed self-review

* don't manually implement vec.insert

* Add test: ExplicitBitVect round-trip through Dict serialization

Exercises the full streamWriteProps/streamReadProps path with an
ExplicitBitVect in an RDProps Dict, confirming the custom handler
is invoked and no memory is leaked (verified under valgrind).

* in anyTag test, assert destructors ran a specific number of times.

---------

Co-authored-by: bddap (Coding Agent) <andrew+bot@dirksen.com>
2026-03-20 06:58:36 +01:00
Katharina Buchthal
f7a3f044ff Adjust lower bounds to allow intramolecular H-Bonds (#9188)
* added test case

* implemented lower bounds of potential h-bonds

* suggested changes

---------

Co-authored-by: Katharina Buchthal <katharina.buchthal@phys.chem.ethz.ch>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2026-03-20 04:36:28 +01:00
Ricardo Rodriguez
680520e0ad Follow up to PR #8968 (#9168)
* implement consistency check

* add more consistency checks

* check direction consistency accross double bond

* clean up directions for non-stereo bonds

* fix counts for second from atom dirs; add check

* handle inconconsistent bond dirs

* add more tests, pubchem cases, and update existing

* drop statics

* fix typo

* make sourceBond arg const

* fix consistency check
2026-03-20 04:28:17 +01:00
Katharina Buchthal
c5de9f8843 Fix issue 9165 & 9166 (#9184)
* added *S-S* and bounds overwriting tests

* fixed *S-S*

* added bounds overwriting test

* searching for the bug

* added test case

* improved tests + fixed bug 9166

* updated ref mols

* regenerated refs

* clean up

* changed ref data

* removed print statements

* Update Code/GraphMol/DistGeomHelpers/BoundsMatrixBuilder.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* Typo

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* Incooperated suggestions

* applied remaining suggestions

* restored imports

---------

Co-authored-by: Katharina Buchthal <katharina.buchthal@phys.chem.ethz.ch>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-03-19 16:47:04 +01:00
David Cosgrove
88ff241407 Support double* in Transform3D::TransformPoint (#9176)
* Accept non-kekulisable molecules.

* Add Transform3D::TransformPoint(double *)

* Reformat.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2026-03-19 09:34:22 +01:00
Yakov Pechersky
0986d22c58 Deterministic kekulize, independent of atom and bond order (#9125)
* Make kekulization deterministic

* Add tautomer order-independence regression (python)

* Adjust tautomer tests for deterministic kekulization

* Update graphmol wedged-bond kekulization checks

* SmilesParse: update aromatic bond index expectations

* SmilesParse: refresh cxsmilesTest expected files

* Depictor: update testDepictor expected MolBlocks

* Depictor: update depictorCatch expectations

* Depictor Wrap: update expected MolBlock for pyDepictor

* MarvinParse: update testMrvToMol expected outputs

* FileParsers: refresh testAtropisomers expected outputs

* FileParsers: update tests for deterministic kekulization

* MolDraw2D: refresh brittle bond assertions

* RascalMCES: update expected cluster size

* MinimalLib: make cffi wedging check order-independent

* documentation fix

* MinimalLib: update Kekulé bond table in aligned-coords test

* Hoist duplicated lambdas to TEST_CASE scope

* Remove unused originalWedges variable

* Remove redundant bounds check; clarify wedge-end preference

* Pre-sort allAtms by wedge-end + rank

* Use mol.atomNeighbors() for neighbor iteration

* Check inAllAtms before linear-scanning done

* Drop redundant optsV/wedgedOptsV sorts

* Remove unused Canon.h include

* Add canonical parameter to Kekulize; skip ranking during sanitization

* Test canonical re-kekulization preserves stereo across atom orderings

* MinimalLib: update Kekulé bond orders in invertedWedges

* Change Kekulize canonical default to false, expose in Python wrappers

* keep rank order, push_back

* Revert "RascalMCES: update expected cluster size"

This reverts commit a81bb39495.

* docstring change

* expose new flag to python wrapper

* document changes in ReleaseNotes.md

* revert minimallib test changes again

* canonical = true defaults

* Revert "revert minimallib test changes again"

This reverts commit 039e1d84da.

* Reapply "RascalMCES: update expected cluster size"

This reverts commit 7b83a7a3e8.

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2026-03-19 08:43:13 +01:00
Nic Zonta
67b4555611 Switch to using SMARTS for 2D depiction templates (#9179)
* parse templates as smarts

* accept ring templates in SMARTS format

* undo CLAUDE mistake

* rename files
2026-03-19 06:54:23 +01:00
Greg Landrum
972b31e239 Add 'k' extension to SMARTS to support ringsize queries (#9172)
* switch the Query infrastructure to use std::function

* add releasenotes mention

* refactor makeAtomInRingOfSizeQuery() to use lambdas and support range queries

* add 'k' atom query to SMARTS

* changes in response to review
2026-03-17 15:02:59 +01:00
Yakov Pechersky
1a3cc2d5e8 fix: kekulization failure for V3000 molblocks with aromatic bonds and explicit H (#9141)
V3000 parsing sets aromatic flags on bonds but not atoms. When removeHs
strips an explicit H from nitrogen in an aromatic ring, molRemoveH
checked heavyAtom->getIsAromatic() to decide whether to increment
numExplicitHs — but that flag was always false for V3000-parsed atoms.

Without the explicit H count, the kekulizer cannot distinguish pyrrole N from pyridine N,
causing
"Can't kekulize mol" errors on valid ChemDraw-exported molblocks.

Fix: use isAromaticAtom(), which checks both atom and bond aromatic
flags
2026-03-14 06:50:01 +01:00
Greg Landrum
fa011fe425 switch the Query infrastructure to use std::function instead of function pointers (#9169)
* switch the Query infrastructure to use std::function

* add releasenotes mention

* response to review

Removed commented-out function pointer declarations for match and data functions.
2026-03-14 05:57:02 +01:00
Chris Von Bargen
c41f7e7167 Add RDLog::CaptureErrorLog for capturing error log messages (#9138)
* Add RDLog::CaptureLog for capturing log messages

Adds an RAII `CaptureLog` class to `namespace RDLog` (alongside the
existing `LogStateSetter`) that redirects an RDKit logger's output to an
internal `std::stringstream` for the duration of its lifetime. On
destruction the original stream destination and enabled state are fully
restored. Nesting is supported: an inner capture shadows the outer one
and each collects its own messages independently.

The default constructor captures `rdErrorLog`; an explicit constructor
accepts any `RDLogger`. Both enable the logger if it was previously
disabled and restore that state on destruction.

Python bindings expose `rdBase.CaptureLog` as a context manager with a
`messages` read-only property, mirroring the existing `rdBase.BlockLogs`
pattern. Messages remain accessible after the `with` block exits.

C++ tests are added to `catch_logs.cpp` (6 Catch2 sections covering
basic capture, empty state, enable/restore, stream restore, explicit
logger, and nested captures). Python tests are added to
`UnitTestLogging.py` (6 unittest cases covering the same scenarios).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* CaptureLog: add per-level properties (error_messages, warning_messages, etc.)

The Python CaptureLog wrapper now captures all four log levels
simultaneously. Per-level properties (error_messages, warning_messages,
info_messages, debug_messages) give access to messages from each logger
independently; the existing messages property returns them all combined.

The C++ RDLog::CaptureLog class is unchanged — it remains a clean
single-logger RAII type. The Python wrapper composes four instances of
it, one per log level.

Suggested by bp-kelley in PR review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Refactor CaptureLog: add named per-level subclasses

Add CaptureErrorLog, CaptureWarningLog, CaptureInfoLog, and CaptureDebugLog
as named convenience subclasses of CaptureLog, each capturing a specific
logger. Update Python bindings to expose the four named classes directly
(dropping the combined multi-capture approach), and update tests accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Simplify CaptureLog: no argument, captures rdErrorLog only

Remove the RDLogger argument overload, the four named subclasses, and the
PyCaptureLog template in favor of a single no-argument CaptureLog that
mirrors the Schrödinger CaptureRDErrorLog from which it was inspired.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* CaptureLog tests: add dp_dest restoration and LogStateSetter interaction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Rename CaptureLog to CaptureErrorLog

The name CaptureLog was ambiguous; CaptureErrorLog is explicit about which
logger it captures and avoids redundancy within namespace RDLog.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Generalize CaptureErrorLog into CaptureLog with logger parameter

Replace CaptureErrorLog with CaptureLog, which accepts any RDLogger in
its constructor (e.g. rdErrorLog, rdWarningLog). Add CaptureErrorLog as
a convenience subclass that pre-fills rdErrorLog, preserving backward
compatibility for existing callers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 06:09:43 +01:00
Ricardo Rodriguez
5f85fafb75 Fixes #9153 (#9154)
* add tests

* fix issue

* make test pass under both legacy and modern stereo

* remove the tests
2026-03-12 18:29:59 +01:00
Brian Kelley
ecdf55ac2a Fixes a boundary issue when indexing SDF (#9162)
* Fixes an index boundary error in SDMolSupplier

* Add test data

* Run clang-format

* Update Code/GraphMol/FileParsers/testMolSupplier.cpp

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>

* Update Code/GraphMol/Wrap/rough_test.py

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2026-03-12 13:58:33 +01:00
Chris Von Bargen
e8f2b98f4c Fix link failure on macOS caused by AGL framework injection in Qt (#9139)
* Fix Qt 6.5.8 link failure on macOS due to removed AGL framework

Qt 6.5.8 injects the AGL (Apple Graphics Layer) framework into the
WrapOpenGL::WrapOpenGL imported target's INTERFACE_LINK_LIBRARIES. AGL
was removed from macOS 14+ SDKs, causing a link error when building
MolDraw2DQt on modern macOS:

  ld: framework not found AGL

This workaround filters AGL out of WrapOpenGL::WrapOpenGL's link
libraries after find_package(Qt6) populates them. The guard conditions
(APPLE and TARGET WrapOpenGL::WrapOpenGL) make it a no-op on other
platforms and Qt versions that do not create that target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Broaden AGL workaround comment to not pin Qt 6.5.8 specifically

The issue may affect other Qt versions, not just 6.5.8.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 06:12:29 +01:00