UNPKG

molstar

Version:

A comprehensive macromolecular library.

69 lines (68 loc) 3.02 kB
"use strict"; /** * Copyright (c) 2018-2020 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.CrossLinkColorThemeProvider = exports.CrossLinkColorThemeParams = void 0; exports.getCrossLinkColorThemeParams = getCrossLinkColorThemeParams; exports.CrossLinkColorTheme = CrossLinkColorTheme; const color_1 = require("../../../mol-util/color"); const param_definition_1 = require("../../../mol-util/param-definition"); const property_1 = require("./property"); const categories_1 = require("../../../mol-theme/color/categories"); const DefaultColor = (0, color_1.Color)(0xCCCCCC); const Description = 'Colors cross-links by the deviation of the observed distance versus the modeled distance (e.g. modeled / `ihm_cross_link_restraint.distance_threshold`).'; exports.CrossLinkColorThemeParams = { domain: param_definition_1.ParamDefinition.Interval([0.5, 1.5], { step: 0.01 }), list: param_definition_1.ParamDefinition.ColorList('red-grey', { presetKind: 'scale' }), }; function getCrossLinkColorThemeParams(ctx) { return exports.CrossLinkColorThemeParams; // TODO return copy } function CrossLinkColorTheme(ctx, props) { let color; let scale = undefined; const crossLinkRestraints = ctx.structure && property_1.CrossLinkRestraintProvider.get(ctx.structure).value; if (crossLinkRestraints) { scale = color_1.ColorScale.create({ domain: props.domain, listOrName: props.list.colors }); const scaleColor = scale.color; color = (location) => { if (property_1.CrossLinkRestraint.isLocation(location)) { const pair = crossLinkRestraints.pairs[location.element]; if (pair) { return scaleColor(property_1.CrossLinkRestraint.distance(pair) / pair.distanceThreshold); } } return DefaultColor; }; } else { color = () => DefaultColor; } return { factory: CrossLinkColorTheme, granularity: 'group', color, props, description: Description, legend: scale ? scale.legend : undefined }; } exports.CrossLinkColorThemeProvider = { name: 'cross-link', label: 'Cross Link', category: categories_1.ColorThemeCategory.Misc, factory: CrossLinkColorTheme, getParams: getCrossLinkColorThemeParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.CrossLinkColorThemeParams), isApplicable: (ctx) => !!ctx.structure && property_1.CrossLinkRestraint.isApplicable(ctx.structure), ensureCustomProperties: { attach: (ctx, data) => data.structure ? property_1.CrossLinkRestraintProvider.attach(ctx, data.structure, void 0, true) : Promise.resolve(), detach: (data) => data.structure && property_1.CrossLinkRestraintProvider.ref(data.structure, false) } };