Type Definitions
-
ArrowSpec
-
Arrow shape specification. Extends ShapeSpec
Properties:
Name Type Description start$3Dmol.Vector3 end$3Dmol.Vector3 radiusnumber radiusRationumber ratio of arrow base to cylinder (1.618034 default)
midnumber relative position of arrow base (0.618034 default)
-
AtomSelectionSpec
-
Atom selection object. Used to specify what atoms should be selected. Can include
any field from AtomSpec in which case atoms must equal the specified value.
All fields must match for the selection to hold. If values
are provided as a list, then only one value of the list must match.Properties:
Name Type Description ...AtomSpec any field from AtomSpec, values may be singletons or lists. Integer numerical ranges are supported as strings.
modelGLModel a single model or list of models from which atoms should be selected. Can also specify by numerical creation order. Reverse indexing is allowed (-1 specifies last added model).
bondsnumber overloaded to select number of bonds, e.g. {bonds: 0} will select all nonbonded atoms
predicatefunction user supplied function that gets passed an {AtomSpec} and should return true if the atom should be selected
invertboolean if set, inverts the meaning of the selection
byresboolean if set, expands the selection to include all atoms of any residue that has any atom selected
expandnumber expands the selection to include all atoms within a given distance from the selection
withinWithinSelectionSpec intersects the selection with the set of atoms within a given distance from another selection
andArray.<AtomSelectionSpec> take the intersection of the provided lists of {AtomSelectionSpec}s
orArray.<AtomSelectionSpec> take the union of the provided lists of {AtomSelectionSpec}s
notAtomSelectionSpec take the inverse of the provided {AtomSelectionSpec}
Example
$3Dmol.download("pdb:2EJ0",viewer,{},function(){ viewer.setStyle({chain:'B'},{cartoon:{color:'spectrum'}}); viewer.setStyle({chain:'B',invert:true},{cartoon:{}}); viewer.setStyle({bonds: 0},{sphere:{radius:0.5}}); //water molecules viewer.setStyle({resn:'PMP',byres:true,expand:5},{stick:{colorscheme:"greenCarbon"}}); viewer.setStyle({resi:["91-95","42-50"]},{cartoon:{color:"green",thickness:1.0}}); viewer.render(); }); -
AtomSpec
-
Atom representation. Depending on the input file format, not all fields may be defined.
Properties:
Name Type Description resnstring Parent residue name
xnumber Atom's x coordinate
ynumber Atom's y coordinate
znumber Atom's z coordinate
colorColorSpec Atom's color, as hex code or built-in color string
surfaceColorColorSpec Hex code for color to be used for surface patch over this atom
elemstring Element abbreviation (e.g. 'H', 'Ca', etc)
hetflagboolean Set to true if atom is a heteroatom
chainstring Chain this atom belongs to, if specified in input file (e.g 'A' for chain A)
resinumber Residue number
icodenumber rescodenumber serialnumber Atom's serial id number
atomstring Atom name; may be more specific than 'elem' (e.g 'CA' for alpha carbon)
bondsArray.<number> Array of atom ids this atom is bonded to
ssstring Secondary structure identifier (for cartoon render; e.g. 'h' for helix)
singleBondsboolean true if this atom forms only single bonds or no bonds at all
bondOrderArray.<number> Array of this atom's bond orders, corresponding to bonds identfied by 'bonds'
propertiesObject Optional mapping of additional properties
bnumber Atom b factor data
pdblinestring If applicable, this atom's record entry from the input PDB file (used to output new PDB from models)
clickableboolean Set this flag to true to enable click selection handling for this atom
callbackfunction Callback click handler function to be executed on this atom and its parent viewer
invertboolean for selection, inverts the meaning of the selection
-
AtomStyleSpec
-
Properties:
Name Type Description lineLineStyleSpec draw bonds as lines
crossCrossStyleSpec draw atoms as crossed lines (aka stars)
stickStickStyleSpec draw bonds as capped cylinders
sphereSphereStyleSpec draw atoms as spheres
cartoonCartoonStyleSpec draw cartoon representation of secondary structure
-
BoxSpec
-
Box shape specification. Extends ShapeSpec
Properties:
Name Type Description corner$3Dmol.Vector3 bottom corner of box
center$3Dmol.Vector3 alternative to corner: center of box
dimensionsObject {w:width, h:height, d:depth}; can be either scalars or vectors (for not-axis aligned boxes)
-
CartoonStyleSpec
-
Properties:
Name Type Description colorColorSpec strand color, may specify as 'spectrum' which will apply reversed gradient based on residue number
stylestring style of cartoon rendering (trace, oval, rectangle
(default), parabola, edged)ribbonboolean whether to use constant strand width, disregarding
secondary structure; use thickness to adjust radiusarrowsboolean whether to add arrows showing beta-sheet
directionality; does not apply to trace or ribbontubesboolean whether to display alpha helices as simple cylinders;
does not apply to tracethicknessnumber cartoon strand thickness, default is 0.4
widthnumber cartoon strand width, default is secondary
structure-dependent; does not apply to trace or ribbonopacitynumber set opacity from 0-1; transparency is set per-chain
with a warning outputted in the event of ambiguityInnucleic acids, the base cylinders obtain their color from the
atom to which the cylinder is drawn, which is 'N1' for purines (resn:
'A', 'G', 'DA', 'DG') and 'N3' for pyrimidines (resn: 'C', 'U', 'DC',
'DT'). The different nucleobases can therefore be distinguished as
follows:Example
$3Dmol.download("pdb:4ZD3",viewer,{},function(){ viewer.setBackgroundColor(0xffffffff); viewer.setViewStyle({style:"outline"}); viewer.setStyle({},{cartoon:{}}); viewer.render(); }); -
ColorschemeSpec
-
Properties:
Name Type Description string color>Carbon - use default element colors but with carbon set to specify html color string
ssPyMOLstring PyMol secondary colorscheme
ssJmolstring Jmol secondary colorscheme
Jmolstring Jmol primary colorscheme
defaultstring default colorscheme
aminostring amino acid colorscheme
shapelystring shapely protien colorscheme
nucleicstring nucleic acid colorscheme
chainstring standard chain colorscheme
chainHetatmstring chain Hetatm colorscheme
propstring atomSpec property. Example 'b'. See AtomSpec.
gradientGradient Allows the user to provide a gradient to the colorsheme. See example #3.
mapobject map of a certain AtomSpec propery to a color.: {}} elementMap - Allows the user to provide a mapping of elements to colors to the colorscheme. This is shown in example #2 and it should be noted that this can be done with any properties, and not just 'elem'.
colorfuncfunction Allows the user to provide a function for setting the colorshemes.See example #4.
Example
//Using a function in order to define the colors. $3Dmol.download("pdb:4UAA",viewer,{},function(){ viewer.setBackgroundColor(0xffffffff); var colorAsSnake = function(atom) { return atom.resi % 2 ? 'white': 'green' }; viewer.setStyle( {chain:'A'}, { cartoon: {colorfunc: colorAsSnake }}); viewer.setStyle( {chain:'B'}, { stick: {colorscheme: 'yellowCarbon'}}); viewer.render(); }); -
ColorSpec
-
Color representation.
Properties:
Name Type Description 0xAF10ABstring any hex number
string color name>
-
CrossStyleSpec
-
Properties:
Name Type Description hiddenboolean do not show
linewidthnumber deprecated due to vanishing browser support
radiusnumber scalenumber scale radius by specified amount
colorschemeColorschemeSpec element based coloring
colorColorSpec fixed coloring, overrides colorscheme
-
CustomShapeSpec
-
Specification for adding custom shape. Extends ShapeSpec.
Properties:
Name Type Description vertexArrArray.<$3Dmol.Vector3> List of vertex positions
normalArrArray.<$3Dmol.Vector3> List of normal vectors for each vertex
faceArrArray.<number> List of triangles to build the custom shape. Each triangle is defined by the indices of 3 vertices in vertexArr, so the array length should be 3 times the number of faces.
colorColorSpec | Array.<ColorSpec> Either a single color for the whole object or an array specifying the color at each vertex.
-
CylinderSpec
-
Curve shape specification. Extends ShapeSpec
Properties:
Name Type Description ]$3Dmol.Vector3 points - list of (x,y,z) points to interpolate between to make curve
smoothnumber amount of interpolation
radiusnumber fromArrowboolean if an arrow should be drawn at the start
toArrowboolean if an arrow should be drawn at the end
-
CylinderSpec
-
Cylinder shape specification. Extends ShapeSpec
Properties:
Name Type Description start$3Dmol.Vector3 end$3Dmol.Vector3 radiusnumber fromCap$3Dmol.CAP 0 for none, 1 for flat, 2 for round
toCap$3Dmol.CAP 0 for none, 1 for flat, 2 for round
-
FileFormats
-
File formats supported by 3Dmol.js
Properties:
Name Type Description cdjson,jsonChemical JSON format
cubeGaussian cube format
groGromacs topology format, need to add coordinates to resulting model.
mcif,cifCrystallographic Information File, the successor to PDB that makes you miss the PDB file format
mmtfMacromolecular Transmission Format, the successor to PDB that is totally awesome
mol2Sybyl Mol2 format
pdbThe venerable Protein Data Bank format
pqrLike PDB but with partial charges which are read into the partialcharge atom property
prmtopAmber topology file, must add coordinates
sdfMDL MOL format, supports muliple models and meta data
vaspVASP format (CONTCAR, POSCAR)
xyzXYZ cartesian coordinates format
-
IsoSurfaceSpec
-
Isosurface style specification
Properties:
Name Type Description isovalnumber specifies the isovalue to draw surface at
colorColorSpec solid color
opacitynumber transparency, between 0 and 1
wireframeboolean draw as wireframe, not surface
linewidthnumber width of line for wireframe rendering No longer supported by most browsers
smoothnessnumber amount to smooth surface (default 1)
coordslist coordinates around which to include data; use viewer.selectedAtoms() to convert an AtomSelectionSpec to coordinates
seldistnumber distance around coords to include data [default = 2.0]
clickableboolean if true, user can click on object to trigger callback
callbackfunction function to call on click
-
LabelSpec
-
Label type specification
Properties:
Name Type Description fontstring font name, default sans-serif
fontSizenumber height of text, default 18
fontColorColorSpec font color, default white
fontOpacitynumber font opacity, default 1
borderThicknessnumber line width of border around label, default 0
borderColorColorSpec color of border, default backgroundColor
borderOpacitystring color of border
backgroundColorColorSpec color of background, default black
backgroundOpacitystring opacity of background, default 1
positionObject x,y,z coordinates for label
inFrontboolean always put labels in from of model
showBackgroundboolean show background rounded rectangle, default true
fixedboolean sets the label to change with the model when zooming
backgroundImageObject An element to draw into the label. Any CanvasImageSource is allowed.
alignmentstring how to orient the label w/respect to position: topLeft (default), topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, bottomRight
-
LineSpec
-
Line shape specification. Extends ShapeSpec (but defaults to wireframe)
Properties:
Name Type Description start$3Dmol.Vector3 end$3Dmol.Vector3 -
LineStyleSpec
-
Properties:
Name Type Description hiddenboolean do not show line
linewidthnumber deprecated due to vanishing browser support
colorschemeColorschemeSpec element based coloring
colorColorSpec fixed coloring, overrides colorscheme
-
ParserOptionsSpec
-
Parser options specification. Used to specify the options of a GLModel. Depending on the input file format, not all fields may be defined.
Properties:
Name Type Description duplicateAssemblyAtoms-boolean Set to true if you wish to diplicate assembly atoms otherwise false ; supported by all
framesboolean true if you want to add to a new frame and false otherwise ; supported by all
vibrateobject object specifying the vibration behavior ; supported by all
Properties
Name Type Description framesnumber number of frames to be created, default to 10 ; supported by all
amplitudenumber amplitude of distortion, default to 1 (full) ; supported by all
multimodelboolean specifies weather or not multiple models are being defined ; supported by xyz,sdf, or mol2
onemolboolean specifies weather or not the model is of one molecule ; Supported by xyz , sdf , mol2
keepHboolean do not strip hydrogens ; supported by sdf,mol2
parseStyleobject used to define ChemDoodle styles ; supported by cdjson
doAssemblyboolean boolean dictating weather or not to do assembly ; supported by mcif
noSecondaryStructureboolean boolean dictating the presence of a secondary structure ; supported by pdb
-
ShapeSpec
-
GLShape style specification
Properties:
Name Type Description colorColorSpec solid color
alphanumber transparency
wireframeboolean draw as wireframe, not surface
hiddenboolean if true, do not display object
linewidthnumber width of line for wireframe rendering No longer supported by most browsers
clickableboolean if true, user can click on object to trigger callback
callbackfunction function to call on click
-
SphereShapeSpec
-
Sphere shape specification. Extends ShapeSpec
Properties:
Name Type Description center$3Dmol.Vector3 radiusnumber -
SphereStyleSpec
-
Properties:
Name Type Description hiddenboolean do not show atom
radiusnumber override van der waals radius
scalenumber scale radius by specified amount
colorschemeColorschemeSpec element based coloring
colorColorSpec fixed coloring, overrides colorscheme
-
StickStyleSpec
-
Properties:
Name Type Description hiddenboolean do not show
radiusnumber singleBondsboolean draw all bonds as single bonds if set
colorschemeColorschemeSpec element based coloring
colorColorSpec fixed coloring, overrides colorscheme
-
SurfaceStyleSpec
-
Properties:
Name Type Description opacitynumber sets the transparency: 0 to hide, 1 for fully opaque
colorschemeColorschemeSpec element based coloring
colorColorSpec fixed coloring, overrides colorscheme
voldata$3Dmol.VolumeData volumetric data for vertex coloring
volscheme$3Dmol.Gradient coloring scheme for mapping volumetric data to vertex color
mapObject specifies a numeric atom property (prop) and color mapping (scheme) such as $3Dmol.Gradient.RWB. Deprecated, use colorscheme instead.
Example
var setStyles = function(volumedata){ var data = new $3Dmol.VolumeData(volumedata, "cube"); viewer.addSurface("VDW", {opacity:0.85, voldata: data, volscheme: new $3Dmol.Gradient.RWB(-10,10)},{chain:'A'}); viewer.mapAtomProperties($3Dmol.applyPartialCharges); viewer.addSurface($3Dmol.SurfaceType.SAS, {map:{prop:'partialCharge',scheme:new $3Dmol.Gradient.RWB(-.05,.05)}, opacity:1.0},{chain:'B'}); viewer.addSurface($3Dmol.SurfaceType.VDW, {opacity:0.85,voldata: data, color:'red'},{chain:'C'}); viewer.addSurface($3Dmol.SurfaceType.SAS, {opacity:0.85,voldata: data, colorscheme:'greenCarbon'},{chain:'D'}); viewer.render(); }; $3Dmol.download("pdb:4DLN",viewer,{},function(){ $.get("data/1fas.cube",setStyles); }); -
Vector3
-
3 dimensional vector
Properties:
Name Type Description xnumber x coordinate
ynumber y coordinate
znumber z coordinate
-
ViewerGridSpec
-
Grid GLViewer input specification
Properties:
Name Type Description rowsnumber number of rows in grid
colsnumber number of columns in grid
control_allboolean if true, mouse events are linked
-
ViewerSpec
-
GLViewer input specification
Properties:
Name Type Description defaultcolorsObject map of elements to colors
nomouseboolean if true, disable handling of mouse events
backgroundColorColorSpec color of background
-
WithinSelectionSpec
-
Within selection object. Used to find the subset of an atom selection that is within
some distance from another atom selection. When added as a field of an AtomSelectionSpec,
intersects the set of atoms in that selection with the set of atoms within a given
distance from the given AtomSelectionSpec.Properties:
Name Type Description distancenumber the distance in angstroms away from the atom selection to include atoms in the parent selection
invertboolean if set, selects atoms not within distance range for intersection
selAtomSelectionSpec the selection of atoms against which to measure the distance from the parent atom selection
Example
$3Dmol.download("pdb:2EJ0",viewer,{},function(){ viewer.setStyle({chain: 'A', within:{distance: 10, sel:{chain: 'B'}}}, {sphere:{}}); viewer.render(); });// stylizes atoms in chain A that are within 10 angstroms of an atom in chain B