Citing substances
A molecule in a standards document is a substance with identity, not glyphs. AsciiChem closes that loop: resolve an identifier, then emit a dataset-type Relaton bibitem for the source you choose to cite.
Resolve, then cite
Section titled “Resolve, then cite”substance = AsciiChem::Resolver.resolve(value: "50-78-2", convention: "cas")xml = AsciiChem::Citation.to_xml(substance) # Relaton <bibitem type="dataset">From the CLI:
asciichem cite --cas 50-78-2The bibitem carries the publisher, an accessed date from the
resolution’s provenance, a source-specific docidentifier (PubChem CID 2244, CAS RN 50-78-2), and every identifier as a keyword —
so a citation is machine-checkable against its InChIKey long after
the page numbers change.
Citing what you typed: @cite
Section titled “Citing what you typed: @cite”Attach the citation intent to the molecule itself. The @cite
property annotation names the source you want to cite, and the
molecule’s other identifiers say who to resolve it as:
CC(=O)OC1=CC=CC=C1C(=O)O @cas("50-78-2") @cite("pubchem")Then the bibitem is a function of the parse tree:
molecule = AsciiChem.parse(source).nodes.firstAsciiChem::Citation.for_molecule(molecule)# => [["pubchem", #<Relaton::Bibitem ...>]]for_molecule resolves via the strongest identifier available
(@cas, @inchikey, @inchi/@smiles, then names) and returns one
[source, bibitem] pair per cited source. Annotate once, cite
anywhere — the citation follows the molecule through every format.
One bibitem per (substance, source)
Section titled “One bibitem per (substance, source)”Two databases agreeing on a substance are still two different documents. Resolution is multi-source; citation is per-source — pick the sources you trust, cite each once.
Sources and licensing
Section titled “Sources and licensing”- PubChem is the default: keyless, permissive, and the bulk mirror of validated CAS RNs.
- CAS Common Chemistry is opt-in: its data is CC BY-NC 4.0, so the adapter never registers itself and every result carries the required attribution.
AsciiChem::Resolver.register(:common_chemistry, AsciiChem::Resolver::CommonChemistry)Results are cached in your user cache directory (TTL’d, attribution
included); --refresh bypasses the cache.