Socket
Socket
Sign inDemoInstall

3dmol

Package Overview
Dependencies
4
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.6 to 2.1.0

favicon.ico

2

build/3Dmol-min.js.LICENSE.txt
/*!
* 3dmol v2.0.6
* 3dmol v2.1.0
* JavaScript/TypeScript molecular visualization library
* Author: David Koes and contributors
*/
/*!
* 3dmol v2.0.6
* 3dmol v2.1.0
* JavaScript/TypeScript molecular visualization library

@@ -4,0 +4,0 @@ * Author: David Koes and contributors

@@ -44,3 +44,3 @@ import { Geometry } from "./WebGL";

* */
function drawCylinder(geo: Geometry, from: any, to: any, radius: number, color: Color | Color[], fromCap?: CAP, toCap?: CAP): void;
function drawCylinder(geo: Geometry, from: any, to: any, radius: number, color: Color | Color[], fromCap?: CAP | string, toCap?: CAP | string): void;
/** Create a cone

@@ -47,0 +47,0 @@ * @memberof GLDraw

import { Geometry } from "./WebGL";
import { Matrix3, XYZ } from "./WebGL/math";
import { Color, ColorschemeSpec, ColorSpec } from "./colors";
import { CAP } from "./GLDraw";
import { CartoonStyleSpec } from "./glcartoon";

@@ -132,3 +133,4 @@ import { Gradient } from "./Gradient";

private drawAtomImposter;
static drawStickImposter(geo: Geometry, from: XYZ, to: XYZ, radius: number, color: Color): void;
private calculateDashes;
static drawStickImposter(geo: Geometry, from: XYZ, to: XYZ, radius: number, color: Color, fromCap?: CAP, toCap?: CAP): void;
private drawBondSticks;

@@ -544,2 +546,10 @@ /** param {AtomSpec[]} atoms */

}
/** Dashed Bond style specification
*/
export interface DashedBondSpec {
/** length of dash (default 0.1) */
dashLength?: number;
/** length of gap (default 0.25) */
gapLength?: number;
}
/** Stick (cylinder) style specification

@@ -556,2 +566,6 @@ */

tripleBondScaling?: number;
/** dashed bond properties */
dashedBondConfig?: DashedBondSpec;
/** draw all bonds as dashed bonds */
dashedBonds?: boolean;
/** draw all bonds as single bonds */

@@ -558,0 +572,0 @@ singleBonds?: boolean;

@@ -308,5 +308,5 @@ import { Geometry } from "./WebGL";

/** Place a cap at the start (none, flat or round) */
fromCap?: CAP;
fromCap?: CAP | string;
/** Place a cap at the end (none, flat or round) */
toCap?: CAP;
toCap?: CAP | string;
/** Make the cylinder dashed. */

@@ -313,0 +313,0 @@ dashed?: boolean;

@@ -913,2 +913,3 @@ import { Renderer } from "./WebGL";

* @param {boolean} addBonds - Create bonds between unit cells based on distances.
* @param {boolean} prune - Keep only atoms that are within the original unit cell (i.e., on edges). Alternatively, call replicateUnitCell(1).
@example

@@ -924,3 +925,3 @@ $3Dmol.get('data/icsd_200866.cif', function(data) {

*/
replicateUnitCell(A?: number, B?: number, C?: number, model?: GLModel | number, addBonds?: boolean): void;
replicateUnitCell(A?: number, B?: number, C?: number, model?: GLModel | number, addBonds?: boolean, prune?: any): void;
/** Add dashed line to shape */

@@ -1066,2 +1067,3 @@ addLineDashed(spec: CylinderSpec, s: GLShape): GLShape;

isAnimated(): boolean;
private getModelOpt;
/**

@@ -1068,0 +1070,0 @@ * Create and add model to viewer, given molecular data and its format

@@ -0,1 +1,2 @@

import { ParserOptionsSpec } from "./ParserOptionsSpec";
/**

@@ -10,2 +11,2 @@ * Parse a gro file from str and create atoms

*/
export declare function GRO(str: string): any[][] & Record<string, any>;
export declare function GRO(str: string, options: ParserOptionsSpec): any[][] & Record<string, any>;

@@ -45,2 +45,4 @@ /**

duplicateAssemblyAtoms?: boolean;
/** Set to true with duplicateAssemblyAtoms to individually wrap atoms (from symmetries) into unit cell */
wrapAtoms?: boolean;
/** shift symmetry mates so their centroid is in the unit cell */

@@ -62,4 +64,6 @@ normalizeAssembly?: boolean;

assignBonds?: boolean;
/** for formats without explicit bonds, if assigning bonds to not assign bonds to common cations */
unboundCations?: boolean;
/** set model to this style after parsing */
style?: AtomStyleSpec;
}

@@ -1,1 +0,1 @@

export declare const anumToSymbol: any;
export declare const anumToSymbol: Record<string, string>;

@@ -1,13 +0,3 @@

export declare function areConnected(atom1: {
elem: any;
x: number;
y: number;
z: number;
altLoc: string;
}, atom2: {
elem: any;
x: number;
y: number;
z: number;
altLoc: string;
}): boolean;
import { AtomSpec } from "specs";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
export declare function areConnected(atom1: AtomSpec, atom2: AtomSpec, options: ParserOptionsSpec): boolean;

@@ -1,1 +0,2 @@

export declare function assignBackboneHBonds(atomsarray: string | any[], hbondCutoff: number): void;
import { AtomSpec } from "specs";
export declare function assignBackboneHBonds(atomsarray: Array<AtomSpec>, hbondCutoff: number): void;

@@ -1,4 +0,3 @@

/**
* @param {AtomSpec[]} atoms
*/
export declare function assignBonds(atoms: string | any[]): void;
import { AtomSpec } from "specs";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
export declare function assignBonds(atoms: AtomSpec[], options: ParserOptionsSpec): void;

@@ -0,5 +1,7 @@

import { AtomSpec } from "specs";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
/**
* @param {AtomSpec[]}
* atomsarray
*/
export declare function assignPDBBonds(atomsarray: string | any[]): void;
*/
export declare function assignPDBBonds(atomsarray: AtomSpec[], options: ParserOptionsSpec): void;

@@ -1,3 +0,3 @@

export declare let bondTable: any;
export declare function bondLength(elem: string | number): any;
export declare let bondTable: Record<string, number>;
export declare function bondLength(elem: string | number): number;
export declare function setBondLength(elem: string, radius: number): void;

@@ -1,1 +0,2 @@

export declare function computeSecondaryStructure(atomsarray: string | any[], hbondCutoff: number | undefined): void;
import { AtomSpec } from "specs";
export declare function computeSecondaryStructure(atomsarray: Array<AtomSpec>, hbondCutoff: number): void;

@@ -0,7 +1,12 @@

import { Matrix4 } from "../../WebGL";
import { ParserOptionsSpec } from "../ParserOptionsSpec";
import { AtomSpec, Cryst } from "specs";
export declare function getSinglePDB(lines: string[], options: ParserOptionsSpec, sslookup: {
[x: string]: {
[x: string]: any;
[x: string]: string;
};
hasOwnProperty?: any;
}): Record<string, any>[];
}): [AtomSpec[], {
symmetries: Matrix4[];
cryst: Cryst;
}, string[]];
export declare function isEmpty(obj: {
[x: string]: {
[x: string]: any;
[x: string]: unknown;
};
hasOwnProperty?: any;
}): boolean;

@@ -1,9 +0,3 @@

