UNPKG

@rcsb/rcsb-saguaro-3d

Version:
54 lines (53 loc) 2.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RcsbRepresentationPreset = void 0; const tslib_1 = require("tslib"); const representation_preset_1 = require("molstar/lib/mol-plugin-state/builder/structure/representation-preset"); const hierarchy_preset_1 = require("molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset"); exports.RcsbRepresentationPreset = (0, hierarchy_preset_1.TrajectoryHierarchyPresetProvider)({ id: "rcsb-saguaro-3d", display: { name: 'Feature View 3D' }, /*params(a: PluginStateObject.Molecule.Trajectory | undefined, plugin: PluginContext): ParamDefinition.For<{id:string, mapStructure: (key: string, structure: PluginStateObject.Molecule.Structure)=>void}> { return {id: undefined, mapStructure: undefined}; },*/ apply(trajectory, params, plugin) { return tslib_1.__awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d; const builder = plugin.builders.structure; const model = yield builder.createModel(trajectory, { modelIndex: 0 }); const modelProperties = yield builder.insertModelProperties(model); const structure = yield builder.createStructure(modelProperties); if ((_a = structure.cell) === null || _a === void 0 ? void 0 : _a.obj) params.mapStructure(params.id, (_b = structure.cell) === null || _b === void 0 ? void 0 : _b.obj); const structureProperties = yield builder.insertStructureProperties(structure); const unitcell = yield builder.tryCreateUnitcell(modelProperties, undefined, { isHidden: true }); const representation = yield plugin.builders.structure.representation.applyPreset(structureProperties, representation_preset_1.PresetStructureRepresentations.auto, {}); components: for (const c of plugin.managers.structure.hierarchy.currentComponentGroups) { for (const comp of c) { if (((_c = comp.cell.obj) === null || _c === void 0 ? void 0 : _c.label) === "Water") { plugin.managers.structure.component.toggleVisibility(c); break components; } } } components: for (const c of plugin.managers.structure.hierarchy.currentComponentGroups) { for (const comp of c) { if (((_d = comp.cell.obj) === null || _d === void 0 ? void 0 : _d.label) === "Polymer") { plugin.managers.structure.component.updateRepresentationsTheme([comp], { color: 'chain-id' }); break components; } } } return { model, modelProperties, unitcell, structure, structureProperties, representation }; }); } });