Lightweight validity check for a SMILES string — verifies the characters are legal and that parentheses/brackets are balanced. This is a cheap guard before a network call, not a real SMILES parser; chemically-invalid but syntactically-plausible strings still pass.
Extracts every SMILES structure embedded in a block of free text, in order of appearance. Each
candidate must contain a "strong" structural character (a bond, branch, bracket, or digit) so
ordinary words and chemical names are not misread as structures. Bracketed single atoms such as
[Na+] are returned, but bare single-character atoms are not (a stray P is not phosphorus).
Because SMILES branch parentheses are indistinguishable from prose parentheses, a structure
wrapped directly in text parentheses may include a trailing ).
Heuristically decides whether a raw query looks like a SMILES structure rather than a chemical
name or CAS number. Deliberately conservative: it only flags strong structural signals (bond/
branch/bracket characters, ring-closure digits) or pure organic-atom tokens of 3+ characters, so
ambiguous short tokens like CO and ordinary names stay on the normal name-search path.
Resolves a SMILES string to searchable identifiers (name, CAS, InChIKey) by querying NCI Cactus (which canonicalizes the structure server-side), falling back to a PubChem SDQ InChIKey lookup when Cactus yields no usable name or CAS. Returns undefined when no resolver recognizes the structure or the input is not a plausible SMILES.
Top-level entry that turns any search query into a term the existing supplier search can consume.
If the query is a structure (via smiles:/inchikey: prefix or the looksLikeSmiles
heuristic) it is resolved to the best searchable identifier (name preferred, CAS fallback) and
returned alongside the resolved structure metadata. Non-structure queries pass through unchanged.
Built for the future search wiring; currently invoked manually for testing.
The result of resolving a structure (SMILES or InChIKey) to searchable identifiers.
Strips an explicit
smiles:orinchikey:prefix from a query, letting the user force structure resolution for otherwise-ambiguous input (e.g.smiles:COinstead of carbon monoxide).