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.

InstallOpen the viewerGitHub

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.

PARylationActivated PARP1 consumes NAD+ to build negatively charged poly(ADP-ribose) chains on itself. Shown: PARP1 (active, bound to DNA (lesion), carrying PAR). Lesions: Single-strand break (SSB) at DNA (lesion).
PARP1-mediated SSB repair: PARylation.

What it draws

Install

Three packages, versioned together. They are ES modules for Node.js 20 or newer and for any bundler.

Terminal
npm install @molecular-motion/core @molecular-motion/svg     # figures, with or without a browser
npm install @molecular-motion/core @molecular-motion/react   # the React player

A mechanism is a list of actors and a list of steps. Each step is a list of actions on those actors:

mechanism.yaml
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:

Figure.tsx
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

Examples

Seven mechanisms come with the repository. Each one is a single YAML file.

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.

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.