Skip to content

Add openclatura enricher for local SMILES-to-IUPAC naming - #87

Open
cmungall wants to merge 3 commits into
mainfrom
claude/openclatura-repo-vm0x1y
Open

Add openclatura enricher for local SMILES-to-IUPAC naming#87
cmungall wants to merge 3 commits into
mainfrom
claude/openclatura-repo-vm0x1y

Conversation

@cmungall

Copy link
Copy Markdown
Collaborator

Adds a new openclatura enricher plugin that derives systematic IUPAC
names directly from a molecule's structure using the openclatura package
(https://github.com/lamalab-org/openclatura), which walks the molecular
graph following IUPAC Blue Book 2013 rules.

Unlike the existing pubchem enricher, this needs no network access and
works for structures not present in any database. It fills the IUPAC_name
slot, and upgrades name only when it still holds a placeholder (e.g. the
empirical formula) so a better name from another enricher is never
clobbered.

Changes:

  • New OpenclaturaEnricher (src/chemrof/converter/enrichers/openclatura.py)
    with lazy, graceful import so it is a no-op when the optional package is
    not installed.
  • Registered openclatura in the enricher registry and documented it in
    the CLI --enrichers help text.
  • Declared openclatura as an optional dependency (pip install
    'chemrof[openclatura]'), marker-gated to python>=3.11 since openclatura
    requires it while chemrof still supports 3.10.
  • Tests: dedicated test_enricher_openclatura.py (naming-application logic
    runs without the optional package) plus registry coverage.

Signed-off-by: @dragon-ai-agent

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Nkkin3NwvuXRvuS5uka3CP

Adds a new `openclatura` enricher plugin that derives systematic IUPAC
names directly from a molecule's structure using the openclatura package
(https://github.com/lamalab-org/openclatura), which walks the molecular
graph following IUPAC Blue Book 2013 rules.

Unlike the existing `pubchem` enricher, this needs no network access and
works for structures not present in any database. It fills the IUPAC_name
slot, and upgrades `name` only when it still holds a placeholder (e.g. the
empirical formula) so a better name from another enricher is never
clobbered.

Changes:
- New OpenclaturaEnricher (src/chemrof/converter/enrichers/openclatura.py)
  with lazy, graceful import so it is a no-op when the optional package is
  not installed.
- Registered `openclatura` in the enricher registry and documented it in
  the CLI --enrichers help text.
- Declared `openclatura` as an optional dependency (pip install
  'chemrof[openclatura]'), marker-gated to python>=3.11 since openclatura
  requires it while chemrof still supports 3.10.
- Tests: dedicated test_enricher_openclatura.py (naming-application logic
  runs without the optional package) plus registry coverage.

Signed-off-by: @dragon-ai-agent

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nkkin3NwvuXRvuS5uka3CP
@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

Add the `openclatura` enricher to the hand-written source docs so it is
covered alongside the other enrichers:

- src/docs/cli.md: new row in the enricher table.
- src/docs/converter.md: new row in the "Available enrichers" table plus a
  short "Local IUPAC naming (openclatura)" usage section showing install,
  standalone use, and combined use with pubchem.

(docs/ is regenerated from src/docs by `make gendoc`, so only the sources
are edited here.)

Signed-off-by: @dragon-ai-agent

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nkkin3NwvuXRvuS5uka3CP
@claude

claude Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

Follow-up review pass on the openclatura enricher:

- OWL composition: the IUPAC_name slot carries an `owl: AnnotationAssertion`
  interpretation, so a name derived by the enricher flows straight into OWL
  output. Add a regression test asserting `AnnotationAssertion(chemrof:
  IUPAC_name ...)` appears, and document the `--format owl` composition in
  src/docs/converter.md. No wiring changes were needed for this to work.

- Warn-once: when the optional `openclatura` package is not installed, only
  emit the install hint on the first molecule instead of once per molecule,
  so batch conversions are not spammed. Point the hint at the extra
  (`pip install 'chemrof[openclatura]'`).

- Add a protocol-conformance test (isinstance check against Enricher).

Signed-off-by: @dragon-ai-agent

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nkkin3NwvuXRvuS5uka3CP
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

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