Skip to main content

JSON Pipeline Format

Pipelines serialize to the SerializedPipeline v3 JSON format. This format is used by:

  • The VSCode extension (megane.json files)
  • The pipeline editor (import/export)
  • The TypeScript pipe.toObject() / pipe.toJSON() methods
  • The Python pipe.to_dict() method

JSON pipelines can be saved, shared, and version-controlled. You can write them by hand or generate them from Python or TypeScript.

For real-world examples, see the Gallery.

Format

{
"version": 3,
"nodes": [
{
"id": "s1",
"type": "load_structure",
"position": { "x": 0, "y": 0 },
"fileName": "protein.pdb",
"fileUrl": "protein.pdb",
"hasTrajectory": false,
"hasCell": false
},
{
"id": "ab1",
"type": "add_bond",
"position": { "x": 0, "y": 150 },
"bondSource": "distance"
},
{
"id": "v1",
"type": "viewport",
"position": { "x": 0, "y": 300 },
"perspective": false,
"cellAxesVisible": false,
"pivotMarkerVisible": false
}
],
"edges": [
{ "source": "s1", "target": "ab1", "sourceHandle": "particle", "targetHandle": "particle" },
{ "source": "s1", "target": "v1", "sourceHandle": "particle", "targetHandle": "particle" },
{ "source": "ab1", "target": "v1", "sourceHandle": "bond", "targetHandle": "bond" }
]
}

Top-level Fields

FieldTypeDescription
versionnumberAlways 3 for the current format
nodesarrayArray of node objects
edgesarrayArray of edge objects connecting nodes

Node Fields

Every node has the following common fields:

FieldTypeDescription
idstringUnique node identifier
typestringNode type (see below)
position{ x, y }Position in the pipeline editor canvas
enabledboolean?Optional. Set to false to bypass this node (default: true)

Node Types and Parameters

load_structure

FieldTypeDescription
fileNamestringDisplay name of the file
fileUrlstringPath or URL to the structure file
hasTrajectorybooleanWhether the file contains trajectory data
hasCellbooleanWhether the file contains unit cell data

load_trajectory

FieldTypeDescription
fileNamestringDisplay name of the trajectory file
fileUrlstringPath or URL to the trajectory file

streaming

No additional parameters.

load_vector

FieldTypeDescription
fileNamestringPath to vector data file

filter

FieldTypeDescription
querystringAtom selection query
bond_querystring?Bond selection query

modify

FieldTypeDescription
scalenumberAtom sphere radius multiplier (0.1–2.0)
opacitynumberTransparency (0–1)

add_bond

FieldTypeDescription
bondSourcestring"distance" or "structure"

label_generator

FieldTypeDescription
sourcestring"element", "resname", or "index"

polyhedron_generator

FieldTypeDescription
centerElementsnumber[]Atomic numbers of center atoms
ligandElementsnumber[]Atomic numbers of ligand atoms
maxDistancenumberMaximum center–ligand distance (Å)
opacitynumberFace transparency (0–1)
showEdgesbooleanDisplay wireframe edges
edgeColorstringWireframe edge color (hex)
edgeWidthnumberWireframe edge width (px)

vector_overlay

FieldTypeDescription
scalenumberVector arrow length multiplier

viewport

FieldTypeDescription
perspectivebooleanPerspective / orthographic projection
cellAxesVisiblebooleanShow unit cell axes
pivotMarkerVisiblebooleanShow rotation pivot marker

Edge Fields

FieldTypeDescription
sourcestringSource node id
targetstringTarget node id
sourceHandlestringOutput port name (e.g., "particle", "bond", "mesh")
targetHandlestringInput port name (e.g., "particle", "bond", "in")

Example: Crystal with Polyhedra

{
"version": 3,
"nodes": [
{
"id": "s1",
"type": "load_structure",
"position": { "x": 0, "y": 0 },
"fileName": "perovskite_srtio3_3x3x3.xyz",
"fileUrl": "perovskite_srtio3_3x3x3.xyz",
"hasTrajectory": false,
"hasCell": true
},
{
"id": "ab1",
"type": "add_bond",
"position": { "x": -170, "y": 310 },
"bondSource": "distance"
},
{
"id": "poly1",
"type": "polyhedron_generator",
"position": { "x": 170, "y": 310 },
"centerElements": [22],
"ligandElements": [8],
"maxDistance": 2.5,
"opacity": 0.5,
"showEdges": true,
"edgeColor": "#dddddd",
"edgeWidth": 2
},
{
"id": "v1",
"type": "viewport",
"position": { "x": 0, "y": 615 },
"perspective": false,
"cellAxesVisible": true,
"pivotMarkerVisible": true
}
],
"edges": [
{ "source": "s1", "target": "ab1", "sourceHandle": "particle", "targetHandle": "particle" },
{ "source": "s1", "target": "poly1", "sourceHandle": "particle", "targetHandle": "particle" },
{ "source": "s1", "target": "v1", "sourceHandle": "particle", "targetHandle": "particle" },
{ "source": "s1", "target": "v1", "sourceHandle": "cell", "targetHandle": "cell" },
{ "source": "ab1", "target": "v1", "sourceHandle": "bond", "targetHandle": "bond" },
{ "source": "poly1", "target": "v1", "sourceHandle": "mesh", "targetHandle": "mesh" }
]
}

Example: Atom Filter with Branching

{
"version": 3,
"nodes": [
{
"id": "s1",
"type": "load_structure",
"position": { "x": 170, "y": 0 },
"fileName": "caffeine_water.pdb",
"fileUrl": "caffeine_water.pdb",
"hasTrajectory": false,
"hasCell": false
},
{
"id": "fc1",
"type": "filter",
"position": { "x": 0, "y": 150 },
"query": "index < 24"
},
{
"id": "mc1",
"type": "modify",
"position": { "x": 0, "y": 300 },
"scale": 3.0,
"opacity": 1.0
},
{
"id": "fw1",
"type": "filter",
"position": { "x": 340, "y": 150 },
"query": "index >= 24"
},
{
"id": "mw1",
"type": "modify",
"position": { "x": 340, "y": 300 },
"scale": 1.0,
"opacity": 0.15
},
{
"id": "v1",
"type": "viewport",
"position": { "x": 170, "y": 450 },
"perspective": false,
"cellAxesVisible": false,
"pivotMarkerVisible": false
}
],
"edges": [
{ "source": "s1", "target": "fc1", "sourceHandle": "particle", "targetHandle": "in" },
{ "source": "fc1", "target": "mc1", "sourceHandle": "out", "targetHandle": "in" },
{ "source": "mc1", "target": "v1", "sourceHandle": "out", "targetHandle": "particle" },
{ "source": "s1", "target": "fw1", "sourceHandle": "particle", "targetHandle": "in" },
{ "source": "fw1", "target": "mw1", "sourceHandle": "out", "targetHandle": "in" },
{ "source": "mw1", "target": "v1", "sourceHandle": "out", "targetHandle": "particle" }
]
}