Repository navigation
Project Format
A FormChem drawing is a .fchem file: a zip package with MIME type application/x-formchem. The full contract (every field, the style sheet, the ops and transactions, validation and coalescing) is docs/FORMAT.md. This page is the short tour.
| Entry | What it is |
|---|---|
mimetype |
application/x-formchem, the first entry, stored uncompressed |
document.json |
The document: pages, structures, text and their styles, UTF-8 |
media/[id].[ext] |
Pictures placed in the document, and from 0.9.0 and 0.10.0 the JCAMP-DX, PDB, mmCIF and 3D SD files kept byte for byte with their spectrum and 3D objects |
thumbs/page-[n].png |
Optional page previews, 512 px on the longer side (the 0.12.0 window does not write them yet, so Home shows a placeholder) |
The engine writes the package to a temporary file in the same folder and renames it into place, so a failed save never leaves half a file. Readers ignore entries they do not know. When the code disagrees with FORMAT.md, the code is the bug, and a format change updates FORMAT.md, the window model (frontend/src/engine/model.ts) and the engine model (backend/app/services/model.py) together.
- Units are points (1/72 inch); x runs right, y runs down; angles are degrees counter-clockwise as the person sees the page.
-
stylenames a preset (journal-1996by default: bond length 14.4 pt, line width 0.6 pt, bold width 2.0 pt, Arimo labels at 10 pt) and any fields set on top of it. New drawings take the preset and the numbers from Preferences > Drawing. -
pagesis a list; each page has a size, margins and anorderof object ids. -
objectsis a map by id. A fragment (kind: "fragment") holdsatomsandbondsmaps; text objects carry runs of styled text. - Ids are short random strings, stable for life and never reused in a document. Agents, extensions and the renderer address everything by id.
- From 0.5.0 the other object kinds are drawn:
arrow(15 types, heads at either end, a signedbend, andanchorsthat tie an end to an atom, a lone pair, a bond or the space between two atoms),plus,bracket,shape,line,table,tlc,orbital,imageandcaption. Agrouplists itschildrenback to front; members are in no pageorder. - A
captionhas atarget(the structure it belongs to) and anoffsetfrom the target's bottom centre; itsx,yare a cache kept in step whenever the target or the caption moves. Compound numbers arenumber: {auto: true, value: "1"}. -
page.reactionslists reactions and their steps: the arrow, the reactant, product, agent and condition object ids,explicit(roles set by hand or by a file, kept by perception), optionalcoefficients, and optionalstoich, the amounts you typed in the Stoichiometry panel (scale_mmol,limiting,product,isolated_mg, and per componentequiv,mass_mg,volume_ml,density_g_ml,conc_m,purity_pct,mw). Moles, masses implied by equivalents, the limiting reagent and yields are worked out, never stored. Atablewithstoich: {reaction, step}is a stoichiometry grid. Atom map numbers aremapon atoms and reacting marksreactingon bonds. - From 0.6.0 a fragment may carry
stereo_groups(enhanced stereo:{kind: "abs"},{kind: "and", n: 1, atoms: [...]},{kind: "or", n: 2, atoms: [...]}) andchiral(absolute,relativeorracemic). For the chemistry,relativeputs every stereocentre in no group into one OR group andracemicinto one AND group, each with the next free number;absolutealso sets the molfile chiral flag. - An atom's
queryholds its query features:listandnot,generic(A, AH, Q, QH, X, XH, M, MH),ring_bonds,subst,unsat,h_min,aromatic, and from 0.6.0smarts, the SMARTS text of an atom query the other fields cannot express (SMARTS import writes it; it wins over the other fields). A bond'squeryisany,single_or_double,single_or_aromaticordouble_or_aromatic, andtopologyisringorchain. -
rgroupson a scaffold fragment define its R-groups by number:members(fragment ids),occurrence,rest_h,if_then, andattach, a map of member fragment id to its attachment atom ids. A member without anattachentry attaches at its atoms withdata.attach1 or 2, else at its*stubs (no label, one bond, standing for the R atom), else at its first atom. -
expansionshold what an abbreviation atom stands for (its atoms, bonds, attachment atoms and reversed label);sourceisbuiltinwhen the expansion came from the shipped library anduserotherwise. -
mediamaps a media id to{name, mime, bytes, w, h, sha256}; animageobject names the id. The bytes go into the package asmedia/[id].[ext], and only ids listed inmediaare written. - From 0.7.0
style.gridmay hold the drawing's page grid:{type, spacing, major, strength}, wheretypeislines,dots,crosses,isometric,isometric-dots,hexorhex-dotsandspacingis points or"bond"(the bond length). It is read only from the document's own style, never from presets or an object's style, and it changes only the screen and snapping, never exports or the chemistry. A drawing without it shows the window's default grid and saves unchanged. Whether the grid is shown and whether snapping is on belong to the window, not the file (Grid and Page). - From 0.9.0 a
spectrumobject holds a measured or predicted spectrum: its JCAMP-DX file kept byte for byte as media (or the prediction it came from), the range and y mode shown, and itspeaks,integralsandmultiplets, each of which may name the atoms it belongs to. Spectrum points are computed on request and never stored. - From 0.10.0 a fragment may carry
conformers, its 3D coordinates in ångström with the hydrogens, each with its energy, method and whether it converged, and amodel3dobject places a 3D view on the page: its source (a structure on the page or a PDB, mmCIF or 3D SD file kept as media), display style, surface, camera, focus, measurements and a PNG snapshot for exports. Editing a structure drops its conformers in the same transaction. -
meta.importedrecords a file opened from another format (name,format, and from 0.7.0report, the import report items).
The engine's chemistry (canonical SMILES, InChI and InChIKey, formula, masses, elemental analysis, implicit hydrogens, valence errors, warnings, from 0.5.0 the balance check of every reaction step, and CIP labels that follow the stereo groups and the chiral flag) is a derived cache. It is rebuilt when a drawing opens and broadcast after every change, keyed by fragment id and document revision, and never saved. Undo history is kept per open drawing by the engine and is not saved either.
Every change is a transaction: a list of set, ins, del and move ops on JSON paths into document.json, applied all or nothing, with the inverse ops kept for undo. One gesture, one command or one agent call is one transaction and one undo step. See Architecture for how a transaction travels from the window to the engine and back.
Molfile, SDF, RXN, RD, SMILES and CXSMILES, SMARTS, InChI, CML, CDXML and CDX files open as new, unsaved drawings laid out at the drawing's bond length; files with reactions open as drawn schemes with their roles set. From 0.7.0 a drawing exports to all of them (and InChIKey), each with a report of what the format could not keep, and to SVG, PNG, PDF and EPS pictures (Formats and Export). From 0.6.0 the engine also writes and reads V3000 molfiles with query features, enhanced stereo and R-group blocks, and SMARTS for query structures (Stereo and Queries); a molfile with its chiral flag at 0 opens with its centres absolute.
A picture exported with "Keep the editable drawing inside the file" carries a copy of the drawing in the same document.json form, holding one page and only the exported objects, with meta.embedded = {scope, from} (scope is page, selection or structure, from the source document's id). It sits in SVG metadata, a PNG iTXt chunk, an attached file drawing.fchem.json in PDF, or %FormChemSource: comment lines in EPS, always under the MIME type application/x-formchem+json. Placed pictures are left out of the copy, because their bytes are not carried. Opening such a picture gives a new document with new document and page ids, the file name as its title and the object ids kept. The FormChem clipboard form is the same document shape with meta.clipboard, and pasting gives every object fresh ids. Details are in docs/FORMATS.md. Templates use the document format too (docs/TEMPLATES.md).
FormChem
- Home
- Manual
- Getting Started
- Drawing
- Grid and Page
- Annotations
- Reactions
- Templates
- Printing and pages
- Keyboard Shortcuts
- Stereo and Queries
- Analysis
- Names
- Spectra and NMR
- 3D
- Databases
- Lab Notebook
- Biopolymers
- Live Structures
- Accessibility
- Formats and Export
- Clipboard
- Command Line
- Agents
- Agent Activity
- Terminal
- Extensions
- Project Format
- Architecture
- Desktop
- Troubleshooting
- Development
- Releasing
Documents