import { ParserOptionsSpec } from 'parsers/ParserOptionsSpec';
export declare function processSymmetries(copyMatrices: string[] | any[], atoms: any[], options: ParserOptionsSpec, cryst: {
a: any;
b: number;
c: number;
alpha: number;
beta: number;
gamma: number;
}): void;
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
import { AtomSpec, Cryst } from "specs";
export declare function processSymmetries(copyMatrices: string[] | any[], atoms: AtomSpec[], options: ParserOptionsSpec, cryst: Cryst): void;

@@ -1,1 +0,2 @@

export declare function validateBonds(atomsarray: string[] | any[], serialToIndex: number[]): void;
import { AtomSpec } from "specs";
export declare function validateBonds(atomsarray: AtomSpec[], serialToIndex: number[]): void;

@@ -0,1 +1,2 @@

import { Vector3 } from "WebGL";
import { AtomStyleSpec, BondStyle, GLModel } from "./GLModel";

@@ -28,4 +29,4 @@ import { GLViewer } from "./GLViewer";

resi?: number;
icode?: number;
rescode?: number;
icode?: string;
rescode?: string;
/** Atom's serial id number */

@@ -41,2 +42,4 @@ serial?: number;

ss?: string;
ssbegin?: boolean;
ssend?: boolean;
/** true if this atom forms only single bonds or no bonds at all */

@@ -72,2 +75,9 @@ singleBonds?: boolean;

contextMenuEnabled?: boolean;
hbondDistanceSq?: number;
hbondOther?: any;
altLoc?: string;
reschain?: number;
uMat?: Record<string, number>;
symmetries?: Vector3[];
sym?: any;
}

