UNPKG

molstar

Version:

A comprehensive macromolecular library.

120 lines 6.72 kB
/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { __assign, __awaiter, __generator } from "tslib"; import { Task } from '../../../mol-task'; // import { BitFlags } from '../../../mol-util'; import { ParamDefinition as PD } from '../../../mol-util/param-definition'; import { Vec3 } from '../../../mol-math/linear-algebra'; import { StructureProperties } from '../../../mol-model/structure'; import { assignRadiusForHeavyAtoms } from './shrake-rupley/radii'; import { VdWLookup, MaxAsa, DefaultMaxAsa } from './shrake-rupley/common'; import { computeArea } from './shrake-rupley/area'; import { SortedArray } from '../../../mol-data/int'; export var ShrakeRupleyComputationParams = { numberOfSpherePoints: PD.Numeric(92, { min: 12, max: 360, step: 1 }, { description: 'Number of sphere points to sample per atom: 92 (original paper), 960 (BioJava), 3000 (EPPIC) - see Shrake A, Rupley JA: Environment and exposure to solvent of protein atoms. Lysozyme and insulin. J Mol Biol 1973.' }), probeSize: PD.Numeric(1.4, { min: 0.1, max: 4, step: 0.01 }, { description: 'Corresponds to the size of a water molecule: 1.4 (original paper), 1.5 (occassionally used)' }), // buriedRasaThreshold: PD.Numeric(0.16, { min: 0.0, max: 1.0 }, { description: 'below this cutoff of relative accessible surface area a residue will be considered buried - see: Rost B, Sander C: Conservation and prediction of solvent accessibility in protein families. Proteins 1994.' }), nonPolymer: PD.Boolean(false, { description: 'Include non-polymer atoms as occluders.' }), traceOnly: PD.Boolean(false, { description: 'Compute only using alpha-carbons, if true increase probeSize accordingly (e.g., 4 A). Considers only canonical amino acids.' }) }; // TODO // - add back buried and relative asa export { AccessibleSurfaceArea }; var AccessibleSurfaceArea; (function (AccessibleSurfaceArea) { /** * Adapts the BioJava implementation by Jose Duarte. That implementation is based on the publication by Shrake, A., and * J. A. Rupley. "Environment and Exposure to Solvent of Protein Atoms. Lysozyme and Insulin." JMB (1973). */ function compute(structure, props) { var _this = this; if (props === void 0) { props = {}; } var p = __assign(__assign({}, PD.getDefaultValues(ShrakeRupleyComputationParams)), props); return Task.create('Compute Accessible Surface Area', function (runtime) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, calculate(runtime, structure, p)]; case 1: return [2 /*return*/, _a.sent()]; } }); }); }); } AccessibleSurfaceArea.compute = compute; function calculate(runtime, structure, props) { return __awaiter(this, void 0, void 0, function () { var ctx, area, serialResidueIndex; return __generator(this, function (_a) { switch (_a.label) { case 0: ctx = initialize(structure, props); assignRadiusForHeavyAtoms(ctx); return [4 /*yield*/, computeArea(runtime, ctx)]; case 1: _a.sent(); area = ctx.area, serialResidueIndex = ctx.serialResidueIndex; return [2 /*return*/, { area: area, serialResidueIndex: serialResidueIndex }]; } }); }); } function initialize(structure, props) { var elementCount = structure.elementCount, atomicResidueCount = structure.atomicResidueCount; var probeSize = props.probeSize, nonPolymer = props.nonPolymer, traceOnly = props.traceOnly, numberOfSpherePoints = props.numberOfSpherePoints; return { structure: structure, probeSize: probeSize, nonPolymer: nonPolymer, traceOnly: traceOnly, spherePoints: generateSpherePoints(numberOfSpherePoints), scalingConstant: 4.0 * Math.PI / numberOfSpherePoints, maxLookupRadius: 2 * props.probeSize + 2 * VdWLookup[2], atomRadiusType: new Int8Array(elementCount), serialResidueIndex: new Int32Array(elementCount), area: new Float32Array(atomicResidueCount) }; } /** Creates a collection of points on a sphere by the Golden Section Spiral algorithm. */ function generateSpherePoints(numberOfSpherePoints) { var points = []; var inc = Math.PI * (3.0 - Math.sqrt(5.0)); var offset = 2.0 / numberOfSpherePoints; for (var k = 0; k < numberOfSpherePoints; ++k) { var y = k * offset - 1.0 + (offset / 2.0); var r = Math.sqrt(1.0 - y * y); var phi = k * inc; points[points.length] = Vec3.create(Math.cos(phi) * r, y, Math.sin(phi) * r); } return points; } /** Get relative area for a given component id */ function normalize(compId, asa) { var maxAsa = MaxAsa[compId] || DefaultMaxAsa; return asa / maxAsa; } AccessibleSurfaceArea.normalize = normalize; function getValue(location, accessibleSurfaceArea) { var area = accessibleSurfaceArea.area, serialResidueIndex = accessibleSurfaceArea.serialResidueIndex; var rSI = serialResidueIndex[SortedArray.indexOf(SortedArray.ofSortedArray(location.structure.root.serialMapping.elementIndices), location.element)]; if (rSI === -1) return -1; return area[rSI]; } AccessibleSurfaceArea.getValue = getValue; function getNormalizedValue(location, accessibleSurfaceArea) { var value = getValue(location, accessibleSurfaceArea); return value === -1 ? -1 : normalize(StructureProperties.atom.label_comp_id(location), value); } AccessibleSurfaceArea.getNormalizedValue = getNormalizedValue; function getFlag(location, accessibleSurfaceArea) { var value = getNormalizedValue(location, accessibleSurfaceArea); return value === -1 ? 0 /* NA */ : value < 0.16 ? 1 /* Buried */ : 2 /* Accessible */; } AccessibleSurfaceArea.getFlag = getFlag; })(AccessibleSurfaceArea || (AccessibleSurfaceArea = {})); //# sourceMappingURL=shrake-rupley.js.map