Skip to content

Sticky fragments - #66

Merged
stsouko merged 13 commits into
masterfrom
sticky-fragments
Jul 27, 2026
Merged

Sticky fragments#66
stsouko merged 13 commits into
masterfrom
sticky-fragments

Conversation

@stsouko

@stsouko stsouko commented Jul 27, 2026

Copy link
Copy Markdown
Member

No description provided.

stsouko and others added 13 commits July 26, 2026 17:40
Expand the starter set to 42 maintainer-curated roles (68 entries) split by
attachment hybridization (aryl/alkyl/alkenyl-sp2/alkynyl-sp): halide and
sulfonate electrophiles (fluoride separate), boron/organometal donors, acyl,
keep-heteroatom amine/thiol/hydroxyl nucleophiles (Mitsunobu keep-O), and
deoxygenative/decarboxylative handles. Fix the alkynyl_bromide cap template
(:2 was unmapped -> zero products) to [A:1]-[At:20]. Add a functional
spot-check asserting every entry fires and produces an astatine cap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
alkenyl_carboxylic_acid maps the beta-vinyl carbon as :4; caps omitting it
silently deleted :4 and everything beyond (cinnamic acid -> propionyl, phenyl
lost). Add =[A:4] to both alkenyl_acyl and alkenyl_decarboxy templates. Switch
the spot-check substrate to cinnamic acid and add a regression test asserting
the phenyl ring survives.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- FragmentResult now carries sticky_left ('-...') and sticky_right ('...-')
  aligned open-bond forms instead of a single [At]-anchored string, so
  fragments glue on either side; canonical_smiles keeps the [At] cap as key.
- locate the fresh astatine cap via max(mol) (transformer guarantees exactly
  one new [At], always the highest atom number) instead of scanning for an
  isotopeless At; drop the now-unused _new_astatine helper.
- sticky_linkers uses the same max() invariant for the 210/211 caps.
- skip disconnected products in sticky_fragments (salts/counter-ions) so one
  bad cut no longer aborts the whole generator; matches the linker guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
No cap rule disconnects a connected molecule (verified across all 68 role
entries), so a disconnected product can only come from a salt/mixture INPUT.
Replace the per-product connected_components_count checks with a single guard
on self at method entry in both sticky_fragments and sticky_linkers.

The flush_cache calls were dead: transformer output arrives with no cached
SMILES, and in the linker the isotope is set before any SMILES call, so no
stale cache can be read. Remove them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add _present_transformers(role, fgs) resolving a role selector to only the
(role, transformer) pairs whose handle FG is present in the molecule. Both
methods use it.

Linker no longer runs left transforms speculatively: capping a cut never
creates a coupling handle (verified across bifunctional test set -- only a
non-handle 'diaryl' match can appear), so every right handle must already be
in the source. Resolve both ends up front and bail before any transform work
when either end has no present handle -- monofunctional inputs now do zero
transform work instead of running every left cut to discover no right FG.

Update linker test for the open-bond sticky_smiles form (isotope caps live in
canonical_smiles, the dedup key).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When both cuts anchor on the same atom the linker collapses to a single core
carrying both caps (e.g. bromoacetic acid alkyl_halide + decarboxy -> [At]C[At],
malonic acid decarboxy + decarboxy -> [At]CH2[At]). Skip a right cut whose core
atom equals the left cap's core, so a linker always spans >=1 atom between its
two attachment points. Add regression test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
react/oxidize/reduce/transform (and ~/@ operators) now yield
EnumeratedReaction(name, reaction) instead of a bare (name, ReactionContainer)
tuple, matching the StickyFragment/StickyLinker style. Positional destructuring
(for name, rxn in ...) is unchanged. Export in __all__.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
deoxygenative_coupling now covers tertiary_alcohol (was primary/secondary
only), so tertiary ROH + ArX -> R-Ar is enumerated.

New deaminative_coupling: R-NH2 + ArX -> R-Ar. sp3 amines couple via
Katritzky pyridinium salts (alpha-carbon to aryl halide, N leaves); anilines
via diazonium (Meerwein/Gomberg-Bachmann, aryl carbon to partner, N2 leaves).
Both directions map the amine carbon :2 onto the aryl halide :3 with N :1 as
the leaving group. Excluded from the BH aryl-bromide+primary-amine test where
it is a legitimate co-product.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ests

Sticky fragments and linkers are driven by the _roles.py glossary, not
_reactions.py, so the new deaminative coupling needed matching roles:
alkyl_deamino (primary_amine) and aryl_deamino (primary_aniline), both
dropping the nitrogen and capping the carbon -- parallel to the deoxy and
decarboxy handles. Tertiary-alcohol deoxy was already covered by alkyl_deoxy.

Added generous per-type reaction tests: tertiary/secondary deoxygenative
coupling across chloride/bromide/iodide, and deaminative coupling for both
alkyl amines and anilines across the halide series (buchwald_hartwig excluded
as a legitimate co-product). Added fragment tests for both deamino roles and
tertiary deoxy, and linker tests spanning deamino + acyl/halide handles.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@stsouko
stsouko merged commit fa3d174 into master Jul 27, 2026
@stsouko
stsouko deleted the sticky-fragments branch August 2, 2026 20:24
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.

1 participant