UNPKG

molstar

Version:

A comprehensive macromolecular library.

62 lines 2.94 kB
"use strict"; /** * Copyright (c) 2019 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.UncertaintySizeThemeProvider = exports.UncertaintySizeTheme = exports.getUncertainty = exports.getUncertaintySizeThemeParams = exports.UncertaintySizeThemeParams = void 0; var structure_1 = require("../../mol-model/structure"); var param_definition_1 = require("../../mol-util/param-definition"); var Description = "Assigns a size reflecting the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique."; exports.UncertaintySizeThemeParams = { bfactorFactor: param_definition_1.ParamDefinition.Numeric(0.1, { min: 0, max: 1, step: 0.01 }), rmsfFactor: param_definition_1.ParamDefinition.Numeric(0.05, { min: 0, max: 1, step: 0.01 }), baseSize: param_definition_1.ParamDefinition.Numeric(0.2, { min: 0, max: 2, step: 0.1 }), }; function getUncertaintySizeThemeParams(ctx) { return exports.UncertaintySizeThemeParams; // TODO return copy } exports.getUncertaintySizeThemeParams = getUncertaintySizeThemeParams; function getUncertainty(unit, element, props) { if (structure_1.Unit.isAtomic(unit)) { return unit.model.atomicConformation.B_iso_or_equiv.value(element) * props.bfactorFactor; } else if (structure_1.Unit.isSpheres(unit)) { return unit.model.coarseConformation.spheres.rmsf[element] * props.rmsfFactor; } else { return 0; } } exports.getUncertainty = getUncertainty; function UncertaintySizeTheme(ctx, props) { function size(location) { var size = props.baseSize; if (structure_1.StructureElement.Location.is(location)) { size += getUncertainty(location.unit, location.element, props); } else if (structure_1.Bond.isLocation(location)) { size += getUncertainty(location.aUnit, location.aUnit.elements[location.aIndex], props); } return size; } return { factory: UncertaintySizeTheme, granularity: 'group', size: size, props: props, description: Description }; } exports.UncertaintySizeTheme = UncertaintySizeTheme; exports.UncertaintySizeThemeProvider = { name: 'uncertainty', label: 'Uncertainty/Disorder', category: '', factory: UncertaintySizeTheme, getParams: getUncertaintySizeThemeParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.UncertaintySizeThemeParams), isApplicable: function (ctx) { return !!ctx.structure && ctx.structure.models.some(function (m) { return m.atomicConformation.B_iso_or_equiv.isDefined || m.coarseHierarchy.isDefined; }); } }; //# sourceMappingURL=uncertainty.js.map