107 Commits

Author SHA1 Message Date
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
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
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
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
Ricardo Rodriguez
d5aa90e18f Fix for issue #8965 (#8968)
* add a test

* change stereo bond canonicalization

* update canonicalization watch test with fixed cases

* make canonicalization test stricter (compare CIP codes)

* add reverse symmetry condition

* rewrite double bond canonicalization code

* update tests

* fix multiline comment

* update java tests

* update python test

* nix switchBondDir (unused)

* fix and rename flipBondDir

* refactor comment

* fix shadowed var name, casting

* fix neighbor sorting

* make seen_bonds a vector

* abstract setDirectionFromNeighboringBond

* handle both sides of the bond have directions

* move getNeighboringStereoBond

* check seen_bonds after popping connectedBondsQ

* use references for arguments

* add release note

* add example required by Dan

* add example requested by Dan
2026-02-26 08:58:36 +01:00
Greg Landrum
3aab2653cd Fixes #9068: raise a ValueError when trying to set properties with empty names (#9085)
* Fixes #9068

* fix a problem with empty labels in s-group parsing

* fix empty column names in smiles suppliers

* add the check to setPODVal()

---------

Co-authored-by: = <=>
2026-02-09 05:58:25 +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
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
951be4f06e fixes #5078 (#8795)
* fixes #5078

* add some more tests
2025-09-22 11:06:42 +02:00
Patrick Kunzmann
c20b2a906b Fix #8638 (#8639)
* Fix #8638

