Members

(readonly) CAP

Enum for cylinder cap styles.

Properties
NameTypeDescription
NONE
FLAT
ROUND
Source

(constant) OFFSETS

(readonly) SurfaceType :number

Surface types

Type:
  • number
Properties
NameTypeDescription
VDW

van der Waals surface

MS

Molecular surface

SAS

Solvent accessible surface

SES

Solvent exposed surface

(constant) builtinColorSchemes

built in color schemes
The user can pass these strings directly as the colorscheme

Properties
NameTypeDescription
ssPyMol

pymol secondary structure

ssJmol

jmol secondary structure

Jmol

jmol element defaults

amino

amino acid coloring

shapely

amino acid coloring

nucleic

nucleic acid coloring

chain

color by chain

rasmol

rasmol default element coloring

default

default element coloring

greenCarbon

default element coloring with green carbon

cyanCarbon

default element coloring with cyan carbon

magentaCarbon

default element coloring with magenta carbon

purpleCarbon

default element coloring with purple carbon

whiteCarbon

default element coloring with white carbon

orangeCarbon

default element coloring with orange carbon

yellowCarbon

default element coloring with yellow carbon

blueCarbon

default element coloring with blue carbon

chainHetatm

color chains

Source
Example
window.$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();
 });

(constant) builtinGradients

built in gradient schemes
The user can pass these strings directly as the gradient

Properties
NameTypeDescription
rwb

red/white/blue, supports setting a mid point for white

roygb

rainbow

sinebow

rainbow with better saturation properties

linear

linearly maps between provided colors

(constant) dic

Parse a lammps trajectory file from str and create atoms

(constant) elementColors

Preset element coloring - from individual element colors to entire mappings (e.g. 'elementColors.Jmol' colors atoms with Jmol stylings)

Source

(constant) ssColors

Preset secondary structure color scheme

Source

syncSurface :boolean

Render surface synchronously if true

Type:
  • boolean

viewers

Contains a dictionary of embedded viewers created from HTML elements
with a the viewer_3Dmoljs css class indexed by their id (or numerically
if they do not have an id).

Methods

BCIF(bindata, ParserOptionsSpec)

Parameters:
NameTypeDescription
bindata

binary UInt8Array buffer or a base64 encoded string

ParserOptionsSpec

CDJSON(str, options)

This parses the ChemDoodle json file format. Although this is registered
for the json file extension, other chemical json file formats exist that
this can not parse. Check which one you have and do not assume that
.json can be parsed

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

CUBE(str, options)

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

GRO(str, options) → {Array.<Array.<AtomSpec>>}

Parse a gro file from str and create atoms

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec
Returns:
  • Returns a 2D array of type AtomSpec
Type: 
Array.<Array.<AtomSpec>>

MMTFparser(bindata, ParserOptionsSpec)

Parameters:
NameTypeDescription
bindata

binary UInt8Array buffer or a base64 encoded string

ParserOptionsSpec

MOL2(str, options)

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

PDB(str, options)

Parse pdb file from str and create atoms if computeStruct is true will always perform secondary structure analysis,
otherwise only do analysis of SHEET/HELIX comments are missing

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

keepH (do not strip hydrogens), noSecondaryStructure,
assignbonds (default true, calculate implicit bonds)
(do not compute ss), altLoc (which alternate location to select, if present; '*' to load all)

PQR(str, options)

Parse a pqr file from str and create atoms. A pqr file is assumed to be a whitespace delimited PDB with charge and radius fields.

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

noSecondaryStructure (do not compute ss)

PRMTOP(str, options)

Parse a prmtop file from str and create atoms

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

noSecondaryStructure (do not compute ss)

SDF(str, options)

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

VASP(str, options)

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

XYZ(str, options)

Read an XYZ file from str and return result

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

assignPDBBonds(atomsarray)

Parameters:
NameTypeDescription
atomsarrayArray.<AtomSpec>

conversionMatrix3(a, b, c, alpha, beta, gamma) → {Matrix3}

Parameters:
NameTypeDescription
anumber
bnumber
cnumber
alphanumber
betanumber
gammanumber
Returns:
Type: 
Matrix3

createViewer(element, configopt) → {GLViewer}

Create and initialize an appropriate viewer at supplied HTML element using specification in config

Parameters:
NameTypeAttributesDescription
elementObject | string

Either HTML element or string identifier

configViewerSpec<optional>

Viewer configuration

Returns:

GLViewer, null if unable to instantiate WebGL

Type: 
GLViewer
Example
var viewer = $3Dmol.createViewer(
     'gldiv', //id of div to create canvas in
     {
       defaultcolors: $3Dmol.elementColors.rasmol,
       backgroundColor: 'black'
     }
   );

createViewerGrid(element, configopt, viewer_configopt)

Create and initialize an appropriate a grid of viewers that share a WebGL canvas

Parameters:
NameTypeAttributesDescription
elementObject | string

Either HTML element or string identifier

configGridSpec<optional>

grid configuration

viewer_configViewerGridSpec<optional>

Viewer specification to apply to all subviewers

Returns:

[[GLViewer]] 2D array of GLViewers

Example
var viewers = $3Dmol.createViewerGrid(
     'gldiv', //id of div to create canvas in
     {
       rows: 2,
       cols: 2,
       control_all: true  //mouse controls all viewers
     },
     { backgroundColor: 'lightgrey' }
   );
   $3Dmol.get('data/1jpy.cif', function(data) {
     var viewer = viewers[0][0];
     viewer.addModel(data,'cif');
     viewer.setStyle({sphere:{}});
     viewer.zoomTo();
     viewer.render( );

     viewer = viewers[0][1];
     viewer.addModel(data,'cif');
     viewer.setStyle({stick:{}});
     viewer.zoomTo();
     viewer.render( );

     viewer = viewers[1][0];
     viewer.addModel(data,'cif');
     viewer.setStyle({cartoon:{color:'spectrum'}});
     viewer.zoomTo();
     viewer.render( );

     viewer = viewers[1][1];
     viewer.addModel(data,'cif');
     viewer.setStyle({cartoon:{colorscheme:'chain'}});
     viewer.zoomTo();
     viewer.render();


   });

decode()

Fixed point, delta, RLE, integer packing adopted from https://github.com/rcsb/mmtf-javascript/
by Alexander Rose alexander.rose@weirdbyte.de, MIT License, Copyright (c) 2016

download(query, viewer, options, callbackopt) → {GLModel}

Load a PDB/PubChem structure into existing viewer. Automatically calls 'zoomTo' and 'render' on viewer after loading model

Parameters:
NameTypeAttributesDescription
querystring

String specifying pdb or pubchem id; must be prefaced with "pdb: " or "cid: ", respectively

viewerGLViewer

Add new model to existing viewer

optionsObject

Specify additional options
format: file format to download, if multiple are available, default format is pdb
pdbUri: URI to retrieve PDB files, default URI is http://www.rcsb.org/pdb/files/

callbackfunction<optional>

Function to call with model as argument after data is loaded.

Returns:

GLModel, Promise if callback is not provided

Type: 
GLModel
Example
viewer.setBackgroundColor(0xffffffff);
       $3Dmol.download('pdb:2nbd',viewer,{onemol: true,multimodel: true},function(m) {
        m.setStyle({'cartoon':{colorscheme:{prop:'ss',map:$3Dmol.ssColors.Jmol}}});
       viewer.zoomTo();
       viewer.render(callback);
    });

fractionalToCartesian(str, options)

Puts atoms specified in mmCIF fromat in str into atoms

Parameters:
NameTypeDescription
strstring
optionsParserOptionsSpec

get(uri, callback)

Fetch data from URL

Parameters:
NameTypeDescription
uri

URL

callback

Function to call with data

getColorFromStyle(atom, style) → {Color}

Return proper color for atom given style

Parameters:
NameTypeDescription
atomAtomSpec
styleAtomStyle
Returns:
Type: 
Color

getbin(uri, callbackopt, requestopt, postdataopt) → {Promise}

Download binary data (e.g. a gzipped file) into an array buffer and provide
arraybuffer to callback.

Parameters:
NameTypeAttributesDescription
uristring

location of data

callbackfunction<optional>

Function to call with arraybuffer as argument.

requeststring<optional>

type of request

postdatastring<optional>

data for POST request

Returns:
Type: 
Promise

parseV3000(linesnon-null, options) → (non-null) {Array.<!Array.<!Object>>}

Parameters:
NameTypeDescription
linesArray.<string>
optionsParserOptionsSpec
Returns:
Type: 
Array.<!Array.<!Object>>

setSyncSurface(val)

Parameters:
NameTypeDescription
valboolean

Whether surfaces should be rendered synchronously or in parallel.

Type Definitions

ColorSpec

Color representation. A hex number, html color name, or object with r/g/b properties

Type:
  • number | string | Colored
Source

ColorschemeSpec

Colorscheme specification.

Type:
  • string | object
Properties
NameTypeAttributesDescription
gradientGradientType | string<optional>
minnumber<optional>
maxnumber<optional>
propstring<optional>

{AtomSpec} property to use for gradient calculation. E.g., 'b' for temperature factors of a PDB.

midnumber<optional>

mid point value for gradient (for rwb)

colorsArray.<ColorSpec><optional>

Custom colors for gradient (for CustomLinear)

mapRecord.<string, unknown><optional>

map of a certain AtomSpec property to a color of the form {'prop': 'elem', map:elementColors.greenCarbon} Allows the user to provide a mapping of elements to colors to the colorscheme. This can be done with any properties, and not just 'elem'.

Source

GradientSpec

Gradient specification.

Type:
  • object
Properties
NameTypeAttributesDescription
gradientstring<optional>

Kind of gradient. E.g. RWB, ROYGB, sinebow. Can also specify linear[_color]* as a,
shorthand for CustomLinear and passing a colors array.

minnumber<optional>

Lower range of gradient

maxnumber<optional>

Upper range of gradient

propstring<optional>

{AtomSpec} property to use for gradient calculation. E.g., 'b' for temperature factors of a PDB.

midnumber<optional>

mid point value for gradient (for rwb)

colorsArray.<ColorSpec><optional>

Custom colors for gradient (for CustomLinear)

mapRecord.<string, unknown><optional>

map of a certain AtomSpec property to a color of the form {'prop': 'elem', map:elementColors.greenCarbon} Allows the user to provide a mapping of elements to colors to the colorscheme. This can be done with any properties, and not just 'elem'.