UNPKG

molstar

Version:

A comprehensive macromolecular library.

55 lines (54 loc) 3.35 kB
"use strict"; /** * 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> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfalPyramidsPreset = void 0; exports.confalPyramidLabel = confalPyramidLabel; const color_1 = require("./color"); const property_1 = require("./property"); const representation_1 = require("./representation"); const property_2 = require("../property"); const representation_preset_1 = require("../../../mol-plugin-state/builder/structure/representation-preset"); const mol_state_1 = require("../../../mol-state"); const mol_task_1 = require("../../../mol-task"); exports.ConfalPyramidsPreset = (0, representation_preset_1.StructureRepresentationPresetProvider)({ id: 'preset-structure-representation-confal-pyramids', display: { name: 'Confal Pyramids', group: 'Annotation', description: 'Schematic depiction of conformer class and confal value.', }, isApplicable(a) { return a.data.models.length >= 1 && a.data.models.some(m => property_2.Dnatco.isApplicable(m)); }, params: () => representation_preset_1.StructureRepresentationPresetProvider.CommonParams, async apply(ref, params, plugin) { var _a; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); const model = (_a = structureCell === null || structureCell === void 0 ? void 0 : structureCell.obj) === null || _a === void 0 ? void 0 : _a.data.model; if (!structureCell || !model) return {}; await plugin.runTask(mol_task_1.Task.create('Confal Pyramids', async (runtime) => { await property_1.ConfalPyramidsProvider.attach({ runtime, assetManager: plugin.managers.asset, errorContext: plugin.errorContext }, model); })); const { components, representations } = await representation_preset_1.PresetStructureRepresentations.auto.apply(ref, { ...params }, plugin); const pyramids = await plugin.builders.structure.tryCreateComponentStatic(structureCell, 'nucleic', { label: 'Confal Pyramids' }); const { update, builder, typeParams } = representation_preset_1.StructureRepresentationPresetProvider.reprBuilder(plugin, params); let pyramidsRepr; if (representations) pyramidsRepr = builder.buildRepresentation(update, pyramids, { type: representation_1.ConfalPyramidsRepresentationProvider, typeParams, color: color_1.ConfalPyramidsColorThemeProvider }, { tag: 'confal-pyramdis' }); await update.commit({ revertOnError: true }); return { components: { ...components, pyramids }, representations: { ...representations, pyramidsRepr } }; } }); function confalPyramidLabel(step) { return ` <b>${step.auth_asym_id_1}</b> | <b>${step.label_comp_id_1} ${step.auth_seq_id_1}${step.PDB_ins_code_1}${step.label_alt_id_1.length > 0 ? ` (alt ${step.label_alt_id_1})` : ''} ${step.label_comp_id_2} ${step.auth_seq_id_2}${step.PDB_ins_code_2}${step.label_alt_id_2.length > 0 ? ` (alt ${step.label_alt_id_2})` : ''} </b><br /> <i>NtC:</i> ${step.NtC} | <i>Confal score:</i> ${step.confal_score} | <i>RMSD:</i> ${step.rmsd.toFixed(2)} `; }