Commit Graph

4456 Commits

Author SHA1 Message Date
Ricardo Rodriguez
deeb9727fc Refactor atomVisitOrders and bondVisitOrders in SMILES Writer canonicalization (#8972)
* refactor calculation of atomVisitOrders/bondVisitOrders

* refactor checkBondsInSameBranch

* fix
2025-12-30 07:08:29 +01:00
Ricardo Rodriguez
08d9b42574 Small fix in ring stereo/canonicalization (#8962)
* fix

* update canonicalization watch test

* add ring chirality test

* prune duplicates
2025-12-30 07:08:15 +01:00
Brian Kelley
48e1fc2b8d 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-30 07:07:50 +01:00
Chi Cheng
c86a691a4d 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-30 07:07:25 +01:00
Greg Landrum
63f514455f 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-30 07:07:04 +01:00
Greg Landrum
c69a20d9f6 strip whitespace from embedParametersToJSON() (#8989)
* strip whitespace from embedParametersToJSON()

* update expected results in python tests

---------

Co-authored-by: = <=>
2025-12-30 07:06:45 +01:00
Ricardo Rodriguez
896b6e8f1e Minor clean up in SMILES Writing double bond canonicalization (#8971)
* move firstVisitOrder into lambda

* remove extra bond switch

* modernize loop
2025-12-30 07:06:22 +01:00
Ricardo Rodriguez
d7cc6b67bf 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-30 07:05:50 +01:00
Niels Maeder
3bc08f39de 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-12-30 07:05:11 +01:00
Ricardo Rodriguez
84ab326f3c count stereo features (#8963) 2025-11-27 17:28:43 +01:00
Rachel Walker
1da163da0d 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-27 17:28:29 +01:00
Ricardo Rodriguez
a3854088fb Add test to watch the state of canonicalization problems reported in #8775 (#8958)
* add test

* add 8862, rename var

* rename variables
2025-11-27 17:28:08 +01:00
paconius
9e7a88e68c 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-27 17:27:33 +01:00
Greg Landrum
65830d2b4c 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-27 17:27:05 +01:00
tadhurst-cdd
29e9f76a65 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-27 17:26:35 +01:00
Greg Landrum
02f0226d6e Fixes #8945 (#8946) 2025-11-27 17:25:51 +01:00
Justin Gullingsrud
d03f8cbe50 Make incremental search callback take ownership of mols (#8940) 2025-11-27 17:25:23 +01:00
Phong Lam
ff6b3b29b5 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-27 17:25:09 +01:00
Greg Landrum
c8ce8418de 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-27 17:22:28 +01:00
Greg Landrum
82e8f673b7 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-27 17:22:10 +01:00
Greg Landrum
f000203f9b Fixes for nontetrahedral stereo parsing from SMILES/SMARTS (#8932)
* backup

* fix nontet stereo parsing in SMARTS
2025-11-27 17:21:52 +01:00
Justin Gullingsrud
1b57199672 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-27 17:21:35 +01:00
Greg Landrum
8800e1556b 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-27 17:21:07 +01:00
Greg Landrum
d4f829fd8e 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-27 17:16:25 +01:00
Greg Landrum
ccdcf4e890 Allow abbreviations without XBonds (#8933)
* coding error checking on extraAttachAtoms

* Allow abbreviations that do not include XBonds

Fixes #8902
2025-11-27 17:16:08 +01:00
tadhurst-cdd
10465683d8 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-27 17:15:54 +01:00
Ricardo Rodriguez
f0779cae3e ignore whitespace in patch (#8927) 2025-11-27 17:15:23 +01:00
Ricardo Rodriguez
d1319ac2ec 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-27 17:15:03 +01:00
Anton Siomchen
5ed46eeb3b add conditional logic for GETAWAY test (#8923) 2025-11-27 17:14:21 +01:00
David Cosgrove
037b2b227c Extra explanation of getPosition() and getReagents(). (#8909) 2025-11-27 17:13:43 +01:00
Brian Kelley
f2b887bee4 Use adjustQueryProperties logic when dealing with dummy atoms in cxsmiles (#8907) 2025-11-27 17:12:53 +01:00
David Cosgrove
53203079c1 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-31 13:49:35 +01:00
David Cosgrove
e6f37dc498 Change docs in Python EmbedMultipleConfs. (#8900)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-10-31 13:49:20 +01:00
Greg Landrum
05f2b18e7f 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-31 13:49:04 +01:00
Greg Landrum
8e8513e2f1 Fixes #8890 (#8891)
stop stripping string properties
updates doc string
adds a test for autoConvertStrings
2025-10-31 13:48:48 +01:00
Ricardo Rodriguez
47ea817e1a remove (#8872) 2025-10-31 13:48:31 +01:00
Greg Landrum
b5378fc2e1 Fixes #8877 (#8886) 2025-10-31 13:47:38 +01:00
Ricardo Rodriguez
eac676c625 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-31 13:46:57 +01:00
Greg Landrum
3b60c7f3ae 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-31 13:46:25 +01:00
Greg Landrum
2ed6df962e allow default radii in the DCLV calculation (#8836) 2025-10-31 13:45:17 +01:00
Greg Landrum
f1c464c6c8 use bond labels in the ranking in MolFragmentToSmiles (#8861) 2025-10-31 13:44:57 +01:00
David Cosgrove
05837b28e7 Add extra info about return value. (#8860) 2025-10-31 13:44:38 +01:00
Greg Landrum
0a5d7f7993 Use properties in the MolDrawOptions python wrappers to make setting/getting colours easier (#8857)
* support direct property setting/getting in MolDraw2DOptions

* same thing for contourParams

* add getAtomPalette()
2025-10-31 13:44:25 +01:00
Ricardo Rodriguez
cf64184339 Merge simple AND queries onto atoms. (#8830)
* duplicate parser code

* regenerate smarts.tab files

* update test

* add release note

* restore pregenerated header

* Suggested changes (#23)

* add a generic flags interface to atoms and bonds

* suggested changes

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-10-31 13:43:56 +01:00
Greg Landrum
cd42cf18ea Fix a couple issues related to atom list handling in V3000 mol blocks (#8824)
Fixes #8820
Fixes #8823
2025-10-31 13:43:17 +01:00
Brian Kelley
16c1637b67 Allow labeled atoms to have working queries (#8849)
* Allow labeled atoms to have working queries

* Remove stray keystrokes

* Fix typo

* Apply clang-format

* Move simpler checks first

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
2025-10-31 13:42:59 +01:00
Niels Maeder
d663b0f7ee same docs for same behaviour (#8854) 2025-10-31 13:42:41 +01:00
Ricardo Rodriguez
e3f2e4651e Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-31 13:42:16 +01:00
Niels Maeder
bf6f924bf9 Add safeSetattr to more params / options objects (#8842)
* add safeSetattr to varios params objects

* added safeSetattr to further params / options
2025-10-31 13:42:01 +01:00
Rachael Pirie
1afb51748d add Reaction From Smiles python wrapper (#8843)
* add Reaction From Smiles python wrapper

* Update Code/GraphMol/ChemReactions/Wrap/rdChemReactions.cpp

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

* fix Greg changes

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-10-31 13:41:41 +01:00