Commit Graph

5666 Commits

Author SHA1 Message Date
Greg Landrum
e786ca231d Stop using raw pointers in the canonicalization interface (#8990)
* change count-type from pointer to ints to vector

* change type from pointer to ints to vector

* change type from pointer to ints to vector

* change type from pointer to ints to vector

* change type from pointer to ints to vector

* use std::fill only when necessary

* delete unnecessary includes

* reformat

* re-enable a test that was accidentally disabled a few years ago

* finish getting rid of the raw pointers

* include chrono

* changes from review

---------

Co-authored-by: Anna Brünisholz <anna.bruenisholz@gmail.com>
2025-12-12 14:00:23 +01:00
Ricardo Rodriguez
a8a00a1d99 Small fix in ring stereo/canonicalization (#8962)
* fix

* update canonicalization watch test

* add ring chirality test

* prune duplicates
2025-12-12 13:56:01 +01:00
Brian Kelley
70540c2eed Add extract mol fragment api (#8811)
* Create a function to extract some specified atoms from a ROMol as a new ROMol by creating new graph (#8742)

This adds a new api, `RDKit::MolOps::ExtractMolFragment`, to allow efficient
extractions of mol fragments from large mols. Compared to the approach where
we delete "unwanted" atoms/bonds from the input mol, this api is faster for
small mols (about 2x faster) and at least 3x faster for big mols
(was 10x faster for "CCC"*1000).

* clang-format

* review comments

* cleanup

* Consolidate copying subsets of molecules

* Readd missing tests

* Update comment to restart build

* Remove missing test

* Remove debugging comment, fix warnings

* Fix warnings on gcc11

* Add docs

* Make vector<bool> dynamic_bitset<>

* Update copyright

* Add swig wrappers

* Use new designated constructor API

* Fix windows builds

* Change enum values from unsigned int to integer

* Fix unsigned int variable

* Update Code/GraphMol/Wrap/test_subset.py

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

* Update Code/GraphMol/Subset.cpp

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

* Update Code/JavaWrappers/gmwrapper/src-test/org/RDKit/ChemTransformsTests.java

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

* Reponse to review

* Fix documentation

* Remove comments

* Remove unnecessary comments

* Fix one liners

* Change assertion to be clearer (and not one-liners)

* Run clang-format

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Hussein Faara <hussein.faara@schrodinger.com>
Co-authored-by: Brian Kelley <bkelley@glysade.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-12-09 15:06:29 +01:00
Chi Cheng
2d25752fe0 Improve DetermineBonds and DetermineBondOrders performance (#8888)
* try to reduce the number of valence combinations by checking neighbour valence and bonding

* fixed error message. Remove test that fails now because determineBondOrders finishes too quickly.

* cleanup

* adjust checking

* fix building

* add interrupt test back in but use a molecule that still takes a bit of time.

* improve error messaging

* change "test interrupt" to use xyz

* fix for atoms without valence information. and apply suggestions

* Update Code/GraphMol/DetermineBonds/DetermineBonds.cpp

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-12-08 06:17:41 +01:00
Greg Landrum
436ecbebac Allow Hs to be ignored in the RMSD alignment functions (#8976)
* first pass at allowing Hs to be ignored in getBestRMS()

* add support in getAllConformersBestRMS()

* do getBestAlignmentTransform()

* cleanup, error checking, and a fix

* this is more painful than it seems like it should be

* add python wrappers and tests

* response to review
2025-12-04 18:37:59 +01:00
Greg Landrum
af4e6c05ec strip whitespace from embedParametersToJSON() (#8989)
* strip whitespace from embedParametersToJSON()

* update expected results in python tests

---------

Co-authored-by: = <=>
2025-12-04 06:57:08 +01:00
Ricardo Rodriguez
39c4083bbf Minor clean up in SMILES Writing double bond canonicalization (#8971)
* move firstVisitOrder into lambda

* remove extra bond switch

* modernize loop
2025-12-03 17:38:56 +01:00
Greg Landrum
6e331accc0 some optimizations of AlignPoints() (#8987)
* some optimizations of AlignPoints()
still should do some benchmarking to see how much of a difference the changes make

* remove unused variable

---------

Co-authored-by: = <=>
2025-12-03 16:59:11 +01:00
Ricardo Rodriguez
22a9814655 Convert graphmolMolOpsTest to catch2 (#8978)
* move test to catch2

* fix one broken test

* make some stuff constexpr

* refactor some checks involving exceptions

* replace CHECK_INVARIANT

* replace CHECK_INVARIANT

* clean up commented out debug logging

* initialize var

* remove redundant REQUIRE_MSG
2025-12-03 06:28:56 +01:00
Niels Maeder
bc4fffda7b Embed Parameters to JSON (#8977)
* add function to convert embedParams to json

* add catch test

* add function to python wrapper

* test python function

* update copyright

* undo formatting and cleanup

* more cleanup

* remove the map flag and added round trip

* add bounds mat output

* run clang-format
2025-11-29 05:19:44 +01:00
Andrew Dirksen
2adf5211e6 add more benchmarking (#8878)
* Add many new c++ catch2 performance benchmarks.

* inline splitmix64 from boost, splitmix64 is not always available in boost. fun fact, this version is ~twice as fast

* reduce intensity of memory pressure test, target 200MB usage.

* new bench compound; accept suggestion from code review

* bench MolToCXSmiles

* Update Code/Bench/stereo.cpp

* impl first part of the suggestions from code reveiw

* impl second part of the suggestions from code reveiw
2025-11-27 14:25:57 +01:00
Ricardo Rodriguez
f2e0e5c440 count stereo features (#8963) 2025-11-23 07:15:30 +01:00
Rachel Walker
3320d7b454 Modern stereo: fix stereo inversion in rings (#8957)
* Modern stereo: fix stereo inversion in rings

* Update Code/GraphMol/catch_chirality.cpp

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

* Update Code/GraphMol/catch_chirality.cpp

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

* Update Code/GraphMol/catch_chirality.cpp

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

* review comments

* Update Code/GraphMol/catch_chirality.cpp

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

* gregs comment

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-11-21 07:50:16 +01:00
Ricardo Rodriguez
79b595de20 Add test to watch the state of canonicalization problems reported in #8775 (#8958)
* add test

* add 8862, rename var

* rename variables
2025-11-20 19:21:06 +01:00
paconius
bea9b11a34 Python Bond Inversion (#8951)
* Exposed Bond::invertChirality() to Python

* Add Bond InvertChirality Test

* Fix test code

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

* Fix unittest

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-11-19 05:54:04 +01:00
Greg Landrum
b2f1eae1c3 Do not add a __computedProps property to molecules when initializing them (#8931)
The rest of the code already adds the property if/when it is needed, so
there's no need to add it to every molecule.
2025-11-18 19:09:36 -05:00
tadhurst-cdd
20aeb386e7 Valence error when parsing SCSR (#8948)
* turn off strict valence check for SCSR Templates

* fix to test molecule ValenceErrorScsr.mol

* Add test mols
2025-11-18 17:09:04 +01:00
David Cosgrove
40fe7ef681 Better solid triangles (#8943)
* Change the way solid wedges are drawn to use larger polygons.

* Better variable name.
2025-11-18 09:47:24 +01:00
Greg Landrum
f71b8e2148 Fixes #8945 (#8946) 2025-11-13 15:18:03 +01:00
Justin Gullingsrud
37a874acd9 Make incremental search callback take ownership of mols (#8940) 2025-11-11 17:10:29 +01:00
Phong Lam
c41513e578 Return original molecule from StereoisomerEnumerator when no unspecified stereocenters are available (#8924)
* Enhance StereoisomerEnumerator to return original molecule when no flippers are available and add test for embedding behavior with input acceptance.

* Use std::make_unique for ROMol construction

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-11-11 17:05:30 +01:00
Greg Landrum
45681a1c04 Switch from using RapidJSON to Boost::JSON for MolInterchange (#8859)
* First pass at port

Mostly auto-converted using claude sonnet 4

Things are a bit slower in this initial port. Here's some timing data for molecules from SMILES (no coords) and from SDF (with coords)

# MASTER
## smiles
read: 50000 mols.
 9.260000s wall, 8.650000s user + 0.600000s system = 9.250000s CPU (99.9%)
serialize
 3.060000s wall, 2.400000s user + 0.660000s system = 3.060000s CPU (100.0%)
deserialize
 1.350000s wall, 1.250000s user + 0.090000s system = 1.340000s CPU (99.3%)

## SDF
read: 50000 mols.
 9.340000s wall, 8.930000s user + 0.400000s system = 9.330000s CPU (99.9%)
serialize
 6.630000s wall, 5.960000s user + 0.680000s system = 6.640000s CPU (100.2%)
deserialize
 1.450000s wall, 1.450000s user + 0.000000s system = 1.450000s CPU (100.0%)

# Boost::JSON
## smiles
read: 50000 mols.
 9.250000s wall, 8.830000s user + 0.420000s system = 9.250000s CPU (100.0%)
serialize
 4.770000s wall, 4.410000s user + 0.350000s system = 4.760000s CPU (99.8%)
deserialize
 2.320000s wall, 2.100000s user + 0.230000s system = 2.330000s CPU (100.4%)

## SDF
read: 50000 mols.
 9.500000s wall, 9.100000s user + 0.400000s system = 9.500000s CPU (100.0%)
serialize
 8.760000s wall, 8.330000s user + 0.420000s system = 8.750000s CPU (99.9%)
deserialize
 2.540000s wall, 2.330000s user + 0.210000s system = 2.540000s CPU (100.0%)

* some json parser optimization

* around the edges

* optimizations for the writer

* hopefully get things compiling

* convert the MinimalLib stuff to use boost::json

Again, a lot of the lifting here was done using Claude Sonnet 4 in VS Code Copilot

* fix Windows DLL build

* response to review

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

* better not to blindly accept suggestions

* fix the problems in MinimalLib

---------

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
Co-authored-by: = <=>
2025-11-11 11:54:44 +01:00
Greg Landrum
60940f5e53 Fixes a bug with chirality perception of T-shaped centers in very large rings (#8930)
* Fixes a bug with chirality perception of T-shaped centers in very large rings

* remove those files from the chemdraw tests
should be added later once we figure out and fix what the problem on the chemdraw side is (it is not directly connected to this PR)

* be more systematic about the tolerance values
carry the same tolerances over into the bond wedging code

* re-enable those chemdraw tests

* typo
2025-11-10 13:02:42 -05:00
Greg Landrum
1a43f1cbef Fixes for nontetrahedral stereo parsing from SMILES/SMARTS (#8932)
* backup

* fix nontet stereo parsing in SMARTS
2025-11-09 05:31:12 +01:00
Justin Gullingsrud
bda9ffbeec Incremental synthon search (#8855)
* Iterated interface to substructure search

* Add a test

* Add python unit test

* Expose the toTryChunkSize parameter to python

* Respect the maxHits parameter; sort the hitset

* Treat maxHits=-1 as infinite

* Add callback versions of fp and rascal search; conform to C++ style

* Add fp and rascal C++ tests

* maxHits=-1 tripped me up again

* Add fp and rascal python wrappers.

Changed the name of the callback-based method to have "Incremental"
in the name because the overloaded versions with default arguments
can't be reliably selected by the boost python runtime.  Probably
better to have a different method name anyway since the return type
is None instead of a results object.

* Delete stray printf.

* Run clang-format

* Use std::int64_t instead of ssize_t for portability

* Make docstrings on callback-based methods more descriptive

* Stop incremental search if the callback returns true.

* Add an example of incremental synthon search to the getting started docs

* trivial commit to force CI rerun

* Reformat single line if statements.

* Make SearchResultsCallback take const ref input

* Fix another one-liner

* Oops - another one-liner
2025-11-08 04:27:16 +01:00
Greg Landrum
adf72c984f Do not reset the ringInfo information when adding bonds to RWMol (#8934)
* Do not reset the ringInfo information when adding bonds

This call was inconsistent (for example, the version of addBond() in ROMol did not do it)
and is unnecessary since the standard assumption is molecules need
to be re-sanitized after adding atoms and bonds

* response to review

clear the property cache on atoms after adding a bond.

* add a property cache update to the reaction runner

* add something to the release notes
2025-11-07 14:41:01 +01:00
Chris Von Bargen
732a63356a Change extern types to static consts (#8765)
* When building RDKit as a static library, Ricardo found that the externs aren't
being resolved correctly causing a number of bad std::any casts. This is his
patch (which we apply in the context of the sketcher build) which moves the
definitions up from the types.cpp file, and make them static.

* Use inline keyword to avoid duplication overhead; this still allows the
use of the static keyword to resolve the issue with static libs
https://en.cppreference.com/w/cpp/language/inline.html

* static inline doesn't work in my static builds; inline only does though

* inline constexpr std::string_view

* casting

* inline-constexpr

* add string_view to python converter

* propagate string_view after static types

---------

Co-authored-by: Ric <ricrogz@gmail.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-11-07 05:15:22 +01:00
Greg Landrum
9a4cca3967 Allow using generators for similarity maps (#8912)
* add option to track atoms involved in each bit for morgan FP

Needs test still

* support similarity maps using fingerprint generators

* support RDKit, AP, and TT

still need tests

* add some testing

* response to review
2025-11-06 19:12:29 +01:00
Greg Landrum
84bef7a66e Allow abbreviations without XBonds (#8933)
* coding error checking on extraAttachAtoms

* Allow abbreviations that do not include XBonds

Fixes #8902
2025-11-06 16:33:25 +01:00
tadhurst-cdd
c948297d98 added new attributes for scsr template as per BIOVIA doc 2023 (#8911)
* added new attributes for scsr template as per BIOVIA doc 2003

* changed to allow any attributes for an SCSR Template def

* removed unneeded defs for TEMPLATE attribute names
2025-11-06 12:24:45 +01:00
Ricardo Rodriguez
9a4b3e2fc6 Implements #8873 (#8904)
* merge ABS groups on setStereoGroups

* warn/fail on multiple ABS groups on strict parsing

* add a test for setStereoGroups

* add a test for multiple ABS groups in mol blocks

* Drop the warning
2025-11-04 16:10:56 +01:00
Anton Siomchen
d3756fc9a2 add conditional logic for GETAWAY test (#8923) 2025-11-04 16:05:56 +01:00
Ricardo Rodriguez
c354ff11dc ignore whitespace in patch (#8927) 2025-11-04 16:04:39 +01:00
David Cosgrove
b9b6078137 Extra explanation of getPosition() and getReagents(). (#8909) 2025-11-01 06:18:08 +01:00
Brian Kelley
c4678568a9 Use adjustQueryProperties logic when dealing with dummy atoms in cxsmiles (#8907) 2025-11-01 05:38:17 +01:00
David Cosgrove
a5347e725e Allow Multiple Core Hits in the Same Molecule in RGroupDecomposition (#8813)
* Allow the same core to match more than once in a molecule.

* Update annotation.

* Changes after review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-10-29 21:50:19 +01:00
David Cosgrove
dad4d39803 Change docs in Python EmbedMultipleConfs. (#8900)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-10-28 02:09:14 +01:00
Greg Landrum
0ee90279b5 Partial fix to a problem with implicit Hs being written to SMARTS (#8893)
* Partially resolve a problem with implicit Hs ending up in SMARTS

* update doctest

* document in release notes
2025-10-24 07:50:06 +02:00
Greg Landrum
8844c55572 Fixes #8890 (#8891)
stop stripping string properties
updates doc string
adds a test for autoConvertStrings
2025-10-23 08:52:27 -04:00
Ricardo Rodriguez
e4c8ed7765 remove (#8872) 2025-10-23 11:21:36 +02:00
Greg Landrum
e625bdb95c make Point2D and Point3D constexpr (#8882)
* constexpr Point, Point2D, and Point3D

* constexpr Vector

* cleanup

* rollback overzealous constexpring

* dial back the constexpr to get windows builds working

the math stuff isn't constexpr with MSVC++

* add [[nodiscard]]
2025-10-23 10:57:33 +02:00
Greg Landrum
20907d3ba9 Fixes #8877 (#8886) 2025-10-22 07:59:35 -04:00
Andrew Dirksen
1ea159ce65 set up performance benchmarks (#8865) 2025-10-18 08:07:49 +02:00
Ricardo Rodriguez
d9850596aa Fixes #8726 (#8874)
* do not remove hydrides by default

* add a minimal test

* add release note about behavior change

* require Hydrides to have degree 1

* also allow hydrides with degree 0 (ionic bond)

* suggested changes

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2025-10-17 16:51:22 +02:00
Greg Landrum
93d0f8bb74 Fixes #8776 (#8875)
* Fixes #8776

don't call the pseudo-CIP perception code if we really don't need to

* allow calling the pseudo-CIP code from Python

* update doctests
2025-10-17 05:52:27 +02:00
Ricardo Rodriguez
af4e8cf01f propagate string_view (#8858) 2025-10-14 19:15:37 +02:00
Greg Landrum
3a4d4df17e allow default radii in the DCLV calculation (#8836) 2025-10-11 20:35:20 +02:00
Greg Landrum
9fd5595f98 use bond labels in the ranking in MolFragmentToSmiles (#8861) 2025-10-10 14:58:45 +02:00
David Cosgrove
dfdddb3fc9 Add extra info about return value. (#8860) 2025-10-10 14:58:20 +02:00
Ricardo Rodriguez
7d1e662bc7 Use std::string_view for property keys (#8844)
* string_view props API

* wip

* fix leak

* add string_view to swig

* fix comment

* add backwards incompatibilty note

* fix rebase issue

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-10-09 16:14:48 +02:00