molstar
Version:
A comprehensive macromolecular library.
104 lines (103 loc) • 7.24 kB
JavaScript
/**
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeStructureGaussianDensityTexture2d = exports.computeStructureGaussianDensityTexture = exports.computeStructureGaussianDensity = exports.computeUnitGaussianDensityTexture2d = exports.computeUnitGaussianDensityTexture = exports.computeUnitGaussianDensity = exports.getTextureMaxCells = exports.DefaultGaussianDensityProps = exports.GaussianDensityParams = void 0;
var tslib_1 = require("tslib");
var mol_task_1 = require("../../../../mol-task");
var param_definition_1 = require("../../../../mol-util/param-definition");
var gpu_1 = require("../../../../mol-math/geometry/gaussian-density/gpu");
var common_1 = require("./common");
var base_1 = require("../../../../mol-geo/geometry/base");
var cpu_1 = require("../../../../mol-math/geometry/gaussian-density/cpu");
exports.GaussianDensityParams = tslib_1.__assign({ resolution: param_definition_1.ParamDefinition.Numeric(1, { min: 0.1, max: 20, step: 0.1 }, tslib_1.__assign({ description: 'Grid resolution/cell spacing.' }, base_1.BaseGeometry.CustomQualityParamInfo)), radiusOffset: param_definition_1.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, { description: 'Extra/offset radius added to the atoms/coarse elements for gaussian calculation. Useful to create coarse, low resolution surfaces.' }), smoothness: param_definition_1.ParamDefinition.Numeric(1.5, { min: 0.5, max: 2.5, step: 0.1 }, { description: 'Smoothness of the gausian surface, lower is smoother.' }) }, common_1.CommonSurfaceParams);
exports.DefaultGaussianDensityProps = param_definition_1.ParamDefinition.getDefaultValues(exports.GaussianDensityParams);
//
function getTextureMaxCells(webgl, structure) {
var d = webgl.maxTextureSize / 3;
return (d * d) / Math.max(1, (structure ? structure.units.length / 16 : 1));
}
exports.getTextureMaxCells = getTextureMaxCells;
//
function computeUnitGaussianDensity(structure, unit, sizeTheme, props) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props);
var _a = (0, common_1.getUnitConformationAndRadius)(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, cpu_1.GaussianDensityCPU)(ctx, position, box, radius, p)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
}
exports.computeUnitGaussianDensity = computeUnitGaussianDensity;
function computeUnitGaussianDensityTexture(structure, unit, sizeTheme, props, webgl, texture) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props, getTextureMaxCells(webgl, structure));
var _a = (0, common_1.getUnitConformationAndRadius)(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, (0, gpu_1.GaussianDensityTexture)(webgl, position, box, radius, p, texture)];
});
}); });
}
exports.computeUnitGaussianDensityTexture = computeUnitGaussianDensityTexture;
function computeUnitGaussianDensityTexture2d(structure, unit, sizeTheme, powerOfTwo, props, webgl, texture) {
var _this = this;
var box = unit.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props, getTextureMaxCells(webgl, structure));
var _a = (0, common_1.getUnitConformationAndRadius)(structure, unit, sizeTheme, p), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, (0, gpu_1.GaussianDensityTexture2d)(webgl, position, box, radius, powerOfTwo, p, texture)];
});
}); });
}
exports.computeUnitGaussianDensityTexture2d = computeUnitGaussianDensityTexture2d;
//
function computeStructureGaussianDensity(structure, sizeTheme, props) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props);
var _a = (0, common_1.getStructureConformationAndRadius)(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, cpu_1.GaussianDensityCPU)(ctx, position, box, radius, p)];
case 1: return [2 /*return*/, _a.sent()];
}
});
}); });
}
exports.computeStructureGaussianDensity = computeStructureGaussianDensity;
function computeStructureGaussianDensityTexture(structure, sizeTheme, props, webgl, texture) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props, getTextureMaxCells(webgl));
var _a = (0, common_1.getStructureConformationAndRadius)(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, (0, gpu_1.GaussianDensityTexture)(webgl, position, box, radius, p, texture)];
});
}); });
}
exports.computeStructureGaussianDensityTexture = computeStructureGaussianDensityTexture;
function computeStructureGaussianDensityTexture2d(structure, sizeTheme, powerOfTwo, props, webgl, texture) {
var _this = this;
var box = structure.lookup3d.boundary.box;
var p = (0, common_1.ensureReasonableResolution)(box, props, getTextureMaxCells(webgl));
var _a = (0, common_1.getStructureConformationAndRadius)(structure, sizeTheme, props.ignoreHydrogens, props.traceOnly), position = _a.position, radius = _a.radius;
return mol_task_1.Task.create('Gaussian Density', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, (0, gpu_1.GaussianDensityTexture2d)(webgl, position, box, radius, powerOfTwo, p, texture)];
});
}); });
}
exports.computeStructureGaussianDensityTexture2d = computeStructureGaussianDensityTexture2d;
;