Concepts¶
Document structure¶
A document is one JSON object, and its Root says what the document contains:
root.nodeslists what the document shows. Molecules, R-groups, monomers and monomer shapes are stored under top-level keys of their own and appear inroot.nodesas references such as{"$ref": "mol0"}. Arrows, pluses, shapes, texts and images are written inline.root.connectionsholds the bonds that are not edges of a single molecule: bonds between monomers, between monomers and atoms, and haptic bonds.root.templateslists the monomer templates the document uses. The templates themselves are stored under top-level keys, like molecules.
References¶
Reference |
Points to |
Written as |
|---|---|---|
an element of |
an object under a top-level key |
|
a bond, an S-group, an attachment group |
atoms of the same molecule |
integer indexes into the molecule’s |
a haptic endpoint |
an atom or an attachment group of a molecule |
|
Keys are resolved by name. A reference to a key the document does not have makes the document invalid.
Coordinates¶
Positions are in KET length units. Writers lay structures out with a standard bond length of 1.0.
The y axis points up: a larger
yis higher on the canvas.One position is the exception: the Stereo flag position of a molecule is measured with the y axis pointing down.
Positions have three coordinates,
[x, y, z];zis 0 in a two-dimensional drawing.
Versions¶
This reference describes version 2.0.0, which a document declares as "ket_version": "2.0.0" at the top level; a document without ket_version follows version 1.0.0. KET 1.0 and 2.0 differ only in text: KET 1.0 writes a text as a serialised Draft.js document in a data key (KET 1.0 text), KET 2.0 as the structured Text object. Versioning says what a version number means and how writers and readers use it.
Query documents¶
Keys marked Query describe search constraints rather than a structure. A document that uses any of them describes a query molecule. A reader that cannot represent queries may reject such a document.
Rules for writers¶
Write UTF-8 JSON that starts with
{, with no byte-order mark or whitespace before it.Write
"ket_version": "2.0.0", and only what version 2.0.0 has (Versioning).Write only the keys this reference lists, and omit a key whose value is its default.
Write an integer as a plain JSON integer —
1, not1.0or"1"— except where a key is defined as a string that holds a number, such asatomId.List every molecule, R-group, monomer and monomer shape in
root.nodes, and every template inroot.templates.Number molecule keys from
mol0in the order in whichroot.nodeslists the molecules.
Rules for readers¶
Where a number is expected, accept integer and fractional notation alike:
0and0.0are the same value.Resolve
$refandmoleculeIdby key, not by the position of a node inroot.nodes.Read
ket_versionfirst and act on it as Versioning says; a document without it is KET 1.0.A key this reference does not list carries no meaning; a reader may ignore it or reject the document. In a document of a later minor version a reader skips it (Versioning).