UNPKG

molstar

Version:

A comprehensive macromolecular library.

70 lines 3.57 kB
"use strict"; /** * Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BestDatabaseSequenceMapping = void 0; var tslib_1 = require("tslib"); var int_1 = require("../../../../../mol-data/int"); var best_database_mapping_1 = require("../../../../../mol-model-props/sequence/best-database-mapping"); var best_database_mapping_2 = require("../../../../../mol-model-props/sequence/themes/best-database-mapping"); var structure_1 = require("../../../../../mol-model/structure"); var param_definition_1 = require("../../../../../mol-util/param-definition"); var behavior_1 = require("../../../behavior"); exports.BestDatabaseSequenceMapping = behavior_1.PluginBehavior.create({ name: 'best-sequence-database-mapping-prop', category: 'custom-props', display: { name: 'Best Database Sequence Mapping' }, ctor: /** @class */ (function (_super) { (0, tslib_1.__extends)(class_1, _super); function class_1() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.provider = best_database_mapping_1.BestDatabaseSequenceMapping.Provider; _this.labelProvider = { label: function (loci) { if (!_this.params.showTooltip) return; return bestDatabaseSequenceMappingLabel(loci); } }; return _this; } class_1.prototype.update = function (p) { var updated = (this.params.autoAttach !== p.autoAttach || this.params.showTooltip !== p.showTooltip); this.params.autoAttach = p.autoAttach; this.params.showTooltip = p.showTooltip; this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach); return updated; }; class_1.prototype.register = function () { this.ctx.customModelProperties.register(this.provider, this.params.autoAttach); this.ctx.representation.structure.themes.colorThemeRegistry.add(best_database_mapping_2.BestDatabaseSequenceMappingColorThemeProvider); this.ctx.managers.lociLabels.addProvider(this.labelProvider); }; class_1.prototype.unregister = function () { this.ctx.customModelProperties.unregister(this.provider.descriptor.name); this.ctx.representation.structure.themes.colorThemeRegistry.remove(best_database_mapping_2.BestDatabaseSequenceMappingColorThemeProvider); this.ctx.managers.lociLabels.removeProvider(this.labelProvider); }; return class_1; }(behavior_1.PluginBehavior.Handler)), params: function () { return ({ autoAttach: param_definition_1.ParamDefinition.Boolean(true), showTooltip: param_definition_1.ParamDefinition.Boolean(true) }); } }); // function bestDatabaseSequenceMappingLabel(loci) { if (loci.kind === 'element-loci') { if (loci.elements.length === 0) return; var e = loci.elements[0]; var u = e.unit; var se = structure_1.StructureElement.Location.create(loci.structure, u, u.elements[int_1.OrderedSet.getAt(e.indices, 0)]); return best_database_mapping_1.BestDatabaseSequenceMapping.getLabel(se); } } //# sourceMappingURL=best-database-mapping.js.map