Skip to content

SKETCH-2375: Migrate to RDKit native attachment point handling - #360

Open
cdvonbargen wants to merge 6 commits into
schrodinger:mainfrom
cdvonbargen:pr/SKETCH-2375-native-attachment-points
Open

SKETCH-2375: Migrate to RDKit native attachment point handling#360
cdvonbargen wants to merge 6 commits into
schrodinger:mainfrom
cdvonbargen:pr/SKETCH-2375-native-attachment-points

Conversation

@cdvonbargen

@cdvonbargen cdvonbargen commented May 23, 2026

Copy link
Copy Markdown
Collaborator

RDKit APIs used

  • MolOps::expandAttachmentPoints() replaces molattachpt_property_to_attachment_point_dummies().
  • MolOps::collapseAttachmentPoints() replaces attachment_point_dummies_to_molattachpt_property().
  • MolOps::details::addExplicitAttachmentPoint() replaces make_new_attachment_point().

Functions kept for Sketcher behavior

  • is_attachment_point_dummy() cannot use RDKit's isAttachmentPoint() because RDKit tests whether an AP can be collapsed and therefore rejects wedged APs. Sketcher must still recognize those as attachment points and support legacy _AP<n> labels.
  • compute2DCoords() additionally handles HELM structures, frozen atoms, ring templates, and removal of stale molfile wedging.
  • wedgeMolBonds() prevents RDKit from choosing attachment-point bonds for wedging by temporarily making those bonds ineligible.
  • The Sketcher R-group helpers for AP numbering, renumbering, bond/atom lookup, and counting implement Sketcher's global _AP<n> UI numbering. RDKit's _fromAttachPoint values only describe the first or second attachment on an individual parent atom.

Testing Done

Added new tests; all existing tests pass

@cdvonbargen
cdvonbargen force-pushed the pr/SKETCH-2375-native-attachment-points branch from a869a44 to 321fd89 Compare August 4, 2026 13:29
@cdvonbargen
cdvonbargen marked this pull request as ready for review August 4, 2026 13:40
cdvonbargen and others added 6 commits August 4, 2026 06:41
Replace custom attachment point expand/collapse functions with RDKit's
native MolOps::expandAttachmentPoints() and collapseAttachmentPoints().
Set _fromAttachPoint property on AP dummies for compatibility with the
native API, while keeping atomLabel for molecule-level numbering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mentPoint

Delegate is_attachment_point_dummy() to RDKit's MolOps::details::isAttachmentPoint()
and replace make_new_attachment_point() with MolOps::details::addExplicitAttachmentPoint().
This requires all AP dummies to have _fromAttachPoint set, so label_expanded_attachment_points()
now also marks CXSMILES-sourced APs that only have atomLabel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hmentPoint

Remove the is_attachment_point_dummy wrapper from rdkit_extensions and replace
all call sites with RDKit::MolOps::details::isAttachmentPoint(). Also simplify
collapse_attachment_point_dummies to just call collapseAttachmentPoints without
the redundant marking loop, since all AP creation and read paths now set
_fromAttachPoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Inline the single collapseAttachmentPoints call at the write site and drop
the unnecessary updatePropertyCache calls that bookended it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cdvonbargen
cdvonbargen force-pushed the pr/SKETCH-2375-native-attachment-points branch from 321fd89 to a426dd5 Compare August 4, 2026 13:46

@ethan-schrodinger ethan-schrodinger left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No "testing done" section. I assume this was tested?

Comment on lines +29 to +35
if (atom.hasProp(RDKit::common_properties::_fromAttachPoint)) {
return true;
}

std::string label;
return atom.getAtomicNum() == 0 && atom.getTotalDegree() == 1 &&
atom.getPropIfPresent(RDKit::common_properties::atomLabel, label) &&
label.find(ATTACHMENT_POINT_LABEL_PREFIX) == 0;
return atom.getPropIfPresent(RDKit::common_properties::atomLabel, label) &&
label.starts_with(ATTACHMENT_POINT_LABEL_PREFIX);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what conditions would we see the attachment point prefix on the atom label, but we wouldn't see the _fromAttachPoint property?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_fromAttachPoint is only set by RDKit when reading SD files or using the (relatively new) addExplicitAttachmentPoint/expandAttachmentPoints functions directly; so things like CXSMILES wouldn't have it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, thanks. Is this well known, or would we benefit from adding a comment here to this effect?

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