UNPKG

molstar

Version:

A comprehensive macromolecular library.

460 lines (459 loc) 30.5 kB
"use strict"; /** * Copyright (c) 2019-2025 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Adam Midlik <midlik@gmail.com> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PresetStructureRepresentations = void 0; exports.StructureRepresentationPresetProvider = StructureRepresentationPresetProvider; exports.presetStaticComponent = presetStaticComponent; exports.presetSelectionComponent = presetSelectionComponent; const param_definition_1 = require("../../../mol-util/param-definition"); const base_1 = require("../../../mol-geo/geometry/base"); const structure_1 = require("../../../mol-model/structure"); const mol_state_1 = require("../../../mol-state"); const structure_selection_query_1 = require("../../helpers/structure-selection-query"); const config_1 = require("../../../mol-plugin/config"); const structure_focus_representation_1 = require("../../../mol-plugin/behavior/dynamic/selection/structure-focus-representation"); const structure_representation_params_1 = require("../../helpers/structure-representation-params"); const chain_id_1 = require("../../../mol-theme/color/chain-id"); const operator_name_1 = require("../../../mol-theme/color/operator-name"); const index_pair_1 = require("../../../mol-model-formats/structure/property/bonds/index-pair"); const struct_conn_1 = require("../../../mol-model-formats/structure/property/bonds/struct_conn"); const type_helpers_1 = require("../../../mol-util/type-helpers"); const vec3_1 = require("../../../mol-math/linear-algebra/3d/vec3"); function StructureRepresentationPresetProvider(repr) { return repr; } (function (StructureRepresentationPresetProvider) { StructureRepresentationPresetProvider.CommonParams = { ignoreHydrogens: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Boolean(false)), ignoreHydrogensVariant: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Select('all', param_definition_1.ParamDefinition.arrayToOptions(['all', 'non-polar']))), ignoreLight: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Boolean(false)), quality: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Select('auto', base_1.VisualQualityOptions)), theme: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Group({ globalName: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Text('')), globalColorParams: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Value({}, { isHidden: true })), carbonColor: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Select('chain-id', param_definition_1.ParamDefinition.arrayToOptions(['chain-id', 'operator-name', 'element-symbol']))), symmetryColor: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Text('')), symmetryColorParams: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Value({}, { isHidden: true })), focus: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Group({ name: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Text('')), params: param_definition_1.ParamDefinition.Optional(param_definition_1.ParamDefinition.Value({})) })) })) }; function getCarbonColorParams(name) { return name === 'chain-id' ? { name, params: chain_id_1.ChainIdColorThemeProvider.defaultValues } : name === 'operator-name' ? { name, params: operator_name_1.OperatorNameColorThemeProvider.defaultValues } : { name, params: {} }; } function isSymmetry(structure) { return structure.units.some(u => !u.conformation.operator.assembly && u.conformation.operator.spgrOp >= 0); } function reprBuilder(plugin, params, structure) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p; const update = plugin.state.data.build(); const builder = plugin.builders.structure.representation; const h = plugin.managers.structure.component.state.options.hydrogens; const typeParams = { quality: plugin.managers.structure.component.state.options.visualQuality, ignoreHydrogens: h !== 'all', ignoreHydrogensVariant: (h === 'only-polar' ? 'non-polar' : 'all'), ignoreLight: plugin.managers.structure.component.state.options.ignoreLight, }; if (params.quality && params.quality !== 'auto') typeParams.quality = params.quality; if (params.ignoreHydrogens !== void 0) typeParams.ignoreHydrogens = !!params.ignoreHydrogens; if (params.ignoreHydrogensVariant !== void 0) typeParams.ignoreHydrogensVariant = params.ignoreHydrogensVariant; if (params.ignoreLight !== void 0) typeParams.ignoreLight = !!params.ignoreLight; const color = ((_a = params.theme) === null || _a === void 0 ? void 0 : _a.globalName) ? (_b = params.theme) === null || _b === void 0 ? void 0 : _b.globalName : void 0; const ballAndStickColor = ((_c = params.theme) === null || _c === void 0 ? void 0 : _c.carbonColor) !== undefined ? { carbonColor: getCarbonColorParams((_d = params.theme) === null || _d === void 0 ? void 0 : _d.carbonColor), ...(_e = params.theme) === null || _e === void 0 ? void 0 : _e.globalColorParams } : { ...(_f = params.theme) === null || _f === void 0 ? void 0 : _f.globalColorParams }; const symmetryColor = structure && ((_g = params.theme) === null || _g === void 0 ? void 0 : _g.symmetryColor) ? isSymmetry(structure) ? (_h = params.theme) === null || _h === void 0 ? void 0 : _h.symmetryColor : color : color; const symmetryColorParams = ((_j = params.theme) === null || _j === void 0 ? void 0 : _j.symmetryColorParams) ? { ...(_k = params.theme) === null || _k === void 0 ? void 0 : _k.globalColorParams, ...(_l = params.theme) === null || _l === void 0 ? void 0 : _l.symmetryColorParams } : { ...(_m = params.theme) === null || _m === void 0 ? void 0 : _m.globalColorParams }; const globalColorParams = ((_o = params.theme) === null || _o === void 0 ? void 0 : _o.globalColorParams) ? { ...(_p = params.theme) === null || _p === void 0 ? void 0 : _p.globalColorParams } : undefined; return { update, builder, color, symmetryColor, symmetryColorParams, globalColorParams, typeParams, ballAndStickColor }; } StructureRepresentationPresetProvider.reprBuilder = reprBuilder; function updateFocusRepr(plugin, structure, themeName, themeParams) { if (!plugin.state.hasBehavior(structure_focus_representation_1.StructureFocusRepresentation)) return; return plugin.state.updateBehavior(structure_focus_representation_1.StructureFocusRepresentation, p => { const c = (0, structure_representation_params_1.createStructureColorThemeParams)(plugin, structure, 'ball-and-stick', themeName || 'element-symbol', themeParams); p.surroundingsParams.colorTheme = c; p.targetParams.colorTheme = c; }); } StructureRepresentationPresetProvider.updateFocusRepr = updateFocusRepr; })(StructureRepresentationPresetProvider || (exports.StructureRepresentationPresetProvider = StructureRepresentationPresetProvider = {})); const CommonParams = StructureRepresentationPresetProvider.CommonParams; const reprBuilder = StructureRepresentationPresetProvider.reprBuilder; const updateFocusRepr = StructureRepresentationPresetProvider.updateFocusRepr; const auto = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-auto', display: { name: 'Automatic', description: 'Show representations based on the size of the structure. Smaller structures are shown with more detail than larger ones, ranging from atomistic display to coarse surfaces.' }, params: () => CommonParams, apply(ref, params, plugin) { var _a, _b; const structure = (_b = (_a = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref)) === null || _a === void 0 ? void 0 : _a.obj) === null || _b === void 0 ? void 0 : _b.data; if (!structure) return {}; const thresholds = plugin.config.get(config_1.PluginConfig.Structure.SizeThresholds) || structure_1.Structure.DefaultSizeThresholds; const size = structure_1.Structure.getSize(structure, thresholds); const gapFraction = structure.polymerResidueCount / structure.polymerGapCount; switch (size) { case structure_1.Structure.Size.Gigantic: case structure_1.Structure.Size.Huge: return coarseSurface.apply(ref, params, plugin); case structure_1.Structure.Size.Large: return polymerCartoon.apply(ref, params, plugin); case structure_1.Structure.Size.Medium: if (gapFraction > 3) { return polymerAndLigand.apply(ref, params, plugin); } // else fall through case structure_1.Structure.Size.Small: // `showCarbohydrateSymbol: true` is nice, e.g., for PDB 1aga return atomicDetail.apply(ref, { ...params, showCarbohydrateSymbol: true }, plugin); default: (0, type_helpers_1.assertUnreachable)(size); } } }); const empty = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-empty', display: { name: 'Empty', description: 'Removes all existing representations.' }, async apply(ref, params, plugin) { return {}; } }); const BuiltInPresetGroupName = 'Basic'; const polymerAndLigand = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-polymer-and-ligand', display: { name: 'Polymer & Ligand', group: BuiltInPresetGroupName, description: 'Shows polymers as Cartoon, ligands as Ball & Stick, carbohydrates as 3D-SNFG and water molecules semi-transparent.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { polymer: await presetStaticComponent(plugin, structureCell, 'polymer'), ligand: await presetStaticComponent(plugin, structureCell, 'ligand'), nonStandard: await presetStaticComponent(plugin, structureCell, 'non-standard'), branched: await presetStaticComponent(plugin, structureCell, 'branched', { label: 'Carbohydrate' }), water: await presetStaticComponent(plugin, structureCell, 'water'), ion: await presetStaticComponent(plugin, structureCell, 'ion'), lipid: await presetStaticComponent(plugin, structureCell, 'lipid'), coarse: await presetStaticComponent(plugin, structureCell, 'coarse') }; const structure = structureCell.obj.data; // TODO make configurable const waterType = (((_c = (_b = (_a = components.water) === null || _a === void 0 ? void 0 : _a.obj) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.elementCount) || 0) > 50000 ? 'line' : 'ball-and-stick'; const lipidType = (((_f = (_e = (_d = components.lipid) === null || _d === void 0 ? void 0 : _d.obj) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.elementCount) || 0) > 20000 ? 'line' : 'ball-and-stick'; const { update, builder, typeParams, color, symmetryColor, symmetryColorParams, globalColorParams, ballAndStickColor } = reprBuilder(plugin, params, structure); const representations = { polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'polymer' }), ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams, color, colorParams: ballAndStickColor }, { tag: 'ligand' }), nonStandard: builder.buildRepresentation(update, components.nonStandard, { type: 'ball-and-stick', typeParams, color, colorParams: ballAndStickColor }, { tag: 'non-standard' }), branchedBallAndStick: builder.buildRepresentation(update, components.branched, { type: 'ball-and-stick', typeParams: { ...typeParams, alpha: 0.3 }, color, colorParams: ballAndStickColor }, { tag: 'branched-ball-and-stick' }), branchedSnfg3d: builder.buildRepresentation(update, components.branched, { type: 'carbohydrate', typeParams, color, colorParams: globalColorParams }, { tag: 'branched-snfg-3d' }), water: builder.buildRepresentation(update, components.water, { type: waterType, typeParams: { ...typeParams, alpha: 0.6, visuals: waterType === 'line' ? ['intra-bond', 'element-point'] : undefined }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} }, ...globalColorParams } }, { tag: 'water' }), ion: builder.buildRepresentation(update, components.ion, { type: 'ball-and-stick', typeParams, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} }, ...globalColorParams } }, { tag: 'ion' }), lipid: builder.buildRepresentation(update, components.lipid, { type: lipidType, typeParams: { ...typeParams, alpha: 0.6, visuals: lipidType === 'line' ? ['intra-bond'] : undefined }, color, colorParams: { carbonColor: { name: 'element-symbol', params: {} }, ...globalColorParams } }, { tag: 'lipid' }), coarse: builder.buildRepresentation(update, components.coarse, { type: 'spacefill', typeParams, color: color || 'chain-id', colorParams: globalColorParams }, { tag: 'coarse' }) }; await update.commit({ revertOnError: false }); await updateFocusRepr(plugin, structure, (_h = (_g = params.theme) === null || _g === void 0 ? void 0 : _g.focus) === null || _h === void 0 ? void 0 : _h.name, (_k = (_j = params.theme) === null || _j === void 0 ? void 0 : _j.focus) === null || _k === void 0 ? void 0 : _k.params); return { components, representations }; } }); const proteinAndNucleic = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-protein-and-nucleic', display: { name: 'Protein & Nucleic', group: BuiltInPresetGroupName, description: 'Shows proteins as Cartoon and RNA/DNA as Gaussian Surface.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { protein: await presetSelectionComponent(plugin, structureCell, 'protein'), nucleic: await presetSelectionComponent(plugin, structureCell, 'nucleic'), }; const structure = structureCell.obj.data; const gaussianProps = { radiusOffset: structure.isCoarseGrained ? 2 : 0, smoothness: structure.isCoarseGrained ? 1.0 : 1.5, }; const { update, builder, typeParams, symmetryColor, symmetryColorParams } = reprBuilder(plugin, params, structure); const representations = { protein: builder.buildRepresentation(update, components.protein, { type: 'cartoon', typeParams, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'protein' }), nucleic: builder.buildRepresentation(update, components.nucleic, { type: 'gaussian-surface', typeParams: { ...typeParams, ...gaussianProps }, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'nucleic' }) }; await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name, (_d = (_c = params.theme) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.params); return { components, representations }; } }); const coarseSurface = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-coarse-surface', display: { name: 'Coarse Surface', group: BuiltInPresetGroupName, description: 'Shows polymers and lipids as coarse Gaussian Surface.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { polymer: await presetStaticComponent(plugin, structureCell, 'polymer'), lipid: await presetStaticComponent(plugin, structureCell, 'lipid'), }; const structure = structureCell.obj.data; const thresholds = plugin.config.get(config_1.PluginConfig.Structure.SizeThresholds) || structure_1.Structure.DefaultSizeThresholds; const size = structure_1.Structure.getSize(structure, thresholds); const gaussianProps = Object.create(null); if (size === structure_1.Structure.Size.Gigantic) { Object.assign(gaussianProps, { traceOnly: !structure.isCoarseGrained, radiusOffset: 2, smoothness: 1, visuals: ['structure-gaussian-surface-mesh'] }); } else if (size === structure_1.Structure.Size.Huge) { Object.assign(gaussianProps, { radiusOffset: structure.isCoarseGrained ? 2 : 0, smoothness: 1, }); } else if (structure.isCoarseGrained) { Object.assign(gaussianProps, { radiusOffset: 2, smoothness: 1, }); } const { update, builder, typeParams, symmetryColor, symmetryColorParams } = reprBuilder(plugin, params, structure); const representations = { polymer: builder.buildRepresentation(update, components.polymer, { type: 'gaussian-surface', typeParams: { ...typeParams, ...gaussianProps }, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'polymer' }), lipid: builder.buildRepresentation(update, components.lipid, { type: 'gaussian-surface', typeParams: { ...typeParams, ...gaussianProps }, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'lipid' }) }; await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name, (_d = (_c = params.theme) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.params); return { components, representations }; } }); const polymerCartoon = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-polymer-cartoon', display: { name: 'Polymer Cartoon', group: BuiltInPresetGroupName, description: 'Shows polymers as Cartoon.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { polymer: await presetStaticComponent(plugin, structureCell, 'polymer'), }; const structure = structureCell.obj.data; const { update, builder, typeParams, symmetryColor, symmetryColorParams } = reprBuilder(plugin, params, structure); const representations = { polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'polymer' }) }; await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name, (_d = (_c = params.theme) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.params); return { components, representations }; } }); const atomicDetail = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-atomic-detail', display: { name: 'Atomic Detail', group: BuiltInPresetGroupName, description: 'Shows everything in atomic detail.' }, params: () => ({ ...CommonParams, showCarbohydrateSymbol: param_definition_1.ParamDefinition.Boolean(false) }), async apply(ref, params, plugin) { var _a, _b, _c, _d, _e, _f; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { all: await presetStaticComponent(plugin, structureCell, 'all'), branched: undefined }; const structure = structureCell.obj.data; const highElementCount = structure.elementCount > 100000; // TODO make configurable const veryHighElementCount = structure.elementCount > 1000000; // TODO make configurable const highUnitCount = structure.units.length > 5000; // TODO make configurable const lowResidueElementRatio = structure.atomicResidueCount && structure.elementCount > 1000 && structure.atomicResidueCount / structure.elementCount < 3; const m = structure.models[0]; const bondsGiven = !!index_pair_1.IndexPairBonds.Provider.get(m) || struct_conn_1.StructConn.isExhaustive(m); let atomicType = 'ball-and-stick'; if (structure.isCoarseGrained || highUnitCount) { atomicType = veryHighElementCount ? 'point' : 'spacefill'; } else if (lowResidueElementRatio && !bondsGiven) { atomicType = 'spacefill'; } else if (highElementCount) { atomicType = 'line'; } const showCarbohydrateSymbol = params.showCarbohydrateSymbol && !highElementCount && !lowResidueElementRatio; if (showCarbohydrateSymbol) { Object.assign(components, { branched: await presetStaticComponent(plugin, structureCell, 'branched', { label: 'Carbohydrate' }), }); } const { update, builder, typeParams, color, ballAndStickColor, globalColorParams } = reprBuilder(plugin, params, structure); const colorParams = lowResidueElementRatio && !bondsGiven ? { carbonColor: { name: 'element-symbol', params: {} }, ...globalColorParams } : ballAndStickColor; const representations = { all: builder.buildRepresentation(update, components.all, { type: atomicType, typeParams, color, colorParams }, { tag: 'all' }), }; if (showCarbohydrateSymbol) { Object.assign(representations, { snfg3d: builder.buildRepresentation(update, components.branched, { type: 'carbohydrate', typeParams: { ...typeParams, alpha: 0.4, visuals: ['carbohydrate-symbol'] }, color, colorParams: globalColorParams }, { tag: 'snfg-3d' }), }); } await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_c = (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : color, (_f = (_e = (_d = params.theme) === null || _d === void 0 ? void 0 : _d.focus) === null || _e === void 0 ? void 0 : _e.params) !== null && _f !== void 0 ? _f : colorParams); return { components, representations }; } }); const illustrative = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-illustrative', display: { name: 'Illustrative', group: 'Miscellaneous', description: 'Show everything in spacefill representation with illustrative colors and ignore light.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d, _e; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { all: await presetStaticComponent(plugin, structureCell, 'all'), branched: undefined }; const structure = structureCell.obj.data; const { update, builder, typeParams, color } = reprBuilder(plugin, params, structure); const representations = { all: builder.buildRepresentation(update, components.all, { type: 'spacefill', typeParams: { ...typeParams, ignoreLight: true }, color: 'illustrative', colorParams: { style: { name: 'entity-id', params: { overrideWater: true } } }, }, { tag: 'all' }), }; await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_c = (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : color, (_e = (_d = params.theme) === null || _d === void 0 ? void 0 : _d.focus) === null || _e === void 0 ? void 0 : _e.params); return { components, representations }; } }); const molecularSurface = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-molecular-surface', display: { name: 'Molecular Surface', group: 'Miscellaneous', description: 'Show everything in molecular surface representation with illustrative colors.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d, _e; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { all: await presetStaticComponent(plugin, structureCell, 'all'), branched: undefined }; const structure = structureCell.obj.data; const { update, builder, typeParams, color } = reprBuilder(plugin, params, structure); const representations = { all: builder.buildRepresentation(update, components.all, { type: 'molecular-surface', typeParams, color: 'entity-id', colorParams: { overrideWater: true }, }, { tag: 'all' }), }; await update.commit({ revertOnError: true }); await updateFocusRepr(plugin, structure, (_c = (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : color, (_e = (_d = params.theme) === null || _d === void 0 ? void 0 : _d.focus) === null || _e === void 0 ? void 0 : _e.params); return { components, representations }; } }); const autoLod = StructureRepresentationPresetProvider({ id: 'preset-structure-representation-auto-lod', display: { name: 'Automatic Detail', group: 'Miscellaneous', description: 'Shows more (or less) detailed representations automatically based on camera distance.' }, params: () => CommonParams, async apply(ref, params, plugin) { var _a, _b, _c, _d; const structureCell = mol_state_1.StateObjectRef.resolveAndCheck(plugin.state.data, ref); if (!structureCell) return {}; const components = { all: await presetStaticComponent(plugin, structureCell, 'all'), }; const structure = structureCell.obj.data; const { update, builder, typeParams, color, symmetryColor, symmetryColorParams, ballAndStickColor } = reprBuilder(plugin, params, structure); const representations = { gaussianSurface: builder.buildRepresentation(update, components.all, { type: 'gaussian-surface', typeParams: { ...typeParams, lod: vec3_1.Vec3.create(30, 10000000, 100) }, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'gaussian-surface' }), cartoon: builder.buildRepresentation(update, components.all, { type: 'cartoon', typeParams: { ...typeParams, lod: vec3_1.Vec3.create(-20, 300, 100) }, color: symmetryColor, colorParams: symmetryColorParams }, { tag: 'cartoon' }), ballAndStick: builder.buildRepresentation(update, components.all, { type: 'ball-and-stick', typeParams: { ...typeParams, lod: vec3_1.Vec3.create(-20, 40, 20) }, color, colorParams: ballAndStickColor }, { tag: 'ball-and-stick' }), }; await update.commit({ revertOnError: false }); await updateFocusRepr(plugin, structure, (_b = (_a = params.theme) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.name, (_d = (_c = params.theme) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.params); return { components, representations }; } }); function presetStaticComponent(plugin, structure, type, params) { return plugin.builders.structure.tryCreateComponentStatic(structure, type, params); } function presetSelectionComponent(plugin, structure, query, params) { return plugin.builders.structure.tryCreateComponentFromSelection(structure, structure_selection_query_1.StructureSelectionQueries[query], `selection-${query}`, params); } exports.PresetStructureRepresentations = { empty, auto, 'atomic-detail': atomicDetail, 'polymer-cartoon': polymerCartoon, 'polymer-and-ligand': polymerAndLigand, 'protein-and-nucleic': proteinAndNucleic, 'coarse-surface': coarseSurface, illustrative, 'molecular-surface': molecularSurface, 'auto-lod': autoLod, };