Skip to content

Molecule annotations

Molecule annotations attach CML metadata to a molecule using the @key("value") suffix. Multiple annotations can be chained.

A @smiles("...") annotation standing alone is an ingest edge: the annotation carries a structure in, and the model is the molecule the runtime’s own SMILES reader produces — renderable, citable, and identity-deriving like any other structure (grammar v0.6.0).

Source Rendered
@smiles("c1cc[nH]c1")
Install the asciichem gem to see this rendered.

Pyrrole, ingested locally: the SMILES is parsed at read time, the connection table lands on the model (aromatic atoms, bonds, the bracket hydrogen), and every formatter and the identity engine see an ordinary molecule.

  • The attached form (molecule @smiles("...")) is different and unchanged: there the annotation is the identifier annotation documented below — the string rides the model as identifier data, the drawn atoms stay the structure.
  • The reference syntax itself is an ingest boundary: the canonical text of @smiles("CCO") is the expanded C-C-O — the same posture as molfile and SMILES file ingest.
  • v1 carries smiles only. A standalone @molfile("...") rejects at parse time; later sources join as data.
Source Rendered
H_2O @name("Water")
Install the asciichem gem to see this rendered.

Maps to CML <name>Water</name>.

Known identifier types (inchi, smiles, cas, iupac, cid, chebi) map to CML <identifier convention="...">:

Source Rendered
C @inchi("InChI=1/C") C @smiles("C") C @cas("74-82-8")
Install the asciichem gem to see this rendered.
Source Rendered
H_2O @title("water molecule")
Install the asciichem gem to see this rendered.

Sets the CML title attribute on <molecule>.

Source Rendered
H_2O @formula("H 2 O 1")
Install the asciichem gem to see this rendered.

Maps to CML <formula concise="H 2 O 1"/>.

Source Rendered
H_2O @label("solvent")
Install the asciichem gem to see this rendered.

Maps to CML <label value="solvent"/>.

Any annotation key that isn’t a known type (name, title, formula, label, or identifier convention) becomes a CML property. Property titles are lowercase (logp, not logP):

Source Rendered
H_2O @mw("18.015") H_2O @density("0.997") H_2O @logp("-0.5")
Install the asciichem gem to see this rendered.

Maps to CML <property title="mw"><scalar>18.015</scalar></property>.

@cite("source") is a property annotation (title cite) that names the resolver source a substance should be cited from. It chains like any annotation and round-trips like any annotation:

Source Rendered
CC(=O)OC1=CC=CC=C1C(=O)O @cas("50-78-2") @cite("pubchem")
Install the asciichem gem to see this rendered.

The annotation itself carries no citation — the citation builder resolves the molecule’s identifiers against the named source and emits a dataset-type bibitem. See Citing substances.

Key-value metadata pairs using @meta("key","value"):

Source Rendered
H_2O @meta("creator","asciichem") H_2O @meta("source","NIST")@meta("year","2024")
Install the asciichem gem to see this rendered.

Chain annotations without spaces between them:

Source Rendered
H_2O @name("Water")@inchi("InChI=1/H2O/h1H2")@cas("7732-18-5")
Install the asciichem gem to see this rendered.

All annotations survive AsciiChem → CML → AsciiChem round-trip without loss. Names, identifiers, title, formulas, labels, and properties use native CML elements. Metadata and AsciiChem-specific fields ride via the aci: extension namespace.

Play