5 Commits
Author SHA1 Message Date
Geoff Hutchison 31c21cf4a8 Fix crashing test on Linux SWIG
- Bind the molecule to a local so the OBAtom* doesn't dangle
- Also fix a few null de-reference defensive tests in alias code

Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
2026-05-22 19:01:35 -04:00
Geoff Hutchison d0f4cf5ff8 Add debug for Python KET test
Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
2026-05-22 18:49:33 -04:00
Roman Shterenzon 152f4f6ead Add test, move KET alias expansion to the final reader mutation in
src/formats/json/ketformat.cpp, because AliasData::Expand deletes/replaces atoms.
2026-05-19 10:57:14 +03:00
Roman Shterenzon ab06499075 Improve KET round-trip fidelity and alias handling
Reject unsupported future KET major versions, preserve aromatic KET
bonds without forcing kekulization, and retain explicit
implicitHCount: 0 values across round-trips.

Expose KET atom aliases as Open Babel AliasData and add the -ia read
option to expand aliases where chemically meaningful. Update KET tests
to cover future-version rejection, explicit zero implicit H counts,
alias metadata, and structural ethanol reading.
2026-05-19 10:57:14 +03:00
Roman ShterenzonandClaude Opus 4.7 1933c9e39c Add Ketcher KET (JSON) chemical structure format
KET is Ketcher's native serialization format, also produced and consumed
by Indigo. This adds a read/write plugin under src/formats/json/.

Supports:
  - molecules (atoms, bonds, S-groups, R-group attachment sites,
    fragment-level properties, highlights)
  - reactions assembled from arrow + plus + molecule geometry via
    OBReactionFacade
  - verbatim preservation of unknown sections (monomers, monomer
    templates, V2 rich text, images, simpleObjects, monomer shapes,
    root.connections, root.annotation, ket_version)

The writer preserves the original \$ref names and root.nodes ordering
so a read/write round-trip on a Ketcher-produced file produces
near-identical output. S-group atom and bond indices are remapped
back to per-molecule-local KET indices.

Tested via 13 ctest cases (set(ketformat_parts 1..13)) and a pybind
test (test/testketformat.py) covering read, write, byte-stable double
round-trip, reaction assembly, per-component scoping of highlight and
properties, and passthrough preservation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 10:57:14 +03:00