@@ -143,2 +153,10 @@ /**

}
export type Cryst = {
a: number;
b: number;
c: number;
alpha: number;
beta: number;
gamma: number;
};
export type SelectionRange = `${number}-${number}`;

@@ -31,2 +31,3 @@ import { EventDispatcher } from "../core";

outline: boolean;
wireframe: boolean;
setValues(values?: Partial<Record<keyof Material, any>>): void;

@@ -33,0 +34,0 @@ clone<T extends this>(material?: T): T;

@@ -92,2 +92,3 @@ /**

getContext(): WebGLRenderingContext | WebGL2RenderingContext;
getCanvas(): any;
isLost(): boolean;

@@ -94,0 +95,0 @@ getPrecision(): any;

{
"name": "3dmol",
"version": "2.0.6",
"version": "2.1.0",
"description": "JavaScript/TypeScript molecular visualization library",

@@ -61,3 +61,3 @@ "repository": {

"canvas": "^2.11.0",
"clean-jsdoc-theme": "^4.2.9",
"clean-jsdoc-theme": "github:3dmol/clean-jsdoc-theme#master",
"codecov": "^3.8.3",

@@ -64,0 +64,0 @@ "del": "^7.0.0",

@@ -1159,3 +1159,3 @@ //glcartoon.js

if (curr === undefined || curr.rescode != next.rescode || curr.resi != next.resi) {
if (baseEndPt) // draw last NA residue's base
if (baseEndPt && curr != undefined) // draw last NA residue's base
{

@@ -1205,7 +1205,7 @@ // start the cylinder at the midpoint between

// atoms used to orient the backbone strand
else if (isAlphaCarbon(curr) && next.atom === "O" ||
else if (curr != undefined && (isAlphaCarbon(curr) && next.atom === "O" ||
inNucleicAcid && curr.atom === "P" &&
(next.atom === "OP2" || next.atom === "O2P") ||
inNucleicAcid && curr.atom.indexOf("O5") == 0 &&
next.atom.indexOf("C5") == 0) {
next.atom.indexOf("C5") == 0)) {
orientPt = new Vector3(next.x, next.y, next.z);

@@ -1212,0 +1212,0 @@ orientPt.resi = next.resi;

@@ -298,6 +298,23 @@ import { Vector3 } from "./WebGL/math";

* */
export function drawCylinder(geo: Geometry, from: any, to: any, radius: number, color: Color | Color[], fromCap:CAP = 0, toCap:CAP = 0) {
export function drawCylinder(geo: Geometry, from: any, to: any, radius: number, color: Color | Color[], fromCap:CAP|string = 0, toCap:CAP|string = 0) {
if (!from || !to)
return;
let getcap = function(c: CAP|string): CAP {
if(typeof c === "string") {
let s = <string>c;
if(s.toLowerCase() == 'flat') {
return CAP.FLAT;
} else if(s.toLowerCase() == 'round') {
return CAP.ROUND;
} else {
return CAP.NONE;
}
} else {
return <CAP>c;
}
}
fromCap = getcap(fromCap);
toCap = getcap(toCap);
// vertices

@@ -304,0 +321,0 @@ var drawcaps = toCap || fromCap;

@@ -1652,5 +1652,5 @@ import { Geometry, Material } from "./WebGL";

/** Place a cap at the start (none, flat or round) */
fromCap?: CAP;
fromCap?: CAP | string;
/** Place a cap at the end (none, flat or round) */
toCap?: CAP;
toCap?: CAP | string;
/** Make the cylinder dashed. */

@@ -1657,0 +1657,0 @@ dashed?: boolean;

import { ParserOptionsSpec } from './ParserOptionsSpec';
import { assignBonds } from "./utils/assignBonds";
import { computeSecondaryStructure } from "./utils/computeSecondaryStructure";
import { processSymmetries } from "./utils/processSymmetries";
import { conversionMatrix3, Matrix3, Matrix4, Vector3, } from "../WebGL"
import { assignPDBBonds } from './utils/assignPDBBonds';

@@ -44,2 +44,7 @@ /**

}
//biopython apparently generates invalid string literals so if we think we are done but aren't at a separator keep going
while (string.substring(sectionEnd, sectionEnd + separator.length) !== separator &&
sectionEnd < string.length) {
sectionEnd++;
}
} else if (string[sectionEnd] === '"') {

@@ -50,4 +55,6 @@ sectionEnd++;

}
sectionEnd++;
} else {
sectionEnd++;
}
sectionEnd++;
}

@@ -243,12 +250,12 @@ sections.push(string.substring(sectionStart, sectionEnd));

? mmCIF._atom_site_auth_asym_id[i]
: undefined;
: (mmCIF._atom_site_label_asym_id ? mmCIF._atom_site_label_asym_id[i] : undefined);
atom.resi = mmCIF._atom_site_auth_seq_id
? parseInt(mmCIF._atom_site_auth_seq_id[i])
: undefined;
: (mmCIF._atom_site_label_seq_id ? mmCIF._atom_site_label_seq_id[i] : undefined);
atom.resn = mmCIF._atom_site_auth_comp_id
? mmCIF._atom_site_auth_comp_id[i].trim()
: undefined;
: (mmCIF._atom_site_label_comp_id ? mmCIF._atom_site_label_comp_id[i].trim() : undefined);
atom.atom = mmCIF._atom_site_auth_atom_id
? mmCIF._atom_site_auth_atom_id[i].replace(/"/gm, "")
: undefined; //"primed" names are in quotes
: (mmCIF._atom_site_label_atom_id ? mmCIF._atom_site_label_atom_id[i].replace(/"/gm, "") : undefined); //"primed" names are in quotes
atom.hetflag =

@@ -405,3 +412,5 @@ !mmCIF._atom_site_group_pdb ||

for (let i = 0; i < atoms.length; i++) {
if (assignbonds) assignBonds(atoms[i]);
if (assignbonds && !(options.duplicateAssemblyAtoms && !options.dontConnectDuplicatedAtoms)) {
assignPDBBonds(atoms[i], options);
}
computeSecondaryStructure(atoms[i],options.hbondCutoff);

@@ -419,3 +428,3 @@ processSymmetries(

)
assignBonds(atoms[i]);
assignPDBBonds(atoms[i],options);
}

@@ -422,0 +431,0 @@

@@ -106,5 +106,5 @@ import { Vector3, Matrix4 } from "../WebGL";

for (let i = 0; i < atoms.length; i++)
assignBonds(atoms[i]);
assignBonds(atoms[i], options);
}
return atoms;
};

@@ -0,1 +1,2 @@

import { ParserOptionsSpec } from "./ParserOptionsSpec";
import { assignPDBBonds } from "./utils/assignPDBBonds";

@@ -14,3 +15,3 @@ import { atomNameToElem } from "./utils/atomNameToElem";

export function GRO(str: string /*, options*/) {
export function GRO(str: string, options: ParserOptionsSpec) {
var allatoms: any[][] & Record<string, any> = [];

@@ -66,5 +67,5 @@ var lines = str.split(/\r?\n|\r/);

for (let i = 0; i < allatoms.length; i++) {
assignPDBBonds(allatoms[i]);
assignPDBBonds(allatoms[i], options);
}
return allatoms;
}

@@ -69,5 +69,5 @@ import { ParserOptionsSpec } from "./ParserOptionsSpec";

if (options.assignBonds) {
for (var i = 0; i < atoms.length; i++) assignBonds(atoms[i]);
for (var i = 0; i < atoms.length; i++) assignBonds(atoms[i], options);
}
return atoms;
}

@@ -50,3 +50,2 @@ import { base64ToArray } from "../utilities";

*/
export function MMTFparser(bindata: any, options: ParserOptionsSpec) {

@@ -304,3 +303,3 @@

if (computeStruct && !ignoreStruct) {
computeSecondaryStructure(atoms, options.hbondCutoff);
computeSecondaryStructure(atoms as any, options.hbondCutoff);
}

@@ -307,0 +306,0 @@

@@ -48,2 +48,4 @@ /**

duplicateAssemblyAtoms?: boolean;
/** Set to true with duplicateAssemblyAtoms to individually wrap atoms (from symmetries) into unit cell */
wrapAtoms?: boolean;
/** shift symmetry mates so their centroid is in the unit cell */

@@ -65,4 +67,6 @@ normalizeAssembly?: boolean;

assignBonds?: boolean;
/** for formats without explicit bonds, if assigning bonds to not assign bonds to common cations */
unboundCations?: boolean;
/** set model to this style after parsing */
style?: AtomStyleSpec;
};

@@ -109,3 +109,3 @@ import { ParserOptionsSpec } from "./ParserOptionsSpec";

for (let i = 0; i < atoms.length; i++) {
assignPDBBonds(atoms[i]);
assignPDBBonds(atoms[i],options);
if (computeStruct)

@@ -112,0 +112,0 @@ computeSecondaryStructure(atoms[i],options.hbondCutoff);

@@ -1,2 +0,2 @@

export const anumToSymbol:any = {
export const anumToSymbol:Record<string, string> = {
1: 'H', 2: 'He',

@@ -3,0 +3,0 @@ 3:'Li',4:'Be', 5: 'B', 6: 'C', 7:'N', 8:'O', 9:'F', 10: 'Ne',

@@ -0,34 +1,40 @@

import { AtomSpec } from "specs";
import { bondLength } from "./bondLength";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
const cations = new Set(["Na","K","Ca","Mg","Mn","Sr"]);
/*
* Return true if atom1 and atom2 are probably bonded to each other based on distance alone
*/
export function areConnected(atom1: { elem: any; x: number; y: number; z: number; altLoc: string; }, atom2: { elem: any; x: number; y: number; z: number; altLoc: string; }) {
var maxsq = bondLength(atom1.elem) + bondLength(atom2.elem);
*/
export function areConnected(atom1: AtomSpec, atom2: AtomSpec, options: ParserOptionsSpec) {
if(options && options.unboundCations && (cations.has(atom1.elem) || cations.has(atom2.elem))) {
return false;
}
let maxsq = bondLength(atom1.elem) + bondLength(atom2.elem);
maxsq += 0.25; // fudge factor, especially important for md frames, also see 1i3d
maxsq *= maxsq;
var xdiff = atom1.x - atom2.x;
let xdiff = atom1.x - atom2.x;
xdiff *= xdiff;
if (xdiff > maxsq) return false;
var ydiff = atom1.y - atom2.y;
let ydiff = atom1.y - atom2.y;
ydiff *= ydiff;
if (ydiff > maxsq) return false;
var zdiff = atom1.z - atom2.z;
let zdiff = atom1.z - atom2.z;
zdiff *= zdiff;
if (zdiff > maxsq) return false;
var distSquared = xdiff + ydiff + zdiff;
const distSquared = xdiff + ydiff + zdiff;
if (isNaN(distSquared)) return false;
else if (distSquared < 0.5) return false; // maybe duplicate position.
else if (distSquared > maxsq) return false;
else if (
atom1.altLoc != atom2.altLoc &&
atom1.altLoc != " " &&
atom2.altLoc != " "
if (
isNaN(distSquared) ||
distSquared < 0.5 ||
distSquared > maxsq ||
(atom1.altLoc !== atom2.altLoc && atom1.altLoc !== " " && atom2.altLoc !== " ")
)
return false; // don't connect across alternate locations
else return true;
return false;
return true;
}
// This will identify all hydrogen bonds between backbone
// atoms; assume atom names are correct, only identifies
// single closest hbond
export function assignBackboneHBonds(atomsarray: string | any[], hbondCutoff: number) {
let maxlength = hbondCutoff || 3.2;
let maxlengthSq = maxlength*maxlength;
let atoms = [];
import { AtomSpec } from "specs";
// interface Atoms {index: number; atom: string; hbondDistanceSq: number; hbondOther: any; hetflag:any}
export function assignBackboneHBonds(
atomsarray: Array<AtomSpec>,
hbondCutoff: number
) {
const maxlength = hbondCutoff || 3.2;
const maxlengthSq = maxlength * maxlength;
const atoms = [];
for (let i = 0, n = atomsarray.length; i < n; i++) {
atomsarray[i].index = i;
// only consider 'N' and 'O'
var atom = atomsarray[i];
const atom = atomsarray[i];
if (!atom.hetflag && (atom.atom === "N" || atom.atom === "O")) {

@@ -24,7 +30,7 @@ atoms.push(atom);

for (let i = 0, n = atoms.length; i < n; i++) {
var ai = atoms[i];
const ai = atoms[i];
for (let j = i + 1; j < n; j++) {
var aj = atoms[j];
var zdiff = aj.z - ai.z;
const aj = atoms[j];
const zdiff = aj.z - ai.z;
if (zdiff > maxlength)

@@ -34,7 +40,7 @@ // can't be connected

if (aj.atom == ai.atom) continue; // can't be connected, but later might be
var ydiff = Math.abs(aj.y - ai.y);
const ydiff = Math.abs(aj.y - ai.y);
if (ydiff > maxlength) continue;
var xdiff = Math.abs(aj.x - ai.x);
const xdiff = Math.abs(aj.x - ai.x);
if (xdiff > maxlength) continue;
var dist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
const dist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
if (dist > maxlengthSq) continue;

@@ -41,0 +47,0 @@

@@ -0,11 +1,29 @@

import { AtomSpec } from "specs";
import { areConnected } from "./areConnected";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
/**
* @param {AtomSpec[]} atoms
*/
*/
const OFFSETS = [
{ x: 0, y: 0, z: 1 },
{ x: 0, y: 1, z: -1 },
{ x: 0, y: 1, z: 0 },
{ x: 0, y: 1, z: 1 },
{ x: 1, y: -1, z: -1 },
{ x: 1, y: -1, z: 0 },
{ x: 1, y: -1, z: 1 },
{ x: 1, y: 0, z: -1 },
{ x: 1, y: 0, z: 0 },
{ x: 1, y: 0, z: 1 },
{ x: 1, y: 1, z: -1 },
{ x: 1, y: 1, z: 0 },
{ x: 1, y: 1, z: 1 },
];
const MAX_BOND_LENGTH = 4.95; // (largest bond length, Cs) 2.25 * 2 * 1.1 (fudge factor)
export function assignBonds(atoms: string | any[]) {
export function assignBonds(atoms: AtomSpec[], options: ParserOptionsSpec) {
// Assign bonds - yuck, can't count on connect records
for (var i = 0, n = atoms.length; i < n; i++) {
for (let i = 0, n = atoms.length; i < n; i++) {
// Don't reindex if atoms are already indexed

@@ -15,10 +33,21 @@ if (!atoms[i].index) atoms[i].index = i;

var grid = {};
var MAX_BOND_LENGTH = 4.95; // (largest bond length, Cs) 2.25 * 2 * 1.1 (fudge factor)
const grid: {
x: {
y: {
z: AtomSpec[];
};
};
} = {
x: {
y: {
z: [],
},
},
};
for (var index = 0; index < atoms.length; index++) {
var atom = atoms[index];
var x = Math.floor(atom.x / MAX_BOND_LENGTH);
var y = Math.floor(atom.y / MAX_BOND_LENGTH);
var z = Math.floor(atom.z / MAX_BOND_LENGTH);
for (let index = 0; index < atoms.length; index++) {
const atom = atoms[index];
const x = Math.floor(atom.x / MAX_BOND_LENGTH);
const y = Math.floor(atom.y / MAX_BOND_LENGTH);
const z = Math.floor(atom.z / MAX_BOND_LENGTH);
if (!grid[x]) {

@@ -37,13 +66,16 @@ grid[x] = {};

var findConnections = function (points: string | any[], otherPoints: string | any[]) {
for (var i = 0; i < points.length; i++) {
var atom1 = points[i];
for (var j = 0; j < otherPoints.length; j++) {
var atom2 = otherPoints[j];
function findConnections(
points: Array<AtomSpec>,
otherPoints: Array<AtomSpec>
) {
for (let i = 0; i < points.length; i++) {
const atom1 = points[i];
for (let j = 0; j < otherPoints.length; j++) {
const atom2 = otherPoints[j];
if (areConnected(atom1, atom2)) {
if (areConnected(atom1, atom2, options)) {
//gracefully handle one-sided bonds
var a2i = atom1.bonds.indexOf(atom2.index);
var a1i = atom2.bonds.indexOf(atom1.index);
if (a2i == -1 && a1i == -1) {
const a2i = atom1.bonds.indexOf(atom2.index);
const a1i = atom2.bonds.indexOf(atom1.index);
if (a2i === -1 && a1i === -1) {
atom1.bonds.push(atom2.index);

@@ -53,6 +85,6 @@ atom1.bondOrder.push(1);

atom2.bondOrder.push(1);
} else if (a2i == -1) {
} else if (a2i === -1) {
atom1.bonds.push(atom2.index);
atom1.bondOrder.push(atom2.bondOrder[a1i]);
} else if (a1i == -1) {
} else if (a1i === -1) {
atom2.bonds.push(atom1.index);

@@ -64,32 +96,17 @@ atom2.bondOrder.push(atom1.bondOrder[a2i]);

}
};
}
/*const*/ var OFFSETS = [
{ x: 0, y: 0, z: 1 },
{ x: 0, y: 1, z: -1 },
{ x: 0, y: 1, z: 0 },
{ x: 0, y: 1, z: 1 },
{ x: 1, y: -1, z: -1 },
{ x: 1, y: -1, z: 0 },
{ x: 1, y: -1, z: 1 },
{ x: 1, y: 0, z: -1 },
{ x: 1, y: 0, z: 0 },
{ x: 1, y: 0, z: 1 },
{ x: 1, y: 1, z: -1 },
{ x: 1, y: 1, z: 0 },
{ x: 1, y: 1, z: 1 },
];
for (let xg in grid) {
let x = parseInt(xg);
const x = parseInt(xg);
for (let yg in grid[x]) {
let y = parseInt(yg);
const y = parseInt(yg);
for (let zg in grid[x][y]) {
let z = parseInt(zg);
let points = grid[x][y][z];
const z = parseInt(zg);
const points = grid[x][y][z];
for (let i = 0; i < points.length; i++) {
let atom1 = points[i];
const atom1 = points[i];
for (let j = i + 1; j < points.length; j++) {
let atom2 = points[j];
if (areConnected(atom1, atom2)) {
const atom2 = points[j];
if (areConnected(atom1, atom2,options)) {
if (atom1.bonds.indexOf(atom2.index) == -1) {

@@ -106,3 +123,3 @@ atom1.bonds.push(atom2.index);

for (let o = 0; o < OFFSETS.length; o++) {
let offset = OFFSETS[o];
const offset = OFFSETS[o];
if (

@@ -115,3 +132,3 @@ !grid[x + offset.x] ||

let otherPoints = grid[x + offset.x][y + offset.y][z + offset.z];
const otherPoints = grid[x + offset.x][y + offset.y][z + offset.z];
findConnections(points, otherPoints);

@@ -118,0 +135,0 @@ }

// This is optimized for proteins where it is assumed connected atoms are on the same or next residue
import { AtomSpec } from "specs";
import { areConnected } from "./areConnected";
import { assignBonds } from "./assignBonds";
import { standardResidues } from "./standardResidues";
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
/**
/**
* @param {AtomSpec[]}
* atomsarray
*/
*/
export function assignPDBBonds(atomsarray: string | any[]) {
export function assignPDBBonds(atomsarray: AtomSpec[], options: ParserOptionsSpec) {
// assign bonds - yuck, can't count on connect records
var protatoms: any[] = [];
var hetatoms: any[] = [];
var i: number, n: number;
for (i = 0, n = atomsarray.length; i < n; i++) {
var atom: any = atomsarray[i];
const protatoms: Array<AtomSpec> = [];
const hetatoms: Array<AtomSpec> = [];
for (let i = 0, n = atomsarray.length; i < n; i++) {
const atom = atomsarray[i];
atom.index = i;

@@ -25,7 +26,7 @@ if (atom.hetflag || !standardResidues.has(atom.resn)) hetatoms.push(atom);

assignBonds(hetatoms);
assignBonds(hetatoms, options);
// sort by resid
protatoms.sort(function (a: any, b: any) {
if (a.chain != b.chain) return a.chain < b.chain ? -1 : 1;
protatoms.sort(function (a, b) {
if (a.chain !== b.chain) return a.chain < b.chain ? -1 : 1;
return a.resi - b.resi;

@@ -35,8 +36,8 @@ });

// for identifying connected residues
var currentResi = -1;
var reschain = -1;
var lastResConnected: boolean;
let currentResi = -1;
let reschain = -1;
let lastResConnected: boolean;
for (i = 0, n = protatoms.length; i < n; i++) {
var ai = protatoms[i];
for (let i = 0, n = protatoms.length; i < n; i++) {
const ai = protatoms[i];

@@ -52,9 +53,7 @@ if (ai.resi !== currentResi) {

for (var j = i + 1; j < protatoms.length; j++) {
var aj = protatoms[j];
if (aj.chain != ai.chain) break;
if (aj.resi - ai.resi > 1)
// can't be connected
break;
if (areConnected(ai, aj)) {
for (let j = i + 1; j < protatoms.length; j++) {
const aj = protatoms[j];
if (aj.chain !== ai.chain || aj.resi - ai.resi > 1) break;
if (areConnected(ai, aj, options)) {
if (ai.bonds.indexOf(aj.index) === -1) {

@@ -61,0 +60,0 @@ // only add if not already there

@@ -5,21 +5,29 @@ import { bondTable } from "./bondLength";

export function atomNameToElem(name: string, nothetero: boolean) {
var elem = name.replace(/ /g, "");
if(elem.length > 0 && elem[0] == 'H' && elem != 'Hg' && elem != 'He' && elem != 'Hf' && elem != 'Hs' && elem != 'Ho') {
elem = 'H'; //workaround weird hydrogen names from MD, note mercury must use lowercase
let elem = name.replace(/ /g, "");
if (
elem.length > 0 &&
elem[0] === "H" &&
elem !== "Hg" &&
elem !== "He" &&
elem !== "Hf" &&
elem !== "Hs" &&
elem !== "Ho"
) {
elem = "H"; //workaround weird hydrogen names from MD, note mercury must use lowercase
}
if(elem.length > 1) {
elem = elem[0].toUpperCase() + elem.substring(1).toLowerCase();
if(typeof(bondTable[elem]) === 'undefined') {
//not a known element, probably should just use first letter
elem = elem[0];
} else if(nothetero) {
if(elem == 'Ca') { //alpha carbon, not calcium
elem = 'C';
}
else if(elem == 'Cd') {
elem = 'C';
}
if (elem.length > 1) {
elem = elem[0].toUpperCase() + elem.substring(1).toLowerCase();
if (bondTable[elem] === undefined) {
//not a known element, probably should just use first letter
elem = elem[0];
} else if (nothetero) {
if (elem === "Ca") {
//alpha carbon, not calcium
elem = "C";
} else if (elem === "Cd") {
elem = "C";
}
}
}
return elem;
};
}

@@ -1,4 +0,3 @@

// Covalent radii lookup table used to identify bonds in assignBonds
export let bondTable:any = {
export let bondTable: Record<string, number> = {
H :0.37, He:0.32,

@@ -14,13 +13,11 @@ Li:1.34,Be:0.90, B :0.82,C :0.77,N :0.75,O :0.73,F :0.71,Ne:0.69,

// Get the length used for bond identification for the specified element.
export function bondLength(elem: string | number) {
return bondTable[elem] || 1.6;
};
}
// Set the length used for bond identification for the specified element.
export function setBondLength(elem:string, radius:number) {
if(radius < 0) radius = 0;
export function setBondLength(elem: string, radius: number) {
if (radius < 0) radius = 0;
bondTable[elem] = radius;
}

@@ -0,10 +1,11 @@

import { AtomSpec } from "specs";
import { assignBackboneHBonds } from "./assignBackboneHBonds";
export function computeSecondaryStructure(atomsarray: string | any[], hbondCutoff: number | undefined) {
assignBackboneHBonds(atomsarray, hbondCutoff!);
export function computeSecondaryStructure(atomsarray: Array<AtomSpec>, hbondCutoff: number) {
assignBackboneHBonds(atomsarray, hbondCutoff);
// compute, per residue, what the secondary structure is
var chres = {}; // lookup by chain and resid
var i: number, il: number, c: string | number, r: number; // i: used in for loop, il: length of atomsarray
var atom: { chain: string | number; hbondDistanceSq: number; hbondOther: any; resi: number; ss: string; ssbegin: boolean; ssend: boolean; }, val: string;
const chres = {}; // lookup by chain and resid
let i: number, il: number, c: string | number, r: number; // i: used in for loop, il: length of atomsarray
let atom: AtomSpec, val: string;

@@ -15,7 +16,7 @@ //identify helices first

if (typeof chres[atom.chain] === "undefined") chres[atom.chain] = [];
if (chres[atom.chain] === undefined) chres[atom.chain] = [];
if (isFinite(atom.hbondDistanceSq)) {
var other = atom.hbondOther;
if (typeof chres[other.chain] === "undefined") chres[other.chain] = [];
const other = atom.hbondOther;
if (chres[other.chain] === undefined) chres[other.chain] = [];

@@ -32,4 +33,4 @@ if (Math.abs(other.resi - atom.resi) === 4) {

for (r = 1; r < chres[c].length - 1; r++) {
var valbefore = chres[c][r - 1];
var valafter = chres[c][r + 1];
const valbefore = chres[c][r - 1];
const valafter = chres[c][r + 1];
val = chres[c][r];

@@ -49,3 +50,3 @@ if (valbefore == "h" && valbefore == valafter && val != valbefore) {

chres[atom.chain][atom.resi] != "h" &&
atom.ss != "h"
atom.ss !== "h"
) {

@@ -77,4 +78,4 @@ chres[atom.chain][atom.resi] = "maybesheet";

for (let r = 1; r < chres[c].length - 1; r++) {
let valbefore = chres[c][r - 1];
let valafter = chres[c][r + 1];
const valbefore = chres[c][r - 1];
const valafter = chres[c][r + 1];
val = chres[c][r];

@@ -86,3 +87,3 @@ if (valbefore == "s" && valbefore == valafter && val != valbefore) {

for (let r = 0; r < chres[c].length; r++) {
let val = chres[c][r];
const val = chres[c][r];
if (val == "h" || val == "s") {

@@ -103,3 +104,3 @@ if (chres[c][r - 1] != val && chres[c][r + 1] != val)

delete atom.hbondDistanceSq;
if (typeof val == "undefined" || val == "maybesheet") continue;
if (val === undefined || val === "maybesheet") continue;
atom.ss = val;

@@ -106,0 +107,0 @@ if (chres[atom.chain][atom.resi - 1] != val) atom.ssbegin = true;

@@ -10,33 +10,38 @@ import { Matrix4 } from "../../WebGL";

import { ParserOptionsSpec } from "../ParserOptionsSpec";
import { AtomSpec, Cryst } from "specs";
// Return one model worth of pdb, returns atoms, modelData, and remaining lines
export function getSinglePDB(lines: string[], options: ParserOptionsSpec, sslookup: { [x: string]: { [x: string]: any; }; hasOwnProperty?: any; }) {
var atoms: any[] = [];
var assignbonds =
export function getSinglePDB(
lines: string[],
options: ParserOptionsSpec,
sslookup: { [x: string]: { [x: string]: string }; hasOwnProperty?: any }
): [AtomSpec[], { symmetries: Matrix4[]; cryst: Cryst }, string[]]{
const atoms: AtomSpec[] = [];
const assignbonds =
options.assignBonds === undefined ? true : options.assignBonds;
var noH = !options.keepH; // suppress hydrogens by default
var ignoreStruct = !!options.noSecondaryStructure;
var computeStruct = !options.noComputeSecondaryStructure;
var noAssembly = !options.doAssembly; // don't assemble by default
var selAltLoc = options.altLoc ? options.altLoc : "A"; //default alternate location to select if present
var modelData: Record<string, any> = { symmetries: [] };
var atom: any;
var remainingLines = [];
const noH = !options.keepH; // suppress hydrogens by default
const ignoreStruct = !!options.noSecondaryStructure;
const computeStruct = !options.noComputeSecondaryStructure;
const noAssembly = !options.doAssembly; // don't assemble by default
const selAltLoc = options.altLoc ? options.altLoc : "A"; //default alternate location to select if present
const modelData: { symmetries: Matrix4[]; cryst: Cryst } = {symmetries:[], cryst: undefined};
//atom name
let atom: string;
let remainingLines = [];
var serialToIndex: number[] = []; // map from pdb serial to index in atoms
var line: string | string[];
var seenbonds: Record<any, any> = {}; //sometimes connect records are duplicated as an unofficial means of relaying bond orders
const serialToIndex: number[] = []; // map from pdb serial to index in atoms
let line: string | string[];
const seenbonds: Record<string, number> = {}; //sometimes connect records are duplicated as an unofficial means of relaying bond orders
for (let i = 0; i < lines.length; i++) {
line = lines[i].replace(/^\s*/, ""); // remove indent
var recordName = line.substring(0, 6);
const recordName = line.substring(0, 6);
var startChain: string, startResi: number, endResi: number;
let startChain: string, startResi: number, endResi: number;
if (recordName.indexOf("END") == 0) {
if (recordName.indexOf("END") === 0) {
remainingLines = lines.slice(i + 1);
if (recordName == "END") {
if (recordName === "END") {
//as opposed to ENDMDL
//reset secondary structure
for (var prop in sslookup) {
for (const prop in sslookup) {
if (sslookup.hasOwnProperty(prop)) {

@@ -48,6 +53,17 @@ delete sslookup[prop];

break;
} else if (recordName == "ATOM " || recordName == "HETATM") {
var resn: any, chain: any, resi: string | number, icode: string, x: number, y: number, z: number, hetflag: boolean, elem: string | string[], serial: number, altLoc: string, b: number;
} else if (recordName === "ATOM " || recordName === "HETATM") {
let resn: string,
chain: any,
resi: string | number,
icode: string,
x: number,
y: number,
z: number,
hetflag: boolean,
elem: string | string[],
serial: number,
altLoc: string,
b: number;
altLoc = line.substring(16, 17);
if (altLoc != " " && altLoc != selAltLoc && selAltLoc != "*") continue;
if (altLoc !== " " && altLoc !== selAltLoc && selAltLoc !== "*") continue;
serial = parseInt(line.substring(6, 11));

@@ -64,3 +80,3 @@ atom = line.substring(12, 16).replace(/ /g, "");

elem = line.substring(76, 78).replace(/ /g, "");
if (elem === "" || typeof bondTable[elem] === "undefined") {
if (elem === "" || bondTable[elem] === undefined) {
// for some incorrect PDB files

@@ -72,3 +88,3 @@ elem = atomNameToElem(line.substring(12, 14), line[0] == "A");

if (elem == "H" && noH) continue;
if (elem === "H" && noH) continue;
if (recordName[0] == "H") hetflag = true;

@@ -78,18 +94,18 @@ else hetflag = false;

atoms.push({
resn: resn,
x: x,
y: y,
z: z,
elem: elem,
hetflag: hetflag,
altLoc: altLoc,
chain: chain,
resi: resi,
resn,
x,
y,
z,
elem,
hetflag,
altLoc,
chain,
resi,
icode: icode,
rescode: resi + (icode != " " ? "^" + icode : ""), // combo
rescode: resi + (icode !== " " ? "^" + icode : ""), // combo
// resi
// and
// icode
serial: serial,
atom: atom,
serial,
atom,
bonds: [],

@@ -99,6 +115,6 @@ ss: "c",

properties: {},
b: b,
b,
pdbline: line,
});
} else if (recordName == "SHEET ") {
} else if (recordName === "SHEET ") {
startChain = line.substring(21, 22);

@@ -112,19 +128,19 @@ startResi = parseInt(line.substring(22, 26));

sslookup[startChain][startResi] = "s1";
for (var res = startResi + 1; res < endResi; res++) {
for (let res = startResi + 1; res < endResi; res++) {
sslookup[startChain][res] = "s";
}
sslookup[startChain][endResi] = "s2";
} else if (recordName == "CONECT") {
} else if (recordName === "CONECT") {
// MEMO: We don't have to parse SSBOND, LINK because both are
// also
// described in CONECT. But what about 2JYT???
var from = parseInt(line.substring(6, 11));
var fromindex = serialToIndex[from];
var fromAtom = atoms[fromindex];
var coffsets = [11, 16, 21, 26];
const from = parseInt(line.substring(6, 11));
const fromindex = serialToIndex[from];
const fromAtom = atoms[fromindex];
const coffsets = [11, 16, 21, 26];
for (let j = 0; j < 4; j++) {
var to = parseInt(line.substring(coffsets[j], coffsets[j]+5));
var toindex = serialToIndex[to];
let from_to = fromindex+":"+toindex;
var toAtom = atoms[toindex];
const to = parseInt(line.substring(coffsets[j], coffsets[j] + 5));
const toindex = serialToIndex[to];
let from_to = fromindex + ":" + toindex;
const toAtom = atoms[toindex];
if (fromAtom !== undefined && toAtom !== undefined) {

@@ -136,3 +152,3 @@ // duplicated conect records indicate bond order

fromAtom.bonds.length == 0 ||
fromAtom.bonds[fromAtom.bonds.length - 1] != toindex
fromAtom.bonds[fromAtom.bonds.length - 1] !== toindex
) {

@@ -148,3 +164,3 @@ fromAtom.bonds.push(toindex);

if (fromAtom.bonds[bi] == toindex) {
var newbo = seenbonds[from_to];
const newbo = seenbonds[from_to];
if (newbo >= 4) {

@@ -161,3 +177,3 @@ //aromatic

}
} else if (recordName == "HELIX ") {
} else if (recordName === "HELIX ") {
startChain = line.substring(19, 20);

@@ -176,7 +192,7 @@ startResi = parseInt(line.substring(21, 25));

!noAssembly &&
recordName == "REMARK" &&
line.substring(13, 18) == "BIOMT"
recordName === "REMARK" &&
line.substring(13, 18) === "BIOMT"
) {
var n: number;
var matrix = new Matrix4();
let n: number;
let matrix = new Matrix4();
for (n = 1; n <= 3; n++) {

@@ -196,3 +212,3 @@ line = lines[i].replace(/^\s*/, "");

} else {
while (line.substring(13, 18) == "BIOMT") {
while (line.substring(13, 18) === "BIOMT") {
i++;

@@ -209,4 +225,9 @@ line = lines[i].replace(/^\s*/, "");

i--; // set i back
} else if (recordName == "CRYST1") {
let a: number, b: number, c: number, alpha: number, beta: number, gamma: number;
} else if (recordName === "CRYST1") {
let a: number,
b: number,
c: number,
alpha: number,
beta: number,
gamma: number;
a = parseFloat(line.substring(7, 15));

@@ -219,16 +240,16 @@ b = parseFloat(line.substring(16, 24));

modelData.cryst = {
a: a,
b: b,
c: c,
alpha: alpha,
beta: beta,
gamma: gamma,
a,
b,
c,
alpha,
beta,
gamma,
};
} else if (recordName == "ANISOU") {
let serial = parseInt(line.substring(6, 11));
var anisouAtomIndex = serialToIndex[serial];
var anisouAtom = atoms[anisouAtomIndex];
} else if (recordName === "ANISOU") {
const serial = parseInt(line.substring(6, 11));
const anisouAtomIndex = serialToIndex[serial];
const anisouAtom = atoms[anisouAtomIndex];
if (anisouAtom) {
var vals = line.substring(30).trim().split(/\s+/);
var uMat = {
const vals = line.substring(30).trim().split(/\s+/);
const uMat = {
u11: parseInt(vals[0]),

@@ -250,3 +271,3 @@ u22: parseInt(vals[1]),

// assign bonds - yuck, can't count on connect records
if (assignbonds) assignPDBBonds(atoms);
if (assignbonds) assignPDBBonds(atoms, options);

@@ -263,6 +284,6 @@ if (!noAssembly)

for (let i = 0; i < atoms.length; i++) {
atom = atoms[i];
const atom = atoms[i];
if (atom === undefined) continue;
if (atom.chain in sslookup && atom.resi in sslookup[atom.chain]) {
var code = sslookup[atom.chain][atom.resi];
const code = sslookup[atom.chain][atom.resi];
atom.ss = code[0];

@@ -269,0 +290,0 @@ if (code.length > 1) {

@@ -1,4 +0,6 @@

export function isEmpty(obj: { [x: string]: { [x: string]: any; }; hasOwnProperty?: any; }) {
var name: string;
for (name in obj) {
export function isEmpty(obj: {
[x: string]: { [x: string]: unknown };
hasOwnProperty?: any;
}) {
for (const _ in obj) {
return false;

@@ -5,0 +7,0 @@ }

@@ -1,19 +0,23 @@

import { ParserOptionsSpec } from 'parsers/ParserOptionsSpec';
import { Matrix3, conversionMatrix3, Vector3 } from '../../WebGL';
import { ParserOptionsSpec } from "parsers/ParserOptionsSpec";
import { Matrix3, conversionMatrix3, Vector3 } from "../../WebGL";
import { AtomSpec, Cryst } from "specs";
// Adds symmetry info to either duplicate and rotate/translate biological unit later or add extra atoms now
// matrices may be modified if normalization is requested
export function processSymmetries(copyMatrices: string[] | any[], atoms: any[], options: ParserOptionsSpec, cryst: { a: any; b: number; c: number; alpha: number; beta: number; gamma: number; }) {
var dontDuplicate = !options.duplicateAssemblyAtoms;
var end = atoms.length;
var offset = end;
var t: any, l: number, n: number; // Used in for loops
export function processSymmetries(
copyMatrices: string[] | any[],
atoms: AtomSpec[],
options: ParserOptionsSpec,
cryst: Cryst
) {
const dontDuplicate = !options.duplicateAssemblyAtoms;
const end = atoms.length;
let offset = end;
let modifiedIdentity = -1;
if (options.normalizeAssembly && cryst) {
//to normalize, translate every symmetry so that the centroid is
//in the unit cell. To do this, convert back to fractional coordinates,
//compute the centroid, calculate any adjustment needed to get it in [0,1],
//convert the adjustment to a cartesian translation, and then add it to
//the symmetry matrix
let conversionMatrix = conversionMatrix3(
let conversionMatrix = null;
let toFrac = null;
if ((options.normalizeAssembly || options.wrapAtoms) && cryst) {
conversionMatrix = conversionMatrix3(
cryst.a,

@@ -26,12 +30,43 @@ cryst.b,

);
let toFrac = new Matrix3();
toFrac = new Matrix3();
toFrac.getInverse3(conversionMatrix);
}
for (t = 0; t < copyMatrices.length; t++) {
let getAdjustment = function(v: Vector3) {
let c = v.clone().applyMatrix3(toFrac);
const coord = [c.x, c.y, c.z];
const adjustment = [0.0, 0.0, 0.0];
for (let i = 0; i < 3; i++) {
while (coord[i] < -0.001) {
coord[i] += 1.0;
adjustment[i] += 1.0;
}
while (coord[i] > 1.001) {
coord[i] -= 1.0;
adjustment[i] -= 1.0;
}
}
//convert adjustment to non-fractional
const adjustmentVec = new Vector3(
adjustment[0],
adjustment[1],
adjustment[2]
);
adjustmentVec.applyMatrix3(conversionMatrix);
return adjustmentVec;
};
if (options.normalizeAssembly && cryst) {
//to normalize, translate every symmetry so that the centroid is
//in the unit cell. To do this, convert back to fractional coordinates,
//compute the centroid, calculate any adjustment needed to get it in [0,1],
//convert the adjustment to a cartesian translation, and then add it to
//the symmetry matrix
for (let t = 0; t < copyMatrices.length; t++) {
//transform with the symmetry, and then back to fractional coordinates
let center = new Vector3(0, 0, 0);
for (n = 0; n < end; n++) {
let xyz = new Vector3(atoms[n].x, atoms[n].y, atoms[n].z);
const center = new Vector3(0, 0, 0);
for (let n = 0; n < end; n++) {
const xyz = new Vector3(atoms[n].x, atoms[n].y, atoms[n].z);
xyz.applyMatrix4(copyMatrices[t]);
xyz.applyMatrix3(toFrac);
//figure out

@@ -41,23 +76,9 @@ center.add(xyz);

center.divideScalar(end);
const centerCoord = [center.x, center.y, center.z];
let adjustment = [0.0, 0.0, 0.0];
for (let i = 0; i < 3; i++) {
while (centerCoord[i] < -0.001) {
centerCoord[i] += 1.0;
adjustment[i] += 1.0;
}
while (centerCoord[i] > 1.001) {
centerCoord[i] -= 1.0;
adjustment[i] -= 1.0;
}
}
//convert adjustment to non-fractional
const adjustmentVec = new Vector3(
adjustment[0],
adjustment[1],
adjustment[2]
);
adjustmentVec.applyMatrix3(conversionMatrix);
const adjustmentVec = getAdjustment(center);
//modify symmetry matrix to include translation
if (copyMatrices[t].isNearlyIdentity() && adjustmentVec.lengthSq() > 0.001) {
if (
copyMatrices[t].isNearlyIdentity() &&
adjustmentVec.lengthSq() > 0.001
) {
modifiedIdentity = t; //keep track of which matrix was identity

@@ -70,11 +91,11 @@ }

// do full assembly
for (n = 0; n < end; n++) {
for (let n = 0; n < end; n++) {
atoms[n].sym = -1; //if identity matrix is present, original labeled -1
}
for (t = 0; t < copyMatrices.length; t++) {
for (let t = 0; t < copyMatrices.length; t++) {
if (!copyMatrices[t].isNearlyIdentity() && modifiedIdentity != t) {
let xyz = new Vector3();
for (n = 0; n < end; n++) {
var bondsArr: any[] = [];
for (l = 0; l < atoms[n].bonds.length; l++) {
for (let n = 0; n < end; n++) {
const bondsArr: number[] = [];
for (let l = 0; l < atoms[n].bonds.length; l++) {
bondsArr.push(atoms[n].bonds[l] + offset);

@@ -85,4 +106,10 @@ }

var newAtom: Record<string, unknown> = {};
for (var i in atoms[n]) {
if (options.wrapAtoms && cryst) {
//wrap per-atom instead of per matrix using the centroid
let adjustment = getAdjustment(xyz);
xyz.add(adjustment);
}
const newAtom: Record<string, unknown> = {};
for (const i in atoms[n]) {
newAtom[i] = atoms[n][i];

@@ -100,3 +127,3 @@ }

} else {
for (n = 0; n < end; n++) {
for (let n = 0; n < end; n++) {
atoms[n].sym = t;

@@ -106,6 +133,20 @@ }

}
if (options.wrapAtoms && cryst) {
//wrap reference coordinates, because the world isn't kind enough
//to ensure these are in the box
let xyz = new Vector3();
for (let n = 0; n < end; n++) {
xyz.set(atoms[n].x, atoms[n].y, atoms[n].z);
//wrap per-atom instead of per matrix using the centroid
let adjustment = getAdjustment(xyz);
xyz.add(adjustment);
atoms[n].x = xyz.x;
atoms[n].y = xyz.y;
atoms[n].z = xyz.z;
}
}
if (modifiedIdentity >= 0) {
//after applying the other transformations, apply this one in place
let xyz = new Vector3();
for (n = 0; n < end; n++) {
const xyz = new Vector3();
for (let n = 0; n < end; n++) {
xyz.set(atoms[n].x, atoms[n].y, atoms[n].z);

@@ -121,5 +162,5 @@ xyz.applyMatrix4(copyMatrices[modifiedIdentity]);

} else if (copyMatrices.length > 1) {
for (t = 0; t < atoms.length; t++) {
for (let t = 0; t < atoms.length; t++) {
var symmetries: Vector3[] = [];
for (l = 0; l < copyMatrices.length; l++) {
for (let l = 0; l < copyMatrices.length; l++) {
if (!copyMatrices[l].isNearlyIdentity()) {

@@ -126,0 +167,0 @@ var newXYZ = new Vector3();

@@ -0,18 +1,20 @@

import { AtomSpec } from "specs";
// Make sure bonds are actually two way
export function validateBonds (atomsarray: string[] | any[], serialToIndex: number[]) {
for (var i = 0, n = atomsarray.length; i < n; i++) {
var atom = atomsarray[i];
for(var b = 0; b < atom.bonds.length; b++) {
var a2i = atom.bonds[b];
var atom2 = atomsarray[a2i];
var atomi = serialToIndex[atom.serial];
if(atom2 && atomi) {
var a1i = atom2.bonds.indexOf(atomi);
if(a1i < 0) {
atom2.bonds.push(atomi);
atom2.bondOrder.push(atom.bondOrder[b]);
}
}
export function validateBonds(atomsarray: AtomSpec[], serialToIndex: number[]) {
for (let i = 0, n = atomsarray.length; i < n; i++) {
const atom = atomsarray[i];
for (let b = 0; b < atom.bonds.length; b++) {
const a2i = atom.bonds[b];
const atom2 = atomsarray[a2i];
const atomi = serialToIndex[atom.serial];
if (atom2 && atomi) {
const a1i = atom2.bonds.indexOf(atomi);
if (a1i < 0) {
atom2.bonds.push(atomi);
atom2.bondOrder.push(atom.bondOrder[b]);
}
}
}
}
};
}

@@ -80,3 +80,3 @@ import { ParserOptionsSpec } from './ParserOptionsSpec';

for (let i = 0; i < atoms.length; i++) {
assignBonds(atoms[i]);
assignBonds(atoms[i], options);
}

@@ -83,0 +83,0 @@ }

// Specifications for various object types used in 3Dmol.js
// This is primarily for documentation
import { Vector3 } from "WebGL";
import { AtomStyleSpec, BondStyle, GLModel } from "./GLModel";

@@ -8,8 +9,6 @@ import { GLViewer } from "./GLViewer";

/**
* Atom representation. Depending on the input file format, not all fields may be defined.
*/
export interface AtomSpec {
export interface AtomSpec {
/** Parent residue name */

@@ -35,4 +34,4 @@ resn?: string;

resi?: number;
icode?: number;
rescode?: number;
icode?: string;
rescode?: string;
/** Atom's serial id number */

@@ -48,2 +47,4 @@ serial?: number;

ss?: string;
ssbegin?: boolean;
ssend?: boolean;
/** true if this atom forms only single bonds or no bonds at all */

@@ -79,3 +80,10 @@ singleBonds?: boolean;

contextMenuEnabled?: boolean;
};
hbondDistanceSq?: number;
hbondOther?: any;
altLoc?: string;
reschain?: number;
uMat?: Record<string, number>;
symmetries?: Vector3[];
sym?: any;
}

@@ -98,5 +106,6 @@ /**

*/
export interface AtomSelectionSpec extends Omit<AtomSpec, "bonds"|"model"|"index"|"resi"> {
export interface AtomSelectionSpec
extends Omit<AtomSpec, "bonds" | "model" | "index" | "resi"> {
/** 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). */
model?: GLModel | number | GLModel[] | number[];
model?: GLModel | number | GLModel[] | number[];
/** frame index of individual frame to style; will apply to all frames if not set */

@@ -117,16 +126,14 @@ frame?: number;

/** expands the selection to include all atoms within a given distance from the selection */
expand?: number|string;
expand?: number | string;
/** intersects the selection with the set of atoms within a given distance from another selection */
within?: WithinSelectionSpec;
/** take the intersection of the provided lists of {@link AtomSelectionSpec}s */
and?: AtomSelectionSpec[] & {__cached_results?: any};
and?: AtomSelectionSpec[] & { __cached_results?: any };
/** take the union of the provided lists of {@link AtomSelectionSpec}s */
or?: AtomSelectionSpec[] & {__cached_results?: any};
or?: AtomSelectionSpec[] & { __cached_results?: any };
/** take the inverse of the provided {@link AtomSelectionSpec} */
not?: AtomSelectionSpec;
contextMenuEnabled?: boolean;
};
}
/**

@@ -151,4 +158,12 @@ * Within selection object. Used to find the subset of an atom selection that is within

sel?: AtomSelectionSpec;
}
export type Cryst = {
a: number;
b: number;
c: number;
alpha: number;
beta: number;
gamma: number;
};
export type SelectionRange = `${number}-${number}`;

@@ -181,2 +181,7 @@ import type { Material } from './../materials/Material';

"\n";
if (material.wireframe && this.colorArray) {
//per vertex colors don't seem to work
let c = this.colorArray;
ret += indent + " emissiveColor " + c[0] + " " + c[1] + " " + c[2] + "\n";
}
if (material?.transparent) {

@@ -190,3 +195,3 @@ ret += indent + " transparency " + (1.0 - material.opacity) + "\n";

indent += " "; //inshape
if (material instanceof LineBasicMaterial) {
if (material instanceof LineBasicMaterial || material.wireframe) {
ret +=

@@ -212,3 +217,3 @@ indent +

if (this.colorArray) {
if (this.colorArray && !material.wireframe) {
ret += indent + " color Color {\n" + indent + " color [\n";

@@ -227,4 +232,13 @@ for (let i = 0; i < this.vertices; ++i) {

ret += indent + " coordIndex [\n";
for (let i = 0; i < this.vertices; i += 2) {
ret += indent + " " + i + ", " + (i + 1) + ", -1,\n";
if(material.wireframe && this.faceArray) {
for (let i = 0; i < this.faceidx; i += 3) {
x = this.faceArray?.[i];
y = this.faceArray?.[i + 1];
z = this.faceArray?.[i + 2];
ret += indent + " " + x + ", " + y + ", " + z + ", -1,\n";
}
} else {
for (let i = 0; i < this.vertices-1; i += 2) {
ret += indent + " " + i + ", " + (i + 1) + ", -1,\n";
}
}

@@ -286,3 +300,3 @@ ret += indent + " ]\n";

ret += indent + " coordIndex [\n";
for (var i = 0; i < this.faceidx; i += 3) {
for (let i = 0; i < this.faceidx; i += 3) {
x = this.faceArray?.[i];

@@ -289,0 +303,0 @@ y = this.faceArray?.[i + 1];

@@ -37,2 +37,3 @@ import {FrontSide} from "../constants/Sides";

outline = false;
wireframe = false;

@@ -39,0 +40,0 @@ setValues(

@@ -225,2 +225,6 @@ /**

getCanvas() {
return this._canvas;
}
isLost() {

@@ -227,0 +231,0 @@ return this._gl.isContextLost();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc