Members
number
# readonly SurfaceType
Surface types
Properties:
Name | Type | Description |
---|---|---|
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:
Name | Type | Description |
---|---|---|
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 |
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 elementColors
Preset element coloring - from individual element colors to entire mappings (e.g. 'elementColors.Jmol' colors atoms with Jmol stylings)
# 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
# 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:
Name | Type | Description |
---|---|---|
str |
string
|
|
options |
ParserOptionsSpec
|
# GRO(str, options*)
Parse a gro file from str and create atoms
Parameters:
Name | Type | Description |
---|---|---|
str |
string
|
|
options* |
ParserOptionsSpec
|
# LAMMPSTRJ()
Parse a lammps trajectory file from str and create atoms
# MMTFparser(bindata, ParserOptionsSpec)
Parameters:
Name | Type | Description |
---|---|---|
bindata |
binary UInt8Array buffer or a base64 encoded string |
|
ParserOptionsSpec |
# PDB(str, options)
Parameters:
Name | Type | Description |
---|---|---|
str |
string
|
|
options |
ParserOptionsSpec
|
keepH (do not strip hydrogens), noSecondaryStructure, |
# 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:
Name | Type | Description |
---|---|---|
str |
string
|
|
options |
ParserOptionsSpec
|
noSecondaryStructure (do not compute ss) |
# PRMTOP(str, options)
Parse a prmtop file from str and create atoms
Parameters:
Name | Type | Description |
---|---|---|
str |
string
|
|
options |
ParserOptionsSpec
|
noSecondaryStructure (do not compute ss) |
# bondLength()
Get the length used for bond identification for the specified element.
# conversionMatrix3(a, b, c, alpha, beta, gamma) → {Matrix3}
Parameters:
Name | Type | Description |
---|---|---|
a |
number
|
|
b |
number
|
|
c |
number
|
|
alpha |
number
|
|
beta |
number
|
|
gamma |
number
|
# createViewer(element, configopt) → {GLViewer}
Create and initialize an appropriate viewer at supplied HTML element using specification in config
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
element |
Object
|
string
|
Either HTML element or string identifier |
|
config |
ViewerSpec
|
<optional> |
Viewer configuration |
GLViewer, null if unable to instantiate WebGL
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:
Name | Type | Attributes | Description |
---|---|---|---|
element |
Object
|
string
|
Either HTML element or string identifier |
|
config |
GridSpec
|
<optional> |
grid configuration |
viewer_config |
ViewerGridSpec
|
<optional> |
Viewer specification to apply to all subviewers |
[[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();
});
# 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:
Name | Type | Attributes | Description |
---|---|---|---|
query |
string
|
String specifying pdb or pubchem id; must be prefaced with "pdb: " or "cid: ", respectively |
|
viewer |
GLViewer
|
Add new model to existing viewer |
|
options |
Object
|
Specify additional options |
|
callback |
function
|
<optional> |
Function to call with model as argument after data is loaded. |
GLModel, Promise if callback is not provided
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);
});
# get(uri, callback)
Fetch data from URL
Parameters:
Name | Type | Description |
---|---|---|
uri |
URL |
|
callback |
Function to call with data |
# getbin(uri, callbackopt, requestopt, postdataopt) → {Promise}
Download binary data (e.g. a gzipped file) into an array buffer and provide
arraybuffer to callback.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uri |
string
|
location of data |
|
callback |
function
|
<optional> |
Function to call with arraybuffer as argument. |
request |
string
|
<optional> |
type of request |
postdata |
string
|
<optional> |
data for POST request |
Promise
# setBondLength()
Set the length used for bond identification for the specified element.
Type Definitions
number
|
string
|
Colored
# ColorSpec
Color representation. A hex number, html color name, or object with r/g/b properties
string
|
object
# ColorschemeSpec
Colorscheme specification.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
gradient |
GradientType
|
string
|
<optional> |
|
min |
number
|
<optional> |
|
max |
number
|
<optional> |
|
prop |
string
|
<optional> |
{AtomSpec} property to use for gradient calculation. E.g., 'b' for temperature factors of a PDB. |
mid |
number
|
<optional> |
mid point value for gradient (for rwb) |
colors |
Array.<ColorSpec>
|
<optional> |
Custom colors for gradient (for |
map |
Record.<string, unknown>
|
<optional> |
map of a certain |
colorfunc |
function
|
<optional> |
Allows the user to provide a function for setting the colorschemes. |