Skip to content

Clean up IBond.Stereo and IBond.Display#1220

Merged
egonw merged 9 commits intomainfrom
hollowwedge
Sep 3, 2025
Merged

Clean up IBond.Stereo and IBond.Display#1220
egonw merged 9 commits intomainfrom
hollowwedge

Conversation

@johnmay
Copy link
Copy Markdown
Member

@johnmay johnmay commented Sep 2, 2025

Some time ago now I added IBond.Display to replace for somewhat misnamed/abused IBond.Stereo. However I left bond fields on the bond. Recent fixes to JChemPaint showed this was a bit of a pain to work with so this commit deprecates IBond.Stereo and moves the majority of the library over to IBond.Display.

  • These changes are (mostly) backwards compatible the one exception being the "default" for "getStereo()" (deprecated) on a double bond is now E_Z_BY_COORDINATES which is what you would get from a MOLFile. This is because it is implemented in terms of getDisplay(). The default for getDisplay() is Solid for both single/double bonds (unchanged).
  • I considered doing what ChemDraw/MDL do for crossed bonds which is you store it as Wavy but bond order=2. In the end I decided a separate enum makes more sense (i.e. we have Display.Crossed AND Display.Wavy).
  • Also I added hollow wedge support as a new display type, sometimes used for relative stereochemistry

There are quite a few places where getStereo() was not used correctly. For example only Up/Down was being tested and not UpInverted/DownInverted. This is correctly ONLY if you came from a MOLfile. I have deprecated/marked these with a // JWM comment indicating it perhaps needs some attention - in practise now with IStereoElement the bond display really should only be touched in depiction since the stereochemistry is correctly captured elsewhere.

Longer term, I plan to store IStereoElements on the Atom/Bonds of a container for convenience and this is a step towards allowing that.

…precate IBond.Stereo get/set and implement them in terms of Display.

The IBond.Stereo is mainly based on MDL/CML model of bonds but then also mixes in an explicit E/Z setting. We now have correct ways
of storing this (IDoubleBondStereochemistry). There is a slight behaviour change in that by default double bonds now return
 E_Z_BY_COORDS by default which mirrors the MDL semantics.
Note some functions had incorrect presumptions about what IBond.getStereo() returned and failed to check for UP + UP_INVERTED as is required.
I have deprecated some very broken functions (in BondTools) where we have much better mechanism to handle this now. I have also left "JWM" comments where attention
might be needed, in particular CML seems to get it wrong.
Both MOLfile and ChemDraw do this but for CDK's API we split them out and handle that when we do input/output.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 3, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ B)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@egonw egonw merged commit a718006 into main Sep 3, 2025
8 of 11 checks passed
@johnmay
Copy link
Copy Markdown
Member Author

johnmay commented Sep 3, 2025

Sorry for got to say if you look at the "C" it is mostly the DebugBond logic repeating log messages.

Screenshot 2025-09-03 at 16 30 57

@johnmay johnmay deleted the hollowwedge branch March 3, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants