UNPKG

molstar

Version:

A comprehensive macromolecular library.

115 lines (114 loc) 6.94 kB
"use strict"; /** * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Ludovic Autin <ludovic.autin@gmail.com> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CellpackMembranePreset = exports.CellpackMembranePresetParams = exports.CellpackPackingPreset = exports.CellpackPackingPresetParams = void 0; var tslib_1 = require("tslib"); var mol_state_1 = require("../../mol-state"); var representation_preset_1 = require("../../mol-plugin-state/builder/structure/representation-preset"); var param_definition_1 = require("../../mol-util/param-definition"); var names_1 = require("../../mol-util/color/names"); var generate_1 = require("./color/generate"); exports.CellpackPackingPresetParams = { traceOnly: param_definition_1.ParamDefinition.Boolean(true), ignoreLight: param_definition_1.ParamDefinition.Boolean(false), representation: param_definition_1.ParamDefinition.Select('gaussian-surface', param_definition_1.ParamDefinition.arrayToOptions(['gaussian-surface', 'spacefill', 'point', 'orientation'])), }; exports.CellpackPackingPreset = (0, representation_preset_1.StructureRepresentationPresetProvider)({ id: 'preset-structure-representation-cellpack-packing', display: { name: 'CellPack Packing' }, params: function () { return exports.CellpackPackingPresetParams; }, apply: function (ref, params, plugin) { return tslib_1.__awaiter(this, void 0, void 0, function () { var structureCell, reprProps, components, color, _a, update, builder, typeParams, representations; var _b; return tslib_1.__generator(this, function (_c) { switch (_c.label) { case 0: structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return [2 /*return*/, {}]; reprProps = { ignoreHydrogens: true, traceOnly: params.traceOnly, instanceGranularity: true, ignoreLight: params.ignoreLight, }; _b = {}; return [4 /*yield*/, (0, representation_preset_1.presetStaticComponent)(plugin, structureCell, 'polymer')]; case 1: components = (_b.polymer = _c.sent(), _b); if (params.representation === 'gaussian-surface') { Object.assign(reprProps, { quality: 'custom', resolution: 10, radiusOffset: 2, doubleSided: false }); } else if (params.representation === 'spacefill') { Object.assign(reprProps, { sizeFactor: params.traceOnly ? 2 : 1 }); } color = generate_1.CellPackGenerateColorThemeProvider.name; _a = representation_preset_1.StructureRepresentationPresetProvider.reprBuilder(plugin, {}), update = _a.update, builder = _a.builder, typeParams = _a.typeParams; representations = { polymer: builder.buildRepresentation(update, components.polymer, { type: params.representation, typeParams: tslib_1.__assign(tslib_1.__assign({}, typeParams), reprProps), color: color }, { tag: 'polymer' }) }; return [4 /*yield*/, update.commit({ revertOnError: true })]; case 2: _c.sent(); return [2 /*return*/, { components: components, representations: representations }]; } }); }); } }); // exports.CellpackMembranePresetParams = { ignoreLight: param_definition_1.ParamDefinition.Boolean(false), representation: param_definition_1.ParamDefinition.Select('gaussian-surface', param_definition_1.ParamDefinition.arrayToOptions(['gaussian-surface', 'spacefill', 'point', 'orientation'])), }; exports.CellpackMembranePreset = (0, representation_preset_1.StructureRepresentationPresetProvider)({ id: 'preset-structure-representation-cellpack-membrane', display: { name: 'CellPack Membrane' }, params: function () { return exports.CellpackMembranePresetParams; }, apply: function (ref, params, plugin) { return tslib_1.__awaiter(this, void 0, void 0, function () { var structureCell, reprProps, components, _a, update, builder, typeParams, representations; var _b; return tslib_1.__generator(this, function (_c) { switch (_c.label) { case 0: structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return [2 /*return*/, {}]; reprProps = { ignoreHydrogens: true, instanceGranularity: true, ignoreLight: params.ignoreLight, }; _b = {}; return [4 /*yield*/, (0, representation_preset_1.presetStaticComponent)(plugin, structureCell, 'all', { label: 'Membrane' })]; case 1: components = (_b.membrane = _c.sent(), _b); if (params.representation === 'gaussian-surface') { Object.assign(reprProps, { quality: 'custom', resolution: 10, radiusOffset: 2, doubleSided: false }); } _a = representation_preset_1.StructureRepresentationPresetProvider.reprBuilder(plugin, {}), update = _a.update, builder = _a.builder, typeParams = _a.typeParams; representations = { membrane: builder.buildRepresentation(update, components.membrane, { type: params.representation, typeParams: tslib_1.__assign(tslib_1.__assign({}, typeParams), reprProps), color: 'uniform', colorParams: { value: names_1.ColorNames.lightgrey } }, { tag: 'all' }) }; return [4 /*yield*/, update.commit({ revertOnError: true })]; case 2: _c.sent(); return [2 /*return*/, { components: components, representations: representations }]; } }); }); } });