NGL@0.10.4 Home Manual Reference Source GalleryRepository

Function

Static Public Summary
public

AVHash(atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: Float)

Modifed from SpatialHash

public

BinaryHeap(scoreFunction: Function)

Binary heap implementation

public

Kdtree(points: Float32Array, metric: Function)

Kdtree

public

Viewer(idOrElement: String | Element)

Viewer class

public

Assigns ResidueType bonds.

public

autoLoad(file: String | File | Blob, params: LoaderParameters): Promise

Load a file

public

binarySearchIndexOf(array: Array, element: Anything, compareFunction: Function): Number

Does a binary search to get the index of an element in the input array

public
public

Make image from what is shown in a viewer canvas

public

quicksortIP(arr: TypedArray, eleSize: Integer, orderElement: Integer, begin: Integer, end: Integer): TypedArray

quicksortIP

public

Perform structural superposition of two structures, optionally guided by a sequence alignment

Static Public

public AVHash(atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: Float) source

import {AVHash} from 'ngl/src/surface/av-surface.js'

Modifed from SpatialHash

Main differences are:

  • Optimized grid size to ensure we only ever need to look +/-1 cell
  • Aware of atomic radii and will only output atoms within rAtom + rExtra (see withinRadii method)

(Uses rounding rather than bitshifting as consequence of arbitrary grid size)

Params:

NameTypeAttributeDescription
atomsX Float32Array

x coordinates

atomsY Float32Array

y coordinates

atomsZ Float32Array

z coordinates

atomsR Float32Array

atom radii

min Float32Array

xyz min coordinates

max Float32Array

xyz max coordinates

maxDistance Float

max distance

public BinaryHeap(scoreFunction: Function) source

import BinaryHeap from 'ngl/src/utils/binary-heap.js'

Binary heap implementation

Params:

NameTypeAttributeDescription
scoreFunction Function

the heap scoring function

public Kdtree(points: Float32Array, metric: Function) source

import Kdtree from 'ngl/src/utils/kdtree.js'

Kdtree

Params:

NameTypeAttributeDescription
points Float32Array

points

metric Function

metric

Example:

points: [x, y, z, x, y, z, x, y, z, ...]
metric: function(a, b){
   return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);
}

public Viewer(idOrElement: String | Element) source

import Viewer from 'ngl/src/viewer/viewer.js'

Viewer class

Params:

NameTypeAttributeDescription
idOrElement String | Element
  • optional

dom id or element

public assignResidueTypeBonds(structure: Structure): undefined source

import {assignResidueTypeBonds} from 'ngl/src/structure/structure-utils.js'

Assigns ResidueType bonds.

Params:

NameTypeAttributeDescription
structure Structure

the structure object

Return:

undefined

public autoLoad(file: String | File | Blob, params: LoaderParameters): Promise source

import {autoLoad} from 'ngl/src/loader/loader-utils.js'

Load a file

Params:

NameTypeAttributeDescription
file String | File | Blob

either a URL or an object containing the file data

params LoaderParameters

loading parameters

Return:

Promise

Promise resolves to the loaded data

Example:

// load from URL
NGL.autoLoad( "http://files.rcsb.org/download/5IOS.cif" );
// load binary data in CCP4 format via a Blob
var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );
NGL.autoLoad( binaryBlob, { ext: "ccp4" } );
// load string data in PDB format via a Blob
var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );
NGL.autoLoad( stringBlob, { ext: "pdb" } );
// load a File object
NGL.autoLoad( file );

public binarySearchIndexOf(array: Array, element: Anything, compareFunction: Function): Number source

import {binarySearchIndexOf} from 'ngl/src/utils.js'

Does a binary search to get the index of an element in the input array

Params:

NameTypeAttributeDescription
array Array

sorted array

element Anything

element to search for in the array

compareFunction Function
  • optional

compare function

Return:

Number

the index of the element or -1 if not in the array

Example:

var array = [ 1, 2, 3, 4, 5, 6 ];
var element = 4;
binarySearchIndexOf( array, element );  // returns 3

public lineLineIntersect(p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3): Array<Vector3, Vector3> | null source

import {lineLineIntersect} from 'ngl/src/math/vector-utils.js'

Converted to JavaScript from http://paulbourke.net/geometry/pointlineplane/lineline.c

Params:

NameTypeAttributeDescription
p1 Vector3

point 1

p2 Vector3

point 2

p3 Vector3

point 3

p4 Vector3

point 4

Return:

Array<Vector3, Vector3> | null

the two intersection points

public makeImage(viewer: Viewer, params: ImageParameters): Promise source

import {makeImage} from 'ngl/src/viewer/viewer-utils.js'

Make image from what is shown in a viewer canvas

Params:

NameTypeAttributeDescription
viewer Viewer

the viewer

params ImageParameters

parameters object

Return:

Promise

A Promise object that resolves to an image Blob.

public quicksortIP(arr: TypedArray, eleSize: Integer, orderElement: Integer, begin: Integer, end: Integer): TypedArray source

import {quicksortIP} from 'ngl/src/math/array-utils.js'

quicksortIP

Params:

NameTypeAttributeDescription
arr TypedArray

array to be sorted

eleSize Integer

element size

orderElement Integer

index of element used for sorting, < eleSize

begin Integer
  • optional

start index for range to be sorted

end Integer
  • optional

end index for range to be sorted

Return:

TypedArray

the input array

Example:

points: [x, y, z, x, y, z, x, y, z, ...]
eleSize: 3 //because of (x, y, z)
orderElement: 0 //order according to x

public superpose(s1: Structure | StructureView, s2: Structure | StructureView, align: Boolean, sele1: String, sele2: String): undefined source

import {superpose} from 'ngl/src/align/align-utils.js'

Perform structural superposition of two structures, optionally guided by a sequence alignment

Params:

NameTypeAttributeDescription
s1 Structure | StructureView

structure 1 which is superposed onto structure 2

s2 Structure | StructureView

structure 2 onto which structure 1 is superposed

align Boolean
  • optional

guide the superposition by a sequence alignment

sele1 String
  • optional

selection string for structure 1

sele2 String
  • optional

selection string for structure 2

Return:

undefined