-
Notifications
You must be signed in to change notification settings - Fork 0
Reference NGL
madscatt edited this page Jun 22, 2026
·
3 revisions
- NGL provides a WebGL based molecular viewer
- examples

- module json (note height & width must be specified, else the viewer will have no size):
...
,{
"role" : "output"
,"id" : "nglplot"
,"label" : "Example NGL"
,"type" : "ngl"
,"height" : "500px"
,"width" : "600px"
}
...
- executable JSON output
{
"loadname" : "myfile.pdb"
,"loadparams" : {
"ext" : "pdb"
,"name" : "a name"
,"asTrajectory" : true
}
,"representation" : "cartoon"
}
- executable JSON output with single-representation parameters
{
"loadname" : "myfile.pdb"
,"loadparams" : {
"ext" : "pdb"
,"asTrajectory" : true
}
,"representation" : "cartoon"
,"representationParams" : {
"colorScheme" : "bfactor"
}
}
- executable JSON output with multiple selection-specific representations
{
"loadname" : "myfile.pdb"
,"loadparams" : {
"ext" : "pdb"
,"asTrajectory" : true
}
,"representations" : [
{
"type" : "cartoon"
,"params" : {
"sele" : "all"
,"color" : "blue"
}
}
,{
"type" : "cartoon"
,"params" : {
"sele" : "bfactor > 0.5"
,"color" : "red"
}
}
]
}
- notes:
- Required:
- "loadname" is passed to stage.loadFile()
- Optional:
- "loadparams" is passed as the 2nd argument to stage.loadFile()
- "loadparams" : "ext" is an optional file extension to determine file type (if not specified in "loadname").
- "loadparams" : "name" is an optional name for the data
- "loadparams" : "asTrajectory" is optional, but required for multimodel PDB's to be used as trajectories
- "representation" is an optional startup representation
- default "cartoon"
- possibilities:
backbone
ball+stick
cartoon
contact
helixorient
hyperball
label
licorice
line
point
ribbon
rocket
rope
spacefill
surface
trace
tube
- "representationParams" is optional and is passed as the 2nd argument to `component.addRepresentation( type, params )`
- use this when a single representation needs parameters such as `colorScheme`
- "representations" is an optional array of objects with:
- "type" passed as the 1st argument to `component.addRepresentation()`
- "params" passed as the 2nd argument to `component.addRepresentation()`
- when present, `representations` is used instead of the single `representation` / `representationParams` form
- dynamic updates reload the current structure in the existing NGL widget
- this supports refreshed snapshots during a run
- it is not a true coordinate streaming transport
- TO DO:
- add trajectory controls