UNPKG

molstar

Version:

A comprehensive macromolecular library.

121 lines (120 loc) 7.21 kB
"use strict"; /** * Copyright (c) 2023-2024 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CartoonColorThemeProvider = exports.CartoonColorThemeParams = void 0; exports.getCartoonColorThemeParams = getCartoonColorThemeParams; exports.CartoonColorTheme = CartoonColorTheme; const param_definition_1 = require("../../mol-util/param-definition"); const chain_id_1 = require("./chain-id"); const uniform_1 = require("./uniform"); const type_helpers_1 = require("../../mol-util/type-helpers"); const entity_id_1 = require("./entity-id"); const molecule_type_1 = require("./molecule-type"); const entity_source_1 = require("./entity-source"); const model_index_1 = require("./model-index"); const structure_index_1 = require("./structure-index"); const categories_1 = require("./categories"); const residue_name_1 = require("./residue-name"); const secondary_structure_1 = require("./secondary-structure"); const element_symbol_1 = require("./element-symbol"); const trajectory_index_1 = require("./trajectory-index"); const util_1 = require("../../mol-data/util"); const hydrophobicity_1 = require("./hydrophobicity"); const uncertainty_1 = require("./uncertainty"); const occupancy_1 = require("./occupancy"); const sequence_id_1 = require("./sequence-id"); const partial_charge_1 = require("./partial-charge"); const Description = 'Uses separate themes for coloring mainchain and sidechain visuals.'; exports.CartoonColorThemeParams = { mainchain: param_definition_1.ParamDefinition.MappedStatic('molecule-type', { 'uniform': param_definition_1.ParamDefinition.Group(uniform_1.UniformColorThemeParams), 'chain-id': param_definition_1.ParamDefinition.Group(chain_id_1.ChainIdColorThemeParams), 'entity-id': param_definition_1.ParamDefinition.Group(entity_id_1.EntityIdColorThemeParams), 'entity-source': param_definition_1.ParamDefinition.Group(entity_source_1.EntitySourceColorThemeParams), 'molecule-type': param_definition_1.ParamDefinition.Group(molecule_type_1.MoleculeTypeColorThemeParams), 'model-index': param_definition_1.ParamDefinition.Group(model_index_1.ModelIndexColorThemeParams), 'structure-index': param_definition_1.ParamDefinition.Group(structure_index_1.StructureIndexColorThemeParams), 'secondary-structure': param_definition_1.ParamDefinition.Group(secondary_structure_1.SecondaryStructureColorThemeParams), 'trajectory-index': param_definition_1.ParamDefinition.Group(trajectory_index_1.TrajectoryIndexColorThemeParams), }), sidechain: param_definition_1.ParamDefinition.MappedStatic('residue-name', { 'uniform': param_definition_1.ParamDefinition.Group(uniform_1.UniformColorThemeParams), 'residue-name': param_definition_1.ParamDefinition.Group(residue_name_1.ResidueNameColorThemeParams), 'element-symbol': param_definition_1.ParamDefinition.Group(element_symbol_1.ElementSymbolColorThemeParams), 'hydrophobicity': param_definition_1.ParamDefinition.Group(hydrophobicity_1.HydrophobicityColorThemeParams), 'uncertainty': param_definition_1.ParamDefinition.Group(uncertainty_1.UncertaintyColorThemeParams), 'occupancy': param_definition_1.ParamDefinition.Group(occupancy_1.OccupancyColorThemeParams), 'sequence-id': param_definition_1.ParamDefinition.Group(sequence_id_1.SequenceIdColorThemeParams), 'partial-charge': param_definition_1.ParamDefinition.Group(partial_charge_1.PartialChargeColorThemeParams), }), }; function getCartoonColorThemeParams(ctx) { const params = param_definition_1.ParamDefinition.clone(exports.CartoonColorThemeParams); return params; } function getMainchainTheme(ctx, props) { switch (props.name) { case 'uniform': return (0, uniform_1.UniformColorTheme)(ctx, props.params); case 'chain-id': return (0, chain_id_1.ChainIdColorTheme)(ctx, props.params); case 'entity-id': return (0, entity_id_1.EntityIdColorTheme)(ctx, props.params); case 'entity-source': return (0, entity_source_1.EntitySourceColorTheme)(ctx, props.params); case 'molecule-type': return (0, molecule_type_1.MoleculeTypeColorTheme)(ctx, props.params); case 'model-index': return (0, model_index_1.ModelIndexColorTheme)(ctx, props.params); case 'structure-index': return (0, structure_index_1.StructureIndexColorTheme)(ctx, props.params); case 'secondary-structure': return (0, secondary_structure_1.SecondaryStructureColorTheme)(ctx, props.params); case 'trajectory-index': return (0, trajectory_index_1.TrajectoryIndexColorTheme)(ctx, props.params); default: (0, type_helpers_1.assertUnreachable)(props); } } function getSidechainTheme(ctx, props) { switch (props.name) { case 'uniform': return (0, uniform_1.UniformColorTheme)(ctx, props.params); case 'residue-name': return (0, residue_name_1.ResidueNameColorTheme)(ctx, props.params); case 'element-symbol': return (0, element_symbol_1.ElementSymbolColorTheme)(ctx, props.params); case 'hydrophobicity': return (0, hydrophobicity_1.HydrophobicityColorTheme)(ctx, props.params); case 'uncertainty': return (0, uncertainty_1.UncertaintyColorTheme)(ctx, props.params); case 'occupancy': return (0, occupancy_1.OccupancyColorTheme)(ctx, props.params); case 'sequence-id': return (0, sequence_id_1.SequenceIdColorTheme)(ctx, props.params); case 'partial-charge': return (0, partial_charge_1.PartialChargeColorTheme)(ctx, props.params); default: (0, type_helpers_1.assertUnreachable)(props); } } function CartoonColorTheme(ctx, props) { var _a, _b, _c, _d; const mainchain = getMainchainTheme(ctx, props.mainchain); const sidechain = getSidechainTheme(ctx, props.sidechain); const contextHash = (0, util_1.hash2)((_a = mainchain.contextHash) !== null && _a !== void 0 ? _a : 0, (_b = sidechain.contextHash) !== null && _b !== void 0 ? _b : 0); function color(location, isSecondary) { return isSecondary ? mainchain.color(location, false) : sidechain.color(location, false); } let legend = mainchain.legend; if (((_c = mainchain.legend) === null || _c === void 0 ? void 0 : _c.kind) === 'table-legend' && ((_d = sidechain.legend) === null || _d === void 0 ? void 0 : _d.kind) === 'table-legend') { legend = { kind: 'table-legend', table: [...mainchain.legend.table, ...sidechain.legend.table] }; } return { factory: CartoonColorTheme, granularity: 'group', preferSmoothing: false, color, props, contextHash, description: Description, legend, }; } exports.CartoonColorThemeProvider = { name: 'cartoon', label: 'Cartoon', category: categories_1.ColorThemeCategory.Misc, factory: CartoonColorTheme, getParams: getCartoonColorThemeParams, defaultValues: param_definition_1.ParamDefinition.getDefaultValues(exports.CartoonColorThemeParams), isApplicable: (ctx) => !!ctx.structure };