UNPKG

molstar

Version:

A comprehensive macromolecular library.

112 lines (111 loc) 7.21 kB
/** * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Michal Malý <michal.maly@ibt.cas.cz> * @author Jiří Černý <jiri.cerny@ibt.cas.cz> */ import { __assign, __awaiter, __extends, __generator } from "tslib"; import { ConfalPyramidsColorThemeProvider } from './color'; import { ConfalPyramids, ConfalPyramidsProvider } from './property'; import { ConfalPyramidsRepresentationProvider } from './representation'; import { PluginBehavior } from '../../../mol-plugin/behavior/behavior'; import { StructureRepresentationPresetProvider, PresetStructureRepresentations } from '../../../mol-plugin-state/builder/structure/representation-preset'; import { StateObjectRef } from '../../../mol-state'; import { Task } from '../../../mol-task'; import { ParamDefinition as PD } from '../../../mol-util/param-definition'; export var DnatcoConfalPyramidsPreset = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-confal-pyramids', display: { name: 'Confal Pyramids', group: 'Annotation', description: 'Schematic depiction of conformer class and confal value.', }, isApplicable: function (a) { return a.data.models.length >= 1 && a.data.models.some(function (m) { return ConfalPyramids.isApplicable(m); }); }, params: function () { return StructureRepresentationPresetProvider.CommonParams; }, apply: function (ref, params, plugin) { var _a; return __awaiter(this, void 0, void 0, function () { var structureCell, model, _b, components, representations, pyramids, _c, update, builder, typeParams, pyramidsRepr; var _this = this; return __generator(this, function (_d) { switch (_d.label) { case 0: structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref); model = (_a = structureCell === null || structureCell === void 0 ? void 0 : structureCell.obj) === null || _a === void 0 ? void 0 : _a.data.model; if (!structureCell || !model) return [2 /*return*/, {}]; return [4 /*yield*/, plugin.runTask(Task.create('Confal Pyramids', function (runtime) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ConfalPyramidsProvider.attach({ runtime: runtime, assetManager: plugin.managers.asset }, model)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }))]; case 1: _d.sent(); return [4 /*yield*/, PresetStructureRepresentations.auto.apply(ref, __assign({}, params), plugin)]; case 2: _b = _d.sent(), components = _b.components, representations = _b.representations; return [4 /*yield*/, plugin.builders.structure.tryCreateComponentStatic(structureCell, 'nucleic', { label: 'Confal Pyramids' })]; case 3: pyramids = _d.sent(); _c = StructureRepresentationPresetProvider.reprBuilder(plugin, params), update = _c.update, builder = _c.builder, typeParams = _c.typeParams; if (representations) pyramidsRepr = builder.buildRepresentation(update, pyramids, { type: ConfalPyramidsRepresentationProvider, typeParams: typeParams, color: ConfalPyramidsColorThemeProvider }, { tag: 'confal-pyramdis' }); return [4 /*yield*/, update.commit({ revertOnError: true })]; case 4: _d.sent(); return [2 /*return*/, { components: __assign(__assign({}, components), { pyramids: pyramids }), representations: __assign(__assign({}, representations), { pyramidsRepr: pyramidsRepr }) }]; } }); }); } }); export var DnatcoConfalPyramids = PluginBehavior.create({ name: 'dnatco-confal-pyramids-prop', category: 'custom-props', display: { name: 'Confal Pyramids', description: 'Schematic depiction of conformer class and confal value.', }, ctor: /** @class */ (function (_super) { __extends(class_1, _super); function class_1() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.provider = ConfalPyramidsProvider; return _this; } class_1.prototype.register = function () { this.ctx.customModelProperties.register(this.provider, this.params.autoAttach); this.ctx.representation.structure.themes.colorThemeRegistry.add(ConfalPyramidsColorThemeProvider); this.ctx.representation.structure.registry.add(ConfalPyramidsRepresentationProvider); this.ctx.builders.structure.representation.registerPreset(DnatcoConfalPyramidsPreset); }; class_1.prototype.update = function (p) { var updated = this.params.autoAttach !== p.autoAttach; this.params.autoAttach = p.autoAttach; this.params.showToolTip = p.showToolTip; this.ctx.customModelProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach); return updated; }; class_1.prototype.unregister = function () { this.ctx.customModelProperties.unregister(ConfalPyramidsProvider.descriptor.name); this.ctx.representation.structure.registry.remove(ConfalPyramidsRepresentationProvider); this.ctx.representation.structure.themes.colorThemeRegistry.remove(ConfalPyramidsColorThemeProvider); this.ctx.builders.structure.representation.unregisterPreset(DnatcoConfalPyramidsPreset); }; return class_1; }(PluginBehavior.Handler)), params: function () { return ({ autoAttach: PD.Boolean(true), showToolTip: PD.Boolean(true) }); } }); export function confalPyramidLabel(halfPyramid) { var step = halfPyramid.step; return "\n <b>".concat(step.auth_asym_id_1, "</b> |\n <b>").concat(step.label_comp_id_1, " ").concat(step.auth_seq_id_1).concat(step.PDB_ins_code_1).concat(step.label_alt_id_1.length > 0 ? " (alt ".concat(step.label_alt_id_1, ")") : '', "\n ").concat(step.label_comp_id_2, " ").concat(step.auth_seq_id_2).concat(step.PDB_ins_code_2).concat(step.label_alt_id_2.length > 0 ? " (alt ".concat(step.label_alt_id_2, ")") : '', " </b><br />\n <i>NtC:</i> ").concat(step.NtC, " | <i>Confal score:</i> ").concat(step.confal_score, " | <i>RMSD:</i> ").concat(step.rmsd.toFixed(2), "\n "); }