80 Commits

Author SHA1 Message Date
Greg Landrum
4ad9f33bf6 Revert "Fix WedgeMolBonds stealing wiggly bonds from adjacent chiral atoms (#…" (#9293)
This reverts commit 020b755ad4.
2026-05-22 04:39:08 +02:00
Chris Von Bargen
020b755ad4 Fix WedgeMolBonds stealing wiggly bonds from adjacent chiral atoms (#9267)
The standard re-wedging pattern is:

    clearSingleBondDirFlags(mol);  // saves _UnknownStereo=1, clears BondDir to NONE
    WedgeMolBonds(mol, &conf);     // re-derives wedges from chiral tags
    // ... caller restores BondDir::UNKNOWN on bonds with _UnknownStereo=1 ...

Wiggly bonds at chiral centers should survive this round-trip but did
not: countChiralNbrs only checked BondDir to decide whether a chiral
atom's stereo was already expressed, missing the _UnknownStereo=1
marker that clearSingleBondDirFlags saved when it cleared BondDir to
NONE. With the marker invisible to countChiralNbrs, pickBondToWedge
would pick the wiggly bond itself (terminal neighbors are scored
lower), and the caller's subsequent restore of BondDir::UNKNOWN would
erase the wedge, leaving the chiral atom with no visible stereo.

Fix: extend countChiralNbrs to recognize bonds with _UnknownStereo=1
as equivalent to BondDir::UNKNOWN. The chiral atom is then pre-skipped
in pickBondsToWedge, the same way it already is for bonds that still
have BondDir::UNKNOWN set.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-21 19:26:58 +02: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
Ricardo Rodriguez
86902488e9 Store CIP-ranked anchors after CIP labeling. (#9056)
* add the _CIPNeighborRanks property

* store CIP-ranked chiral neighbors

* store CIP-ranked SP2 bond and atropisomer anchors

* add a test

* boost headers in test

* add Atom::NOATOM

* add NOATOM test

* amend and clarify implicit H in Tetrahedral

* rename property

* rename property to _CIPNeighborOrder

* deprecate Chirality::StereoInfo::NOATOM
2026-01-29 18:23:44 +01:00
Ricardo Rodriguez
d3d4170e7c CXSMILES: do not add separators for unserializable Substance Groups (#9048)
* do not write extra separators

* add a test

* update tests

* Update Code/GraphMol/SmilesParse/CXSmilesOps.cpp

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-01-27 12:35:18 +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
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
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
Ricardo Rodriguez
6da61ce9ac Fixes #8712 (#8736)
* fix secondary bug involving ring stereo clearing

* refactor test

* update ring stereo for last atom
2025-09-11 05:01:08 +02:00
Greg Landrum
6d8fca2fbf Fixes #8689 (#8738)
* add test

* potential fix

* whops\!

* support disabling ring stereo in rankMolAtoms

* pass atom ranks into the ring-stereo detection code

* all tests pass

* forgot a file

---------

Co-authored-by: Ric R. <ricrogz@gmail.com>
2025-09-03 12:15:09 +02:00
Ricardo Rodriguez
3eb71c50ca A few mem fixes in tests (#8521)
* mol suppliers leaking mols on multiple tests

* test leaks query
2025-05-13 12:17:52 +02:00
Greg Landrum
86141183c1 Moving towards getting all tests to pass when using the new stereo code (#8409)
* Fixes #8379

* check in some working tests

* test passes

* test passes

* test passes

* test passes

* test passes

* ensure that the invariants flush the streams on failure

* tests pass

* test passes

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* Fixes #8391

* tests pass

* fix a test with legacy
not clear why this was not causing problems before

* make a test work

* Fixes #8396

* gcc builds work

* fingerprint tests pass

* mention backwards incompatible change

* fix a problem with FindMolChiralCenters

* more testing details

* enable the test status output

* Fixes #8432

fix a bug in double-bond stereo handling for template matching

* all depictor tests pass

* use the new-stereo chiral ranks in the depiction code

* always assign new-stereo chiral ranks

* make _ChiralAtomRank a computed property
This is analogous to _CIPRank

* tweak to the way the atom ordering is computed for 2D coordinate generation

* update two expected results

* backup

* response to review

* tests pass

* tests pass

---------

Co-authored-by: = <=>
2025-04-15 14:00:32 +02:00
Greg Landrum
7a9265b103 Fixes #8420 (#8428)
* Fixes #8420

* Update Code/GraphMol/Chirality.cpp

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

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-04-10 19:15:34 +02:00
Greg Landrum
8ea8ec5e3f Fixes #7983 (#8342)
* Fixes #7983

move the call to cleanupAtropisomerStereoGroups() into assignStereochemistry()

* Additional tests from @susanhleung in #8323

* more testing

* changes in response to review

* changes for review
2025-03-20 07:40:33 +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
Ricardo Rodriguez
077493b209 Fixes #7929 (#7930)
* add a test

* fix issue

* Update Code/GraphMol/Chirality.cpp

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-10-18 05:34:50 +02:00
Greg Landrum
350a8bcd05 Fixes #7598 (#7604)
* add test

* Fixes #7598
2024-07-15 14:15:32 -04: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
Ricardo Rodriguez
d6171aaade Fixes #7509 (#7513)
* add a test

* scale pseudo 3d offset

* update inchi test

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-06-14 05:39:48 +02:00
tadhurst-cdd
4ce1a5640a Ring stereo atropisomers (#7486)
* changed string_view to string in catch test

* fix for ring-stereo atropisomers

* removed debug cout

* removed change to build in debug mode

* change catch arg to a rerference

* changes as per PR review
2024-06-13 08:35:42 +02:00
Greg Landrum
ba5f43fa6f Fixes #7438 (#7474)
This moves the function into the Chirality namespace.
2024-05-31 14:41:22 +02:00
Greg Landrum
748f36f7d8 Fixes #7434 (#7446) 2024-05-16 14:32:38 +02:00
Greg Landrum
18d1ff5f8f Prefer wedging ring bonds around atropisomers (#7373)
* prefer wedging ring bonds for atropisomers

* update expected results

* handle 3D as well

* prefer wedging to larger rings

wedging bonds in 5 rings make later attempts at improving kekulization very difficult

update expected results

* extend those changes to 3D

* update tests for those changes

* avoid wedging atropisomers if possible

response to review
2024-05-08 06:04:23 +02:00
Greg Landrum
a7ac25cbe8 Fixes #7300 (#7413) 2024-05-02 17:32:05 +02:00
Ricardo Rodriguez
ba7deb89a0 Fixes #7346 (#7347)
* add a test

* fix issue
2024-04-11 16:16:47 +02:00
Greg Landrum
9bb5e4834f Support zero order bonds in V3K CTABs (#7269) 2024-03-18 18:45:08 +01:00
Greg Landrum
e7084bb400 Do not wedge bonds to attachment points (#7212)
* make sure added attachment points have valences set

* do not wedge bonds to attachment points if at all possible
2024-03-05 21:13:26 +01:00
Greg Landrum
6981cb0a39 allow perception of stereo from T-shaped structures (#7183)
* allow perception of stereo from T-shaped structures

* document that in the release notes
2024-03-05 15:59:11 +01:00
Greg Landrum
716b38a2d8 Fixes #7140 (#7150)
* Fixes #7140

deprecates the old version and creates a new one in Chirality.h
adds it to the python wrappers

* changes in response to review

* backup

* support custom labels with templates
2024-02-12 15:50:02 +01:00
Greg Landrum
b9a345157e Fixes #7076 (#7092) 2024-01-25 19:31:18 +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
3c494e3425 Fixes #6981 (#6982) 2023-12-16 08:01:33 +01:00
Greg Landrum
c9a46b34bc Fixes #6975 (#6972) 2023-12-11 17:40:30 +01:00
Ric
897de1d92d Fixes #6944 (#6950)
* fix issue

* add a test

* add copyright note
2023-12-01 05:41:14 +01:00
Brian Kelley
4200047dc0 Set squiggle bonds to STEREOANY with stereo atoms (#6877)
* Set squiggle bonds to STEREOANY with stereo atoms

* STEREOANY from squigglebonds is set regardless of sanitization now

* Ensure we have stereo atoms

* Add comment for new behavior

* See if a newer version of cmake works

* rev cmake to a slightly new version

* rev cmake to a slightly older version

* Response to review

* Allow setting of CIS/TRANS in set from squiggle bond

* Fix missing paren

* Add test for the actual enumeration

---------

Co-authored-by: Brian Kelley <bkelley@relaytx.com>
2023-11-29 04:52:39 +01:00
Brian Kelley
ee8c35a236 Removing stereoatoms requires removing CIS/Trans stereo flags (#6901)
* Removing stereoatoms requires removing CIS/Trans stereo flags

* Added test when removing nbrs of cis/trans bonds

---------

Co-authored-by: Brian Kelley <bkelley@relaytx.com>
2023-11-21 08:01:37 +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
tadhurst-cdd
d7c01af9c8 Fixes for canonicalization, and stereochemistry (#6743)
* Fixes for canonicalization, and stereochemistry

* chnages from code review

* test that was omitted for canon correction

* PR review changes

* changes as per PR review

* missed file checkint to make PR tests compile

* PR conflict resolution

* change to fix PR buld errors (hopefully)

* line delete to force re-running of tests

* changes as per PR review

* resolve merge conflicts with master

* some suggestions

* revert chirality modifications when sanitization isn't being done

* addl changes: no stereo percept when no sanitize

* missing test expected files added

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-11-06 07:40:23 +01:00
Ric
3720c2ceaf Fixes #6703 (#6705)
* add test

* fix the issue

* make imines w/ implicit H unspecified, but allow unknown

* improve test in 6527

* do not mark double bonds as EITHERDOUBLE if no neighbors
2023-09-28 05:16:17 +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
Greg Landrum
5086391cdb Fix a bunch of edge cases in the pseudo 3d chiral assignment code. (#6669)
* handle bonds with zero length around chiral centers

* chirality perception fixes
- fix handling of T-shaped chirality
- catch zero-length bonds
- catch opposing bonds with opposite wedging

* another special case

* more quasi-linear handling

* more progress

* backup

* update

* remove some complication with the neighbor order sorting by just doing a sort
🤦
passing all tests again

* oh, isn't this fun?

* no more t-shaped three-coordinate chirality

* still a couple of tests failing

* all tests pass

* overlapping neighbors without wedges remove stereo

* add test for overlapping atoms with wedged bonds

* make warnings consistent to allow easy parsing

* more testing

* docs
2023-08-31 17:30:16 +02:00
Ric
8c62a963fe Fixes #6640 (#6642) 2023-08-20 15:54:49 +02:00
Ric
8d95e1be5b fix issue in stereo bonds with only implicit H (#6527) 2023-07-27 19:00:21 +02:00
Greg Landrum
8ab356e266 Allow systems like C/C=N/[H] to be stereogenic with the new chirality perception (#6473)
This was raised in discussion #6291 here:
https://github.com/rdkit/rdkit/discussions/6291#discussioncomment-6214078
2023-06-22 10:53:58 +02:00
Ric
61dad64eef Fixes #6423 (#6424)
* add one test

* try to wedge a second bond

* comments

* review comments
2023-06-06 17:39:56 +02:00
Ric
36c4ec9e2b Fixes #6239 (#6240)
* check for protium nbrs

* Add a test

* fix test id

* fix H detection
2023-04-11 10:42:56 +02:00
Ric
4e2e45baa3 Fixes #6217 (#6218)
* fix

* add a test
2023-03-22 17:14:03 +01:00
Greg Landrum
7b139a2276 Add the option to wedge two bonds at chiral centers (#6108)
* refactoring: move a bunch of bond-wedging code into WedgeBonds.cpp and
into the Chirality namespace (since it's not just connected to mol files)

* remove a compiler warning

* more cleanup

* backup

* basics work; needs testing and edge cases

* backup

* progress

* better

* make sure the new wedges are also inverted

* docs

* favor lower degree atoms, even if the angle isn't ideal

* fix clang compile problems (hopefully)
2023-03-11 05:25:03 +01:00
Greg Landrum
58b79c6f8e BondDir not cleared from bonds that aren't stereoactive (#6162)
* backup

* update .gitignore

* passes tests

* all tests now pass

* update release notes

* cleanup

* changes in response to review
2023-03-07 15:15:11 +01:00
Greg Landrum
4d4b927651 Fixes #6049 (#6061)
* backup

* backup

* Fixes #6049

Bump version of NumBridgeheadAtoms descriptor

* add a specific test for the issue
2023-02-09 08:31:39 +01:00