CLI Reference
Overview
The momapy command-line interface (CLI) allows you to work with molecular maps directly from the command line without writing Python code. It supports SBGN-ML and CellDesigner map formats.
Available subcommands:
render— Render maps to image formats (SVG, PDF, PNG, PS, JPEG, WebP)export— Export maps back to their original format (useful for roundtrip testing)info— Print a summary of a map file's contentslist— List available readers, writers, renderers, colors, styles, or stylable attributestidy— Apply layout tidying operations (fit nodes, snap arcs, etc.)style— Bake CSS stylesheets into map data and output the styled mapvisualize— Open an interactive viewer in the default web browser
Synopsis
momapy render <input_file_path>... -o <output_file_path> [options]
momapy export [<input_file_path>] [-o <output_file_path>] [options]
momapy info [<input_file_path>] [options]
momapy list {readers,writers,renderers,colors,styles,attributes}
momapy tidy <operation> [<input_file_path>] [options]
momapy style [<input_file_path>] [options]
momapy visualize [<input_file_path>] [options]
Piping between commands
Every command that reads a map reads from stdin when no input file is given, and every command that writes a map writes to stdout when no output file is given. By default the map is passed as text in its own format and re-parsed by the next command:
The text keeps what the format can carry (annotations, notes, ids), as when writing to a file with -o.
With -P, commands pass a pickled ReaderResult instead: the result is passed unchanged and is not re-parsed, which is faster. -P reads stdin and writes stdout as a pickle, and has no effect on input files or on -o, so the same flag is used on every command of the chain:
Pickles are never detected automatically. When only one side of a command is a pickle, use -R pickle (pickle in) or -W pickle (pickle out):
Reading a pickle can run code: only read pickles from a trusted source.
Subcommand: render
Renders one or more molecular maps to an image file.
Arguments
| Argument | Description |
|---|---|
input_file_path |
One or more input file paths (SBGN-ML or CellDesigner format; reads from stdin if omitted) |
Options
| Option | Short | Description |
|---|---|---|
--output-file-path |
-o |
Output file path (required) |
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin as a pickled ReaderResult (faster for piping momapy commands); no effect on input files |
--renderer |
-r |
Renderer to use: svg-native, svg-native-compat, skia, cairo (auto-detected if omitted) |
--format |
-f |
Output format: svg, pdf, png, ps, jpeg, webp (inferred from extension if omitted) |
--multi-pages |
-m |
Render one map per page (for multi-input PDF) |
--to-top-left |
-l |
Move elements to the top-left of the page |
--tidy |
-t |
Tidy the map (reroute arcs, fit labels, etc.) |
--style-sheet-file-path |
-s |
Custom CSS style sheet file path (repeatable) |
--preset |
-p |
Built-in preset name (repeatable); see momapy list styles |
Renderer/Format Compatibility
| Format | svg-native | svg-native-compat | skia | cairo |
|---|---|---|---|---|
| SVG | ✓ | ✓ | ✓ | ✓ |
| ✗ | ✗ | ✓ | ✓ | |
| PNG | ✗ | ✗ | ✓ | ✓ |
| PS | ✗ | ✗ | ✗ | ✓ |
| JPEG | ✗ | ✗ | ✓ | ✗ |
| WebP | ✗ | ✗ | ✓ | ✗ |
Note: The svg-native and svg-native-compat renderers are always available and have no external dependencies; svg-native-compat converts filters (e.g. drop shadows) into a form that renders in older SVG viewers. The skia and cairo renderers require optional dependencies to be installed.
Examples
Basic rendering
Render an SBGN-ML file to SVG:
Render to PDF
Render to PDF (requires skia or cairo renderer):
Specify renderer explicitly
Force the use of a specific renderer:
Multiple input files
Render multiple maps into a single multi-page PDF:
Apply style sheets
Apply one or more CSS style sheets to customize the appearance:
Adjust layout position
Move all elements to the top-left corner of the output:
Installation
The CLI is installed automatically when you install MomaPy:
To use PDF, PNG, PS, JPEG, or WebP output formats, install the optional rendering dependencies:
Subcommand: export
Reads a map and writes it back in the same format. This is useful for roundtrip testing (read with the reader, write with the writer) and for applying transformations like tidying or styling before re-exporting.
Arguments
| Argument | Description |
|---|---|
input_file_path |
Input file path (SBGN-ML or CellDesigner format; reads from stdin if omitted) |
Options
| Option | Short | Description |
|---|---|---|
--output-file-path |
-o |
Output file path (default: stdout) |
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin and write stdout as a pickled ReaderResult (faster for piping momapy commands); no effect on input files or -o |
--writer |
-W |
Writer to use for the output (default: the format of the map), e.g. pickle |
--tidy |
-t |
Tidy the map (reroute arcs, fit labels, etc.) |
--to-top-left |
-l |
Move elements to the top-left of the page |
--style-sheet-file-path |
-s |
Custom CSS style sheet file path (repeatable) |
--preset |
-p |
Built-in preset name (repeatable); see momapy list styles |
Unless -W is given, the writer is inferred from the map type: SBGN maps are exported using the sbgnml writer, CellDesigner maps using the celldesigner writer. SBML is read-only and cannot be exported.
If no output file is specified, the map is written to standard output in its own format. Pass -P or -W pickle to write a pickled ReaderResult instead.
Examples
Export to stdout
Basic roundtrip
Export an SBGN-ML file:
Export a CellDesigner file:
Export with tidy
Tidy the map before exporting (reroute arcs, fit labels, etc.):
Apply style sheets
Apply a stylesheet before exporting:
Subcommand: info
Prints a summary of a map file's contents, including the map type, model element counts, and layout dimensions.
Arguments
| Argument | Description |
|---|---|
input_file_path |
Input file path (SBGN-ML or CellDesigner format; reads from stdin if omitted) |
Options
| Option | Short | Description |
|---|---|---|
--output-file-path |
-o |
Output file path (default: stdout) |
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin as a pickled ReaderResult (faster for piping momapy commands); no effect on input files |
--format |
-f |
Output format: text (default) or json |
Examples
Inspect an SBGN-ML file
JSON output
Inspect a CellDesigner file
Subcommand: list
Lists plugins, named colors, built-in style presets, or stylable attributes of a layout element class.
Arguments
| Argument | Description |
|---|---|
readers |
List available map readers |
writers |
List available map writers |
renderers |
List available renderers (with supported output formats) |
colors |
List all named colors (displayed in their own color) |
styles |
List built-in style presets |
attributes <class_path> |
List stylable attributes of a layout element class |
Examples
List available readers
List available writers
List available renderers
If a renderer's dependencies are not installed, it shows (not installed) instead of formats.
List named colors
Each color name is printed in its own color. Useful for picking values for fill, stroke, and similar properties in stylesheets.
List built-in style presets
Preset names can be passed to momapy style -p or to momapy render/momapy export/momapy visualize via --preset.
List stylable attributes of a class
Lists every attribute that can be targeted in a stylesheet for the given class. Pass --presentation-only to restrict the output to visual presentation attributes (fill, stroke, font, etc.).
Subcommand: tidy
Applies layout tidying operations to a map and outputs the result. Use a specific operation sub-command or all to run the full pipeline.
Synopsis
Operations
| Operation | Description |
|---|---|
all |
Apply all tidying operations in sequence |
fit-species |
Resize species nodes to fit their labels (CellDesigner only) |
fit-epns |
Resize entity pool nodes to fit their labels (SBGN only) |
fit-auxiliary |
Position and resize auxiliary elements (modifications/state variables/units of information) |
fit-complexes |
Resize complexes to fit their subunits |
fit-compartments |
Resize compartments to fit their content |
fit-submaps |
Resize submaps to fit their terminals (SBGN only) |
fit-layout |
Resize the overall layout to fit all elements |
snap-arcs |
Snap arc endpoints to node borders |
straighten-arcs |
Straighten near-horizontal and near-vertical arc segments (CellDesigner only) |
Options
All operations accept:
| Option | Short | Description |
|---|---|---|
--output-file-path |
-o |
Output file path (default: stdout) |
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin and write stdout as a pickled ReaderResult (faster for piping momapy commands); no effect on input files or -o |
--writer |
-W |
Writer to use for the output (default: the format of the map), e.g. pickle |
The all, fit-species, fit-epns, fit-auxiliary, fit-complexes, fit-compartments, fit-submaps, and fit-layout operations also accept:
| Option | Description |
|---|---|
--xsep <float> |
Horizontal padding (default: depends on operation and map type) |
--ysep <float> |
Vertical padding (default: depends on operation and map type) |
The fit-species, fit-epns, fit-auxiliary, fit-complexes, fit-compartments, and fit-submaps operations also accept:
| Option | Description |
|---|---|
--no-snap-arcs |
Do not snap arc endpoints to node borders after the operation (useful when chaining tidy operations; run tidy snap-arcs once at the end) |
The all and straighten-arcs operations also accept:
| Option | Description |
|---|---|
--angle-tolerance <float> |
Angle tolerance in degrees for straightening (default: 5.0) |
Examples
Apply all tidying operations
Fit entity pool nodes to their labels
Snap arc endpoints to node borders
Read from stdin and write to stdout (pipeline)
Subcommand: style
Applies CSS stylesheets (and/or built-in presets) to a map, baking the styles into the map data, and outputs the result. Multiple -s and -p flags can be interleaved; stylesheets are merged left-to-right (later rules override earlier ones).
Arguments
| Argument | Description |
|---|---|
input_file_path |
Input file path (reads from stdin if omitted) |
Options
| Option | Short | Description |
|---|---|---|
--output-file-path |
-o |
Output file path (default: stdout) |
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin and write stdout as a pickled ReaderResult (faster for piping momapy commands); no effect on input files or -o |
--writer |
-W |
Writer to use for the output (default: the format of the map), e.g. pickle |
--style-sheet-file-path |
-s |
Custom CSS file path (repeatable) |
--preset |
-p |
Built-in preset name (repeatable); see momapy list styles |
Examples
Apply a custom stylesheet
Apply a built-in preset
Combine a preset with a custom override
Read from stdin
Subcommand: visualize
Opens an interactive viewer for a molecular map in the default web browser. The viewer is a self-contained HTML page with the map rendered as inline SVG, featuring:
- Pan and zoom — click and drag to pan, scroll to zoom, double-click to reset
- Hover tooltips — hover over any element to see its type, layout ID, model ID, and label
- Click to inspect — click an element to pin its info in a bottom panel with selectable/copyable text
- Search — search by label or ID; matching elements and their descendants stay visible while everything else is dimmed. Press Enter to pan to the first match, Escape to clear.
- Keyboard shortcuts — Ctrl+F / Cmd+F to focus the search bar
Arguments
| Argument | Description |
|---|---|
input_file_path |
Input file path (SBGN-ML or CellDesigner format; reads from stdin if omitted) |
Options
| Option | Short | Description |
|---|---|---|
--reader |
-R |
Reader to use for the input (default: detected from the content). Pickle input is never detected: use -R pickle, or -P for stdin |
--pipe |
-P |
Read stdin as a pickled ReaderResult (faster for piping momapy commands); no effect on input files |
--tidy |
-t |
Tidy the map (reroute arcs, fit labels, etc.) |
--to-top-left |
-l |
Move elements to the top-left of the page |
--style-sheet-file-path |
-s |
Custom CSS style sheet file path (repeatable) |
--preset |
-p |
Built-in preset name (repeatable); see momapy list styles |
Examples
Basic visualization
Visualize with tidy and style sheet
Getting Help
Display help information: