UNPKG

@rcsb/rcsb-saguaro-3d

Version:
51 lines 2.87 kB
import { __awaiter } from "tslib"; import { PresetStructureRepresentations } from "molstar/lib/mol-plugin-state/builder/structure/representation-preset"; import { TrajectoryHierarchyPresetProvider } from "molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset"; export const RcsbRepresentationPreset = 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 __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, 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 }; }); } }); //# sourceMappingURL=TrajectoryPreset.js.map