UNPKG

pdbe-molstar

Version:
42 lines (41 loc) 2.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SequenceColorAnnotationsProperty = void 0; const tslib_1 = require("tslib"); const selector_1 = require("molstar/lib/extensions/mvs/components/selector"); const custom_structure_property_1 = require("molstar/lib/mol-model-props/common/custom-structure-property"); const custom_property_1 = require("molstar/lib/mol-model/custom-property"); const color_1 = require("molstar/lib/mol-util/color"); const names_1 = require("molstar/lib/mol-util/color/names"); const param_definition_1 = require("molstar/lib/mol-util/param-definition"); var SequenceColorAnnotationsProperty; (function (SequenceColorAnnotationsProperty) { /** Provider name (key) for this custom property */ SequenceColorAnnotationsProperty.Name = 'sequence-color-annotations'; SequenceColorAnnotationsProperty.Params = { colors: param_definition_1.ParamDefinition.ObjectList({ color: param_definition_1.ParamDefinition.Color(names_1.ColorNames.grey, { description: 'Color to apply to a substructure' }), selector: selector_1.SelectorParams, }, obj => color_1.Color.toHexStyle(obj.color), { description: 'List of substructure-color assignments' }), }; /** Provider for this custom property */ SequenceColorAnnotationsProperty.Provider = custom_structure_property_1.CustomStructureProperty.createProvider({ label: 'Sequence Color Annotations', descriptor: (0, custom_property_1.CustomPropertyDescriptor)({ name: SequenceColorAnnotationsProperty.Name, }), type: 'root', defaultParams: SequenceColorAnnotationsProperty.Params, getParams: (data) => SequenceColorAnnotationsProperty.Params, isApplicable: (data) => data.root === data, obtain: (ctx, data, props) => tslib_1.__awaiter(this, void 0, void 0, function* () { const fullProps = Object.assign(Object.assign({}, param_definition_1.ParamDefinition.getDefaultValues(SequenceColorAnnotationsProperty.Params)), props); const items = fullProps.colors.map(t => ({ // creating a copy, so we don't polute props later selector: t.selector, color: t.color, })); return { value: { items, colorCache: {} } }; }), }); })(SequenceColorAnnotationsProperty || (exports.SequenceColorAnnotationsProperty = SequenceColorAnnotationsProperty = {}));