* add a test

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2025-07-25 14:33:32 +02:00
Greg Landrum
9d4afd0e08 add clearPropertyCache() (#8533) 2025-05-18 08:14:05 +02:00
Greg Landrum
5e58f20433 improve operator<< for stereogroups (#8489) 2025-05-01 16:43:33 +02:00
Eisuke Kawashima
26033b6578 style: apply modernize-use-override (#8137)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-04-25 12:24:58 +02:00
Greg Landrum
231f711c05 fix a logic error in needsHs (#8442)
* fix a logic error in needsHs

* add another test
2025-04-16 14:36:45 +02: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
Greg Landrum
28db5d706c Revert "Fixes #5134 (#5136)" (#8319)
This reverts commit 8691c58055.
2025-03-05 18:11:24 +01:00
Greg Landrum
b40f99eee3 Fixes #8304 (#8316)
* first pass, does not pass all tests

* add an option to control the new behavior

* add that to the python wrapper too

Fixes #8304

* Update Code/GraphMol/MolOps.h

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

* undo some extra comment reformatting

* typo

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

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-03-04 14:56:08 +01:00
Greg Landrum
8691c58055 Fixes #5134 (#5136) 2025-01-30 16:10:57 +01:00
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Hussein Faara
8411f4535e remove no-op macros and dead code (pt 2) (#8035)
* remove no-op macros and dead code (pt 2)

* test failures due to whitespace changes?

* actually run the testFeatures tests

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2025-01-11 14:10:00 +01:00
John Mayfield
2553cfce73 Improved handling of SP/TB/OH reording in SMILES/SMARTS. (#6777)
* Improved handling of SP/TB/OH reording in SMILES/SMARTS.

- add a getMaxNbors(tag) utility function to avoid repeated logic in multiple places
- tweak getChiralPermutation() for handling implicit/missing ligands (uses -1), allow inverse lookup
- use the tweaked chiral ordering in the reading/writing from SMILES

* clang-format run

* Reviewer requested changes.
- curly braces on all if conditions
- null check raw pointers with precondition.

* Correct additional test case introduced in the last year
2024-10-21 04:55:08 +02:00
Yakov Pechersky
ad4ee83aec Fixes #7044 (#7137)
* oxime tests

* Support allenes in canonicalizing double bonds

* alternate solution to the problem

* expand comment

* reactivate conjugated nitro test

* Fix conjugated nitro tests, have a bondstereo test

* Empty commit to re-proc tests

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-10-18 05:32:20 +02:00
Brian Kelley
0909d753b8 Fixes #7873 (#7885)
* Fixes #7873

* Resolve MonomerInfo class for deletion

* Add regression test for setMonomerInfo

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-10-11 06:42:52 +02:00
Ricardo Rodriguez
ea7f51f3b1 Fix some mem errors in 2024.09.1 (#7867) 2024-10-03 16:05:43 +02:00
Paolo Tosco
7aca92b914 fix #7782 (#7783)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-10-03 06:52:34 +02:00
Greg Landrum
da6cd73168 Run clang-format across everything (#7849)
* run clang-format-18 across Code/*.cpp and Code/*.h

* run clang-format-18 across External
2024-09-26 13:39:02 +02:00
Greg Landrum
ad3e570dea add findMesoCenters (#7574)
* add option to use chiral presence in atom ranking

* add findMesoCenters

* add includeChiralPresence to python wrapper

* add python wrapper for that

* backup, not working

* backup

* all tests pass

* add tests for partial coverage of stereo groups

all tests pass

* backout the cleanup operations for the initial merge

* track the meso atoms with atom properties.

this is an optimization for later.

* changes in response to review
2024-06-28 04:55:49 +02:00
Greg Landrum
724716b2c6 Switch to isoelectronic valence model (#7491)
* change valence model to use isolobal analogy

Remove support for five-coordinate C+ and, by analogy, five-coordinate N+2

Removes support for charge states that take atoms past the end of the periodic table
  i.e. [Lv-4] is no longer supported

* update the tests for that

* remove valence state of 6 for Al

* fix representation of phosphate in the mol2 parser

this is a correction of what was done during #5973

* cleanup the exceptions for P, S, As, and Se

* drop valence states:

Si 6, P 7, As 7

* a couple of additional changes from #7397

* update java tests

* fix an inconsistency: Rb now supports valence -1

* documentation

* - replace operator[] with at() for bounds check
- extract some code into a function to avoid duplication
- use TAB as separator throughout in the periodic table data for consistency

* removing the .at() usage

We know that these vectors aren't empty, so there's no need for the bounds check.

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-06-25 15:38:49 +02:00
Greg Landrum
c40fb8791c Favor nonwedged bonds in kekulization (#7456)
* Try not to make wedged bonds double in the kekulization code

This is a first pass implementation and definitely needs more testing of the new feature.
Probably looking at optimizing the code would also not be terrible.

All tests pass with this commit

* Some changes to the kekulization in presence of wedged bonds and additional testing

* additional kekulization test case

* start the kekulization in rings with wedged bonds

add some bulk tests

all tests now passing for me

* changes from review

---------

Co-authored-by: Riccardo Vianello <riccardo.vianello@gmail.com>
2024-06-05 13:56:00 +02:00
Ricardo Rodriguez
d71e82179d Fixes #7375 (#7381)
* check for ringinfo levels instead of init

* check for ring info in kekulizefragment

* add a test

* update tests

* update doctests

* revert ringinfo level checks
2024-05-16 09:13:32 +02:00
Ricardo Rodriguez
73e91a6344 Fixes #7318 (#7319)
* fix hybridization for atoms with outgoing dative bonds

* expose and wrap C++ numPiElectrons

* deprecate AtomPairs.Utils.NumPiElectrons

* add & update tests

* fix draw2d test

* update expected hash

* add hybridization test

* move numPiElectrons to Atom.h

* take reference instead of ptr
2024-04-03 15:34:37 +02:00
Greg Landrum
01ec60a856 Fixes #7078 (#7155)
* add MolOps::expandAttachmentPoints, along with tests

* support expandAttachmentPoints in the mol file parser

* switch the v2 stuff in the guts of the reaction parser

* add collapseAttachmentPoints()
add addAsQueries option to expandAttachmentPoints()

lots of testing

* an edge case and some cleanup

* add python wrapper for those two functions

* Update Code/GraphMol/FileParsers/FileParsers.h

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

* changes in response to review

- support addCoords in expandAttachmentPoints()
- support the new attachment point stuff to/from CXSMILES
- add MolOps::details::addExplicitAttachmentPoint() and MolOps::details::isAttachmentPoint() utility functions

---------

Co-authored-by: Ric <ricrogz@users.noreply.github.com>
2024-02-28 17:05:53 +01:00
Greg Landrum
8b8ae1561d Improve output of debugMol (#7172)
* better bond output with debugMol

* update atom output

* fix typo in the StereoGroup output
2024-02-25 17:46:21 +01:00
Ric
ae4a7dbf1f Fixes #7064 (#7141)
* insert stereogroups

* insert Substance Groups

* fix ownership, bond indexes

* add test

* fix comparison signednedss

* update test

* Brian's suggestion

* allow more than one ABS group
2024-02-22 06:46:39 +01:00
Ric
d4fa4c5aed Fixes #7131 (#7132)
* Add a test

* do not consider wedge/dash bonds when choosing controlling bonds
2024-02-06 15:55:42 +01:00
Ric
8dae48b7a1 Fixes #7128 (#7129)
* update explicit Hs on bond replacement

* add a test
2024-02-04 06:40:31 +01:00
Greg Landrum
d1b9331a36 Fixes #7122 (#7126) 2024-02-03 06:47:28 +01:00
tadhurst-cdd
d5d4d194ec atropisomer handling added (#6903)
* atropisomer handling added

* fixed non-used variables,  linking directives

* BOOST LIB start/stop fixes, linking fix

* Fixes for RDKIT CI errors

* minimalLib fix

* changed vector<enum> for java builds

* check for extra chars in CIP labeling

* removed wrong deprecated message

* fix ostrstream output error?

* restored _ChiralAtomRank to lowercase first letter

* changes for merged master

* Fixed catch label for new Catch package

* update expected psql results

* get swig wrappers building

* restore MolFileStereochem to FileParsers

* fix java wrapper for reapplyMolBlockWedging

* some suggestions

* move a couple functions out of Bond

* Merge branch 'master' into pr/atropisomers2

* merged master

* Renamed setStereoanyFromSquiggleBond

* atropisomers in cdxml, rationalize atrop wedging, stereoGroups in drawMol

* fix for CI build

* attempt to fix java build in CI

* attempt to fix java build in CI #2

* New routine to remove non-explicit  3D-geneated chirality

* changed to use pair for atrop atoms and related bonds

* Changes as per PR reviews

* PR review respnses

* PR review reponse - more

* Fix merge from master

* fixing java ci after merge

* Updated the help doc for atripisomers

* update the atropisomer docs

* improve the images

* add the source CXSMILES

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-12-22 04:58:18 +01:00
Ric
897de1d92d Fixes #6944 (#6950)
* fix issue

* add a test

* add copyright note
2023-12-01 05:41:14 +01:00
Greg Landrum
2957ab4576 switch to catch2 v3 (#6898)
* switch to catch2 v3
Fixes #6894

* fix a couple of problems noticed in the CI builds

* more warning cleanup

* changes in response to review
2023-11-15 06:45:42 +01:00
Richard Gowers
4db63b8ec1 Issue 6411 ROMol hasquery (#6739)
* added ROMol::hasQuery

* python bindings for Mol.HasQuery

* at least I checked that my Python tests were running...

* hasQuery use C++11 range iterators
2023-09-25 13:23:37 +02:00
Greg Landrum
91d32dda50 fix order of cleanupOrganometallics() in sanitizeMol() (#6690)
* fix order of cleanupOrganometallics in sanitizeMol

* make sure cleanupOrganometallics() works on non-sanitized molecules
2023-09-07 12:58:03 +02:00
Ric
eebb973ee9 fix + test (#6682) 2023-09-04 06:36:42 +02:00
Ric
8176f5c962 Fail CI builds on compiler warnings + some fixes (#6675)
* enable Werror on Mac and Linux

* do not fail on boost multiprecision pessimizing move

* fix eigen array_bounds warning

* Fix unused arg in Rascal MCS

* fix range-loop-construct warning in Rascal MCES

* fix sign mismatched comparison

* drop unused lambda capture

* allow FMCS timeout test more time under Debug (not a warning!)

* fix fwd declaration of struct RascalClusterOptions

* fix deallocator mismatch

* fix two minor leaks

* fix a real leak

* more minor leaks

* fix another real leak, plus some potential ones

* fix std::move preventing copy ellision

* allow longer run time for debug builds

* make maxBondMatchPairs and getLargestFragSize unsigned int

* make snake case camel case

* update to current master, fix new warnings

* update again and more fixes

* add #include <optional>

* fix char array deallocation

* update and fixes in Marvin writer

* unsigned int

* more copy ellision fixes

* more copy ellision fixes, and typos

* and some more
2023-09-02 04:38:45 +02:00
Ric
3167c06544 Fixes Issue 6437 (#6438)
* Add tests

* fix

* rename function
2023-06-06 17:41:03 +02:00
David Cosgrove
2d881e0abb Fix cleanupOrganometallics and reinstate to sanitisation (#6357)
* Fix canonically correct single to dative bond conversion for organometallics.

* Cleanups from review.

* Process atoms in canonical order.
Extra test.

* Only do the expensive bit if there's something to fix.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-05-23 09:49:40 +02:00
Ric
58d135a874 Reformat C/C++ code ahead of 2023.03 release (#6295)
* format files

* format template files too
2023-04-28 04:42:35 +02:00
Desmond Gilmour
295ade0fd4 fixes #6119 (#6183)
* fixes #6119

* fixed comments and made the logic more readable

* modified test cases

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-04-16 05:38:06 +02:00
Calvin Josenhans
b6345a816b Using Chiral Tag instead of CIPCode to ensure preservation of chirality in addHs (#6259)
* Changing flags if doIsomericSmiles is false

* Ignoring cis-trans bonds as well

* Tests for removing enhanced stereo

* Fix #6237 by checking chiral tag instead of CIP

* Remove unnecesary calls to fabs

* Modify AddHs

* Tets for #6237

* Rerun Checks
2023-04-14 09:03:35 +02:00
Greg Landrum
7c93c02205 remove cleanupOrganometallics() from the default sanitization (#6292)
* remove cleanupOrganometallics() from the default sanitization

* doc update
2023-04-14 08:49:26 +02:00