Commit Graph

363 Commits

Author SHA1 Message Date
Rody Arantes
5d9892575c Fix STEREOANY (wavy bond) loss during InChI roundtrip (#9315)
When converting molecules with wavy bonds (Bond::STEREOANY on double
bonds) through InChI and back, the stereo information was silently
dropped. This affected any workflow using InChI roundtrips for
canonicalization (e.g. with -SUU flag).

Two bugs in External/INCHI-API/inchi.cpp:

Reverse path (InchiToMol): The stereo0D processing loop skipped
INCHI_PARITY_UNDEFINED entries before they could reach the double bond
handler. The handler already had an else clause that correctly sets
Bond::STEREOANY, but it was never reached. Fix: only skip
INCHI_PARITY_NONE at the top level, and add a guard in the Tetrahedral
case to prevent UNDEFINED/UNKNOWN from incorrectly setting chirality.

Forward path (MolToInchi): STEREOANY double bonds were only handled by
collapsing the coordinates — InChI then produced no stereo annotation
under -SUU. Fix: also emit a stereo0D entry with INCHI_PARITY_UNKNOWN
parity so InChI's -SUU output correctly carries the "stereo unknown"
designation. StereoAtoms may be cleared for STEREOANY, so we locate
the two outer neighbors by iterating bonds.

New test testStereoAnyRoundtrip in External/INCHI-API/test.cpp covers
9 representative cases (Schiff base, oxime, cinnamic acid, chalcone,
crotonaldehyde, tamoxifen-like, retinal-like, plus two molecules with
a chiral center adjacent to the wavy bond).

Counts in rdkit/Chem/UnitTestInchi.py shift by 1 (689 same, 492
reasonable) because the new STEREOANY emission produces a more
accurate roundtrip for one entry in the test inventory.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-02 14:41:00 +02:00
Greg Landrum
e35f7db009 Cleanup/get atoms and bonds (#9243) 2026-04-18 05:22:09 +02:00
Yakov Pechersky
87a6c7163d Use index-order kekulization in MolToInchi (#9226)
MolToInchi has called MolOps::Kekulize(*m, false) for years, but PR #9125 changed the default traversal to canonical=true. That pulls rankFragmentAtoms() and the canonicalization path into the InChI conversion even though the tested InChI outputs stay the same.

Validation:
- rdkit.Chem.UnitTestInchi passed before and after this change on upstream/master (18 tests, OK in both runs).
- No InChI output drift was observed between stock and patched builds on Regress/Data/mols.1000.sdf.gz, rdkit/Chem/test_data/pubchem-hard-set.sdf.gz, or the atom-order regression molecules added in Code/GraphMol/catch_graphmol.cpp.

Performance:
- Release_2026_03_1 Python MolToInchi on Regress/Data/mols.1000.sdf.gz improved from 0.40712s to 0.38871s median (-4.52%).
- Release_2026_03_1 rdinchi MolToInchi on the same dataset improved from 0.39755s to 0.37814s median (-4.88%).
- Release_2026_03_1 standalone C++ MolToInchi on /tmp/mols.1000.sdf improved from 7.66775s to 7.03474s wall time (-8.26%), from 20.57B to 19.04B cycles (-7.46%), and from 121.78M to 114.05M cache misses (-6.35%).
2026-04-07 06:17:40 +02:00
Ricardo Rodriguez
f3dd424d28 make ringdecomposerlib a mandatory dependency (#9209) 2026-03-27 18:17:27 +01:00
Rody Arantes
6f58d21f29 Add MolFromInchiAndAuxInfo to restore original atom order from AuxInfo (#9158)
* Add MolFromInchiAndAuxInfo to restore original atom order from AuxInfo

Add a new function that reconstructs molecules from InChI + AuxInfo strings,
restoring the original atom ordering and 2D/3D coordinates from the /N: and
/rC: AuxInfo layers. Includes comprehensive tests for round-tripping, stereo
preservation, coordinate restoration, edge cases, and multi-fragment molecules.

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

* Update rdkit/Chem/UnitTestInchi.py

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-03-13 06:10:56 +01:00
Brian Kelley
22be7245df Add suppresions for AppleClang and ChemDraw (#9147) 2026-03-04 08:27:30 +01:00
Brian Kelley
2a79115e9c Use CXX flags not C flags in ChemDraw cmake config (#9108)
* Use CXX flags not C flags

* Explicitly turn off -Werror and see if that works

* Back out removing -Werror, remove unused clang -Wno-X flags
2026-02-13 06:08:13 +01:00
Brian Kelley
1daf819ec9 Fixes #9077 (#9091) 2026-02-10 17:18:47 +01:00
Eisuke Kawashima
e89c9f656a style: apply readability-braces-around-statements (#8136)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2026-02-09 12:10:50 +01:00
David Cosgrove
21b3c4e6f1 Shape overlay initial start aligned to principal axes (#8999)
* Add MolTransforms library.

* Transform to inertial frame of reference before overlay.

* Vital fix of typo in comment.

* Tidy up debugging cruft.

* Comment in CMakeLists.txt.

* Fix python wrappers.

* Extra tidy.

* Response to review.

* Tidy includes.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-12-20 08:35:28 +01:00
David Cosgrove
2c3010d5ce Add function to compute shape scores without overlay. (#8950)
* Add function to compute shape scores without overlay.

* Update docstrings.

* Rename function to ScoreMolecule/ScoreMol.
Add extra functions analogous to the overlay ones.

* Windows export crap.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-11-19 17:02:38 +01:00
Greg Landrum
1bd29449dc remove rapidjson patch file (#8953) 2025-11-18 17:02:53 +01:00
Greg Landrum
323f7970e6 yaehmop version bump (#8952) 2025-11-18 17:02:04 +01:00
Max Rietmann
3802eaaac9 Fix potential iterator invalidation (#8944)
The iterator in the loop over bonds (changed in utils.cpp) is potentially
invalidated by adding bonds to the molecule. We copy the bonds into a vector to
ensure safety.
2025-11-11 17:03:05 +01:00
Ricardo Rodriguez
350c22f7dd Install expat lib in static builds (#8832)
* install expat in static builds

* specify destination

* also fix a windows build issue
2025-10-09 05:25:11 +02:00
Niels Maeder
db93262a3e Add safeSetattr to more params / options objects (#8842)
* add safeSetattr to varios params objects

* added safeSetattr to further params / options
2025-10-08 16:15:20 +02:00
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +02:00
Ricardo Rodriguez
a4b63d7df5 Minor refactor of the python wrappers (#8847)
* refactor python wrappers

* fix FilterHierarchyMatcher converted already registered warning
2025-10-05 09:42:31 +02:00
Greg Landrum
6b30df1e40 run clang-tidy and clang-format on the chemdraw files (#8837)
* git tidy

* clang-format
2025-10-03 11:21:56 -04:00
Ricardo Rodriguez
158db5d1a7 link expat to ChemDraw_static (#8839) 2025-10-03 17:12:49 +02:00
Ricardo Rodriguez
fbf4990709 Fixes a leak in ChemDraw code (#8828)
* clang format

* refactor code

* fix typos

* do not leak bonds when deleting in batch mode

* check sizes
2025-10-02 06:04:24 +02:00
Paolo Tosco
053a0283f7 Patch RapidJSON to make sure it builds on all platforms (#8818)
* patch RapidJSON to make sure it builds on all platforms

* remove unnecessary sed command from Docker recipe

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-09-26 05:28:46 +02:00
Brian Kelley
7e9293ed25 Fix an out of bounds access when replacing fragments (#8767)
* Fix an out of bounds access when replacing fragments

* Add segfaulting US patent CDXs

* Return false when we can't find the bond idx for better handling

* Remove useless REQUIRE

* Only sniff when in format AUTO

* Add test for reading wrong format

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
2025-09-25 15:53:50 +02:00
Greg Landrum
a5bcf726e1 allow custom shape points (#8799)
* support providing custom features

* expose that to python

* switch to tuples (on get) and objects (on set) for attributes

* allow aligning mols directly with ShapeInputOptions

* changes for review

* add warning
2025-09-23 18:56:03 +02:00
Chris Von Bargen
8b8d6a3fe2 RDKit's InChi build tries to guess whether the C compiler provides (#8764)
isascii() (which is the standard) or __isascii(), but it guesses wrong for
Emscripten builds (which I do during sketcher compilation). This change
passes -D__isascii=isascii when building InChi,
which means that the wrong guess will still wind up with the right
function name.
2025-09-12 17:15:19 +02:00
Brian Kelley
cf269aa813 Expose CDX support to FileParsers and ChemDraw to SWIG (#8681)
* Fist pass at CDX support

* Enable CDX support for reading (also) in the CDXMLParser API

* Add cdxml test files

* Update swig wrappers for CDXMLFormat and Parameters

* Add constructor to ChemDrawParserParams

* Add Java SWIG support for ChemDraw

* Add chemdraw define to rdconfig

* Add missing chemdraw deps

* Remove direct expat link

* Fix Java linkages for ChemDraw

* Remove bad merge code

* Remove bad merge code

* Fix csharp builds

* Add sniffer for the ChemDraw DataStream

* Include filesystem

* Fix test on windows

* Add more CDX tests

* Ensure streams are open in binary mode to support CDX on windows

* Fix text to show that a Block is the text input, not a file

* Fix CSharp test

* Disable CDX tests when not building chemdraw

* Turn back on chemdraw

* Response to review

* Turn off chemdraw support for the limited external test

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
2025-08-29 04:39:22 +02:00
Greg Landrum
dbd972497f patch the pubchem alignment code (#8733)
Co-authored-by: = <=>
2025-08-28 09:18:03 +02:00
Greg Landrum
81226d84ad Fixes a bug with bad H positions in output conformer (#8731)
* Fixes a bug with bad H positions in output conformer

This would only trigger when the number of H atoms is equal
to the number of features, but it was terrible when it happened.

* spell that better

* docs

---------

Co-authored-by: = <=>
2025-08-27 13:28:50 +02:00
Pat Riley
4cc9d6f2e6 Update documentation for rdShapeAlign.AlignMol opt_param (#8724)
* Update documentation for opt_param

* Revert default to 1.0

* revert all 0.5 default changes
2025-08-25 16:56:59 +02:00
badisa
53a01430e0 Fix documentation errors for rdShapeAlign (#8685) 2025-08-10 07:51:09 +02:00
Brian Kelley
58c21baeba ChemDraw Document and read/write support for the RDKit (#8620)
* ChemDraw Document and read/write support for the RDKit

* Add missing test file

* Rev chemdraw version

* Rev chemdraw version

* Rev chemdraw version for g++11

* Update CMakeLists.txt

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

* Build chemdraw from an external CMake file

* Remove unused platform bigendian check

* Revert changes to constants, remove unused ones

* Keep the original constant names

* Remove __main__ section

* Use as much of the ChemDraw CMakeList as possible

* Skip installing expat

* Rev chemdraw version to fix windows issue

* Don't install expat, set the appropriate CHEMDRAW_BUILD definition

* resolve windows builds

* Fix minimal lib builds

* Move ChemDraw document to private header

* Move utility functions to ChemDraw namespace

* Move ChemDraw to v2 unique ptr api namespace

* Make class enum

* Switch to camelCase

* Response to review

* Move ChemDrawToDocument to ChemDraw namespace

* Update External/ChemDraw/Wrap/rdChemDraw.cpp

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

* Fix typo

* Update External/ChemDraw/Wrap/rdChemDraw.cpp

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

* Add better documentation

* Rev chemdraw version

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-07-04 06:36:10 +02:00
Greg Landrum
969b1aadee Revert "ChemDraw Document and read/write support for the RDKit (#8539)" (#8618)
This reverts commit f8fde2f7d8.
2025-07-03 07:57:20 +02:00
Brian Kelley
f8fde2f7d8 ChemDraw Document and read/write support for the RDKit (#8539)
* ChemDraw Document and read/write support for the RDKit

* Add missing test file

* Rev chemdraw version

* Rev chemdraw version

* Rev chemdraw version for g++11

* Update CMakeLists.txt

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

* Build chemdraw from an external CMake file

* Remove unused platform bigendian check

* Revert changes to constants, remove unused ones

* Keep the original constant names

* Remove __main__ section

* Use as much of the ChemDraw CMakeList as possible

* Skip installing expat

* Rev chemdraw version to fix windows issue

* Don't install expat, set the appropriate CHEMDRAW_BUILD definition

* resolve windows builds

* Fix minimal lib builds

* Move ChemDraw document to private header

* Move utility functions to ChemDraw namespace

* Move ChemDraw to v2 unique ptr api namespace

* Make class enum

* Switch to camelCase

* Response to review

* Move ChemDrawToDocument to ChemDraw namespace

* Update External/ChemDraw/Wrap/rdChemDraw.cpp

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

* Fix typo

* Update External/ChemDraw/Wrap/rdChemDraw.cpp

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

* Add better documentation

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-07-03 06:01:58 +02:00
Ricardo Rodriguez
0ce4600f59 bump maeparser to 1.3.3 (#8580) 2025-06-12 05:02:36 +02:00
Kevin Keating
2a6307b0aa rdkit-targets.cmake now uses cmake package names for external libraries instead of absolute paths (#8552) 2025-05-24 07:27:03 +02:00
Paolo Tosco
73a7378ddb Avoid a large number of warnings when building MinimalLib with emscripten (#8545)
* - avoid a large number of warnings when building MinimalLib with emscripten, which does not support SHARED
- fix indentation in CoordGen CMakeLists.txt

* disable RDK_USE_BOOST_STACKTRACE on emscripten platform

* revert change done by mistake

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-05-22 05:08:01 +02:00
Greg Landrum
7467fe005f Fixes #8508 (#8514)
* Fixes #8508

* suggestion from review

* Update inchi.cpp
2025-05-11 05:10:18 +02:00
Yakov Pechersky
1356292c08 Set default Eigen3 version to 3.4.0 (#8477)
That is C++20 compatible

Fixes #8476
2025-05-05 09:00:20 +02:00
David Cosgrove
2de1dabdc1 ShapeInput from subset of atoms in molecule (#8449)
* Make shape on subset of atoms in molecule.
Optional radius for dummy atoms.

* Re-factor.
Add ShapeInputOptions.

* Python wrapper for options.

* Add non-standard radii option.
Add function to align a shape on a shape.
Add function to align conformer based on shape-shape transformation.

* Python wrappers for AlignShapes and TransformConformer.

* Add the new thing for Python options.

* Add option for excluding atoms from color features.
No partial color features if using atomSubset.

* In AlignShapes, don't change the fit shape (apart from transforming it) in case it will be used again.

* Rename it AlignShape to be consistent with AlignMolecule.

* Response to review.

* Undo clang-format

* Fix botched merge.

* Typo.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-04-27 06:51:53 +02:00
David Cosgrove
fee128300c Only apply transformation to reference centre when overlaying molecule onto molecule. (#8463) 2025-04-25 10:57:32 +02:00
David Cosgrove
a88ef96b33 Set useCutOff in PrepareConformer. (#8446) 2025-04-16 12:14:59 +02:00
David Cosgrove
4ea67c70a5 Support pickling Shape inputs (#8434)
* Stash for transfer.

* Basic serialization.

* Serialization of ShapeInput.

* Default c'tor and operator=.

* Response to review.

* Add cmake to macOS CI image.

* Add make, not cmake.

* Conditional serialization test.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-04-14 18:03:50 +02:00
Greg Landrum
8eb02b8bed switch to C++20 (#8039)
* c++20 builds working

* get MolStandardize building with clang19

* get FMCS building with clang-19

* set cxx version to c++20

* remove a few more compiler warnings

* bump min boost version, CI cleanup

* boost 1.81 is not available from conda-forge

* remove unused constants

* bump linux version for CI

* remove another unused variable

* fix (hopefully) cartridge CI builds

* simplify cartridge environment

* try postgresql14 in CI

* start the postgresql service

* change the columns used in the pandastools nbtest

* remove missed merge conflict artifact

* get github4823 test to pass with numpy 2.2

* remove a compiler warning/error with g++13
2025-04-09 11:57:17 +02:00
David Cosgrove
73382748bc Fix indexing of heavy atoms in PubChemShape (#8417)
* Fix indexing of heavy atoms.

* Increment j. Doh!

* Add include guard for the hpp.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-04-08 09:41:46 +02:00
Paolo Tosco
d8dc968eaa Avoid a segfault in CoordGen when a double bond has stereo spec but no stereo atoms (#8415)
* avoid a segfault in CoordGen when a double bond has stereo spec but no stereo atoms

* changes in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-04-08 09:32:59 +02:00
Paolo Tosco
030bd976de bump MaeParser version to 1.3.2 (enable building without boost::iostreams) (#8404)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-04-02 15:56:14 +02:00
Paolo Tosco
71c4103475 Suppress large amounts of 'BOOST_NO_CXX98_FUNCTION_BASE macro redefined' warnings in clang/emcc builds (#7747) 2025-03-29 20:04:58 +01:00
Greg Landrum
32608ae0b4 Atoms bonded to metal atoms should always have their H counts explicit in SMILES (#8318)
* refactor the code to determine whether or not an atom is in brackets

* move the definition of isMetal to QueryOps

* atoms bound to metals in SMILES should always be in square brackets

Implementation and some test updates

needs confirmation that all of tests run

* basic tests pass

* java tests pass

* update js tests

* doc updates

* Update Code/GraphMol/catch_graphmol.cpp

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

* Update Code/GraphMol/SmilesParse/test.cpp

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

* finish fixing tests

* bump yaehmop version to allow compilation to work

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-03-29 07:26:03 +01:00
Ricardo Rodriguez
55dc5c73e3 fix inchi conversion leak 1 (#8291) 2025-02-24 17:14:38 +01:00
Ricardo Rodriguez
1a67fefcc6 mem fixes (#8276) 2025-02-20 05:59:30 +01:00