vibesketch.document.cdxml

CDXML, ChemDraw’s XML format: the whole drawing written and read (#24).

The private fixture writer (not a supported export API) writes CDXML drawings. Each connected molecule is a fragment of nodes and bonds at its drawn coordinates, with labels on its heteroatoms and a single charge as a symbol beside its atom. Arrows are arrow objects with their head and tail; equilibrium and retrosynthetic arrows are old-style graphic lines of those types, which every reader knows. Plus signs are graphic symbols, and each line of text is a t. A scheme holds a step per reaction derive reads, naming its reactants, products and arrow, and the reagents and texts above and below the arrow; a retrosynthetic step names the precursors as its reactants. One KET bond length is the style preset’s bond length in points (14.4 for ACS 1996), y points down as CDXML’s does, and the document settings (bond length and spacing, line widths, label font and size) are the preset’s.

Import reads the same objects back. Molecules go through RDKit’s CDXML reader, which expands nicknames and takes stereochemistry from wedges and double-bond geometry; their coordinates are kept. Arrows, plus signs and texts are read from the XML. The reactions are then derived from the drawing, as for any drawing, and a file’s scheme is a check: a step the drawing does not read the same way, and every object left out, is reported as a warning.

Sources: CambridgeSoft, ChemDraw SDK, the CDX/CDXML format specification (objects, properties and their values), mirrored at https://chemapps.stolaf.edu/iupac/cdx/sdk/. The arrow object is newer than that specification; its attributes follow the files ChemDraw writes, as EPAM Indigo’s CDXML writer (Apache-2.0) reproduces them.

Functions

read_cdxml(data)

A CDXML file as a KET drawing, and warnings about what did not carry over.

Exceptions

CdxmlRefused

The drawing cannot be written as CDXML.

CdxmlUnreadable

The data is not CDXML this reader can use.

exception vibesketch.document.cdxml.CdxmlUnreadable[source]

Bases: ValueError

The data is not CDXML this reader can use.

vibesketch.document.cdxml.read_cdxml(data)[source]

A CDXML file as a KET drawing, and warnings about what did not carry over.

Raises CdxmlUnreadable.

Parameters:

data (str | bytes)

Return type:

tuple[dict[str, Any], list[str]]