Molecular Motion
Interactive and animated molecular biology visualization for the web.
Molecular Motion is an open-source TypeScript library for creating interactive and animated molecular biology visualizations with SVG. You describe a mechanism in YAML or JSON: the molecules that take part and what happens step by step. It draws the proteins, DNA, RNA, membranes and compartments, animates each step into the next, and gives you a player to navigate them.
A mechanism, drawn from its description
This is PARP1-mediated SSB repair, one of the examples. Step through it with the controls or the arrow keys. Nothing in it was drawn by hand: see how the DNA repair example is written.
What it draws
-
Proteins
Globular proteins, enzymes, complexes and membrane-spanning receptors, with their activity state, several copies of one protein, and interfaces between them.
-
DNA and RNA
A double helix with coordinates and strand polarity: breaks, lesions, resection, synthesis, unwinding, pairing between molecules, splicing and strand exchange.
-
Molecular interactions
Binding and release, recruitment, activation, inhibition, phosphorylation, ubiquitination, PARylation, cleavage, ligation, degradation and translocation.
-
Membranes and compartments
A lipid bilayer with proteins that span it, and bands for the nucleus, cytoplasm, ER, Golgi, mitochondrion, endosome or compartments you name.
-
Animation and interaction
Steps morph into one another instead of redrawing. A React player adds a timeline, playback, keyboard navigation and selectable molecules.
-
Figures for publication
Any step exports as a standalone SVG, or as PNG in the browser, in a light or dark theme. The same code runs in Node, without a browser.
Install
Three packages, versioned together. They are ES modules for Node.js 20 or newer and for any bundler.
npm install @molecular-motion/core @molecular-motion/svg # figures, with or without a browser
npm install @molecular-motion/core @molecular-motion/react # the React playerA mechanism is a list of actors and a list of steps. Each step is a list of actions on those actors:
schemaVersion: 7
mechanism: { id: nick-repair, name: Repair of a nick }
compartments: [nucleus]
actors:
- id: dna
type: dna
compartment: nucleus
nucleic: { length: 60 }
sites:
- { id: nick, at: 30, strand: top }
- id: ligase
type: protein
label: DNA ligase
compartment: nucleus
steps:
- id: damage
title: A nick appears
actions:
- { type: cleave, target: dna.nick, lesion: nick }
- id: repair
title: Ligase seals it
actions:
- { type: recruit, actor: ligase, target: dna.nick }
- { type: ligate, target: dna.nick, by: ligase }The React player turns that file into an animated figure with controls:
import { parseMechanism } from '@molecular-motion/core/yaml';
import { MolecularMechanism } from '@molecular-motion/react';
import source from './mechanism.yaml?raw'; // Vite; any way of reading the file as text works
export function Figure() {
return <MolecularMechanism definition={parseMechanism(source)} controls />;
}Without React, @molecular-motion/svg gives the SVG of any step as a string, in Node or in a browser. The README shows both, the language describes every part of a document, and Actions lists every action a step can contain.
What it is for
-
DNA repair visualization
Base excision repair, single-strand break repair and homologous recombination, lesion by lesion.
-
Protein–DNA interactions
Proteins that bind a site or coat a stretch of DNA, placed by coordinate.
-
Transcription and gene expression
A transcript that grows on its template, loses its intron and meets a ribosome in the cytoplasm.
-
Membrane receptor signalling
Ligand binding, dimerization and trans-phosphorylation of a receptor in the membrane.
-
Cell signalling
A signal followed across the cytosol, the ER, the Golgi and the nucleus.
-
Teaching molecular biology
Lectures, courses and textbooks online where a student steps through a mechanism at their own pace.
-
Scientific figures in SVG
Consistent, editable figures for a review, a thesis or a poster, kept in version control with the text.
Examples
Seven mechanisms come with the repository. Each one is a single YAML file.
-
DNA repair
Base excision repair of an oxidized base, and how PARP1 signals the single-strand break it leaves behind, as an animated SVG figure you can step through. The whole figure is generated from one YAML file.
-
Protein–DNA interactions
Proteins that bind, coat and leave a stretch of DNA, drawn where they sit on the molecule. The example is the repair of a double-strand break by homologous recombination, from the break to an intact chromatid.
-
Gene expression
A gene is transcribed into RNA, the intron is spliced out, and the mRNA reaches a ribosome in the cytoplasm. The transcript grows nucleotide by nucleotide on its template, and loses its intron without being redrawn as a new molecule.
-
Membrane receptor signalling
A receptor in a lipid bilayer binds its ligand outside the cell, dimerizes, and is phosphorylated inside it. The example is the activation of the EGF receptor, with every receptor and ligand drawn as an individual copy.
-
Cell signalling
A signal followed from its trigger to the nucleus: DNA in the cytosol, a second messenger, a membrane protein that changes compartment, a kinase and a transcription factor. The example is the cGAS–STING pathway of innate immunity.
-
A negative feedback loop
p53 turnover, the stress response and induction of its inhibitor MDM2.
-
Double Holliday junction
Second-end capture and resolution as a crossover by reconnecting strands.
What molecules do, not what they look like
Molecular Motion explains a mechanism: who binds whom, what is modified, what moves where, and in what order. It works at the level of a figure in a review or a slide in a lecture.
- It is not a molecular structure viewer. Tools such as Mol* and NGL show the three-dimensional structure of a molecule from atomic coordinates. Molecular Motion draws schematic molecules and does not read PDB files.
- It is not a pathway or network browser. Tools such as Cytoscape.js lay out graphs of many nodes and edges. Molecular Motion follows a few molecules through the steps of one mechanism.
- It is not a simulation. No kinetics, stoichiometry or physics are computed. The steps are the ones the author wrote, and the compiler checks that they are consistent.
- It is not a drawing tool. There is no canvas to draw on. The figure is generated from data, so it can be reviewed, versioned and changed like code.
Questions
- What is Molecular Motion?
- Molecular Motion is an open-source TypeScript library for creating interactive and animated molecular biology visualizations with SVG. You describe a mechanism in YAML or JSON, and it draws the molecules, animates each step and gives you a player to navigate them.
- What does it visualize?
- Molecular mechanisms: proteins, DNA, RNA, small molecules, complexes, membranes and cell compartments, and what happens between them step by step. Examples in the repository cover DNA repair, homologous recombination, transcription and splicing, receptor signalling and a feedback loop.
- Which language and technologies does it use?
- It is written in TypeScript and runs in any JavaScript project. Figures are SVG. The core and the renderer have no DOM dependency and run in Node; the player is a React component.
- Can it draw DNA, RNA and proteins?
- Yes. DNA and RNA are drawn as helices and strands with real coordinates and 5′→3′ polarity, and proteins as surfaces with their state, modifications and binding partners.
- Can it show molecular interactions?
- Yes. Binding, recruitment, activation, inhibition, post-translational modification, cleavage, ligation, synthesis, degradation and translocation are actions of the language, and each one is animated.
- Are the diagrams interactive?
- Yes. The React player has a step timeline, play and pause, keyboard navigation and selectable molecules. It respects the reduced-motion preference, and every figure carries a text alternative.
- How is it different from a molecular structure viewer?
- A structure viewer such as Mol* or NGL shows the three-dimensional structure of a molecule from its atomic coordinates. Molecular Motion shows what molecules do: a schematic, step-by-step account of a mechanism, at the level of a review figure. It does not read PDB files and is not a simulation.
Documentation and source
- The language: every part of a mechanism document.
- Actions: every action, with its fields.
- Visual language: the catalog of SVG primitives for proteins, nucleic acids, lesions, modifications and membranes.
- Playground: edit a YAML document and see the figure change.
- Source code on GitHub, and the packages on npm: core, svg and react.