pdbe-molstar 3.6.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/build/pdbe-molstar-component.js +2 -2
  2. package/build/pdbe-molstar-light.css +2 -2
  3. package/build/pdbe-molstar-plugin.js +2 -2
  4. package/build/pdbe-molstar-plugin.js.LICENSE.txt +1 -1
  5. package/build/pdbe-molstar.css +2 -2
  6. package/lib/alphafold-transparency.js +7 -8
  7. package/lib/extensions/complexes/coloring.d.ts +15 -0
  8. package/lib/extensions/complexes/coloring.js +20 -9
  9. package/lib/extensions/complexes/index.d.ts +32 -17
  10. package/lib/extensions/complexes/index.js +24 -48
  11. package/lib/extensions/complexes/superpose-by-biggest-chain.d.ts +13 -15
  12. package/lib/extensions/complexes/superpose-by-biggest-chain.js +62 -56
  13. package/lib/extensions/complexes/superpose-by-sequence-alignment.d.ts +10 -0
  14. package/lib/extensions/complexes/superpose-by-sequence-alignment.js +181 -0
  15. package/lib/helpers.d.ts +11 -1
  16. package/lib/helpers.js +11 -5
  17. package/lib/plugin-custom-state.d.ts +0 -2
  18. package/lib/sequence-color/behavior.d.ts +5 -0
  19. package/lib/sequence-color/behavior.js +54 -0
  20. package/lib/sequence-color/color.d.ts +11 -0
  21. package/lib/sequence-color/color.js +58 -0
  22. package/lib/sequence-color/prop.d.ts +38 -0
  23. package/lib/sequence-color/prop.js +38 -0
  24. package/lib/styles/pdbe-molstar/_index.scss +39 -1
  25. package/lib/superposition.d.ts +2 -2
  26. package/lib/superposition.js +41 -60
  27. package/lib/ui/_layout.d.ts +15 -0
  28. package/lib/ui/_layout.js +162 -0
  29. package/lib/ui/alphafold-superposition.js +2 -2
  30. package/lib/ui/layout-no-controls-unless-expanded.d.ts +5 -0
  31. package/lib/ui/layout-no-controls-unless-expanded.js +34 -0
  32. package/lib/ui/pdbe-viewport-controls.d.ts +0 -1
  33. package/lib/ui/pdbe-viewport-controls.js +3 -19
  34. package/lib/ui/split-ui/components.d.ts +3 -0
  35. package/lib/ui/split-ui/components.js +3 -0
  36. package/lib/viewer.d.ts +1 -0
  37. package/lib/viewer.js +3 -3
  38. package/package.json +1 -1
  39. package/lib/superposition-sifts-mapping.d.ts +0 -22
  40. package/lib/superposition-sifts-mapping.js +0 -153
@@ -2,31 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PDBeViewportControls = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const common_1 = require("molstar/lib/mol-plugin-ui/controls/common");
5
6
  const viewport_1 = require("molstar/lib/mol-plugin-ui/viewport");
6
- const names_1 = require("molstar/lib/mol-util/color/names");
7
- const helpers_1 = require("../helpers");
8
7
  const plugin_custom_state_1 = require("../plugin-custom-state");
9
8
  class PDBeViewportControls extends viewport_1.ViewportControls {
10
- isBlack() {
11
- var _a;
12
- const bgColor = (_a = (0, plugin_custom_state_1.PluginCustomState)(this.plugin).initParams) === null || _a === void 0 ? void 0 : _a.bgColor;
13
- return bgColor !== undefined && (0, helpers_1.normalizeColor)(bgColor) === names_1.ColorNames.black;
14
- }
15
9
  render() {
16
10
  const initParams = (0, plugin_custom_state_1.PluginCustomState)(this.plugin).initParams;
17
11
  const showPDBeLink = (initParams === null || initParams === void 0 ? void 0 : initParams.moleculeId) && (initParams === null || initParams === void 0 ? void 0 : initParams.pdbeLink) && !(initParams === null || initParams === void 0 ? void 0 : initParams.superposition);
18
- const pdbeLinkColor = this.isBlack() ? '#fff' : '#555';
19
- const pdbeLink = {
20
- containerStyle: { position: 'absolute', right: '10px', top: '10px', padding: '6px', paddingRight: '3px', paddingLeft: '18px' },
21
- bgStyle: { position: 'absolute', height: '32px', width: '54px', marginLeft: '-33px' },
22
- style: { display: 'inline-block', fontSize: '14px', color: pdbeLinkColor, borderBottom: 'none', cursor: 'pointer', textDecoration: 'none', position: 'absolute', right: '5px' },
23
- pdbeImg: {
24
- src: 'https://www.ebi.ac.uk/pdbe/entry/static/images/logos/PDBe/logo_T_64.png',
25
- alt: 'PDBe logo',
26
- style: { height: '12px', width: '12px', border: 0, position: 'absolute', margin: '4px 0 0 -13px' },
27
- },
28
- };
29
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showPDBeLink && (0, jsx_runtime_1.jsxs)("div", { className: 'msp-viewport-controls-buttons', style: pdbeLink.containerStyle, children: [(0, jsx_runtime_1.jsx)("div", { className: 'msp-semi-transparent-background', style: pdbeLink.bgStyle }), (0, jsx_runtime_1.jsxs)("a", { className: 'msp-pdbe-link', style: pdbeLink.style, target: "_blank", href: `https://pdbe.org/${initParams.moleculeId}`, children: [(0, jsx_runtime_1.jsx)("img", { src: pdbeLink.pdbeImg.src, alt: pdbeLink.pdbeImg.alt, style: pdbeLink.pdbeImg.style }), initParams.moleculeId] })] }), (0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', top: showPDBeLink ? (32 + 4) : 0, right: 0 }, children: super.render() })] });
12
+ return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [showPDBeLink &&
13
+ (0, jsx_runtime_1.jsx)("div", { className: 'msp-viewport-controls', children: (0, jsx_runtime_1.jsx)("div", { className: 'msp-viewport-controls-buttons', children: (0, jsx_runtime_1.jsxs)("div", { className: 'pdbemolstar-pdbe-link-box', children: [(0, jsx_runtime_1.jsx)("div", { className: 'msp-semi-transparent-background' }), (0, jsx_runtime_1.jsx)("a", { target: '_blank', href: `https://pdbe.org/${initParams.moleculeId}`, style: { textDecoration: 'none', color: 'initial' }, children: (0, jsx_runtime_1.jsxs)(common_1.Button, { className: 'msp-btn-link-toggle-on pdbemolstar-pdbe-link', title: 'Go to PDBe Pages', children: [(0, jsx_runtime_1.jsx)("img", { className: 'pdbemolstar-pdbe-logo', alt: 'PDBe logo', src: 'https://www.ebi.ac.uk/pdbe/entry/static/images/logos/PDBe/logo_T_64.png' }), initParams.moleculeId] }) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: showPDBeLink ? 'pdbemolstar-viewport-controls-shifted' : 'pdbemolstar-viewport-controls-normal', children: super.render() })] });
30
14
  }
31
15
  }
32
16
  exports.PDBeViewportControls = PDBeViewportControls;
@@ -1,5 +1,6 @@
1
1
  import { ControlsWrapper, Log } from 'molstar/lib/mol-plugin-ui/plugin';
2
2
  import { SequenceView } from 'molstar/lib/mol-plugin-ui/sequence';
3
+ import { FullLayoutNoControlsUnlessExpanded } from '../layout-no-controls-unless-expanded';
3
4
  export declare const UIComponents: {
4
5
  /** Component containing 3D canvas, button in top left and top right corners, and tooltip box (center panel in default layout). Changes to fullscreen view by "Toggle Expanded Viewport" button, or "expanded" option. */
5
6
  readonly PDBeViewport: import("react").ComponentClass<{}, any>;
@@ -13,4 +14,6 @@ export declare const UIComponents: {
13
14
  readonly DefaultLeftPanelControls: import("react").ComponentClass<{}, any>;
14
15
  /** Component containing right panel controls (contents depend on PDBeMolstar init params (superposition/ligand/default view)) */
15
16
  readonly DefaultRightPanelControls: typeof ControlsWrapper;
17
+ /** Component containing only `PDBeViewport` when not in fullscreen view, but shows full UI layout when in fullscreen view. */
18
+ readonly FullLayoutNoControlsUnlessExpanded: typeof FullLayoutNoControlsUnlessExpanded;
16
19
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UIComponents = void 0;
4
4
  const plugin_1 = require("molstar/lib/mol-plugin-ui/plugin");
5
5
  const sequence_1 = require("molstar/lib/mol-plugin-ui/sequence");
6
+ const layout_no_controls_unless_expanded_1 = require("../layout-no-controls-unless-expanded");
6
7
  const pdbe_left_panel_1 = require("../left-panel/pdbe-left-panel");
7
8
  const pdbe_viewport_1 = require("../pdbe-viewport");
8
9
  exports.UIComponents = {
@@ -18,5 +19,7 @@ exports.UIComponents = {
18
19
  DefaultLeftPanelControls: pdbe_left_panel_1.DefaultLeftPanelControls,
19
20
  /** Component containing right panel controls (contents depend on PDBeMolstar init params (superposition/ligand/default view)) */
20
21
  DefaultRightPanelControls: plugin_1.ControlsWrapper,
22
+ /** Component containing only `PDBeViewport` when not in fullscreen view, but shows full UI layout when in fullscreen view. */
23
+ FullLayoutNoControlsUnlessExpanded: layout_no_controls_unless_expanded_1.FullLayoutNoControlsUnlessExpanded,
21
24
  // TODO add all meaningful components,
22
25
  };
package/lib/viewer.d.ts CHANGED
@@ -232,6 +232,7 @@ export declare class PDBeMolstarPlugin {
232
232
  readonly PDBeLeftPanelControls: import("react").ComponentClass<{}, any>;
233
233
  readonly DefaultLeftPanelControls: import("react").ComponentClass<{}, any>;
234
234
  readonly DefaultRightPanelControls: typeof import("molstar/lib/mol-plugin-ui/plugin").ControlsWrapper;
235
+ readonly FullLayoutNoControlsUnlessExpanded: typeof import("./ui/layout-no-controls-unless-expanded").FullLayoutNoControlsUnlessExpanded;
235
236
  };
236
237
  static MAIN_STRUCTURE_ID: string;
237
238
  }
package/lib/viewer.js CHANGED
@@ -431,8 +431,6 @@ class PDBeMolstarPlugin {
431
431
  if (this.initParams.customData && this.initParams.customData.url && !this.initParams.customData.format)
432
432
  return false;
433
433
  (0, plugin_custom_state_1.PluginCustomState)(this.plugin).initParams = this.initParams;
434
- // Update layout
435
- commands_1.PluginCommands.Layout.Update(this.plugin, { state: (0, helpers_1.pluginLayoutStateFromInitParams)(this.initParams) });
436
434
  // Show/hide buttons in the viewport control panel
437
435
  this.plugin.config.set(config_1.PluginConfig.Viewport.ShowScreenshotControls, !this.initParams.hideCanvasControls.includes('screenshot'));
438
436
  this.plugin.config.set(config_1.PluginConfig.Viewport.ShowExpand, !this.initParams.hideCanvasControls.includes('expand'));
@@ -441,6 +439,8 @@ class PDBeMolstarPlugin {
441
439
  this.plugin.config.set(config_1.PluginConfig.Viewport.ShowSelectionMode, !this.initParams.hideCanvasControls.includes('selection'));
442
440
  this.plugin.config.set(config_1.PluginConfig.Viewport.ShowAnimation, !this.initParams.hideCanvasControls.includes('animation'));
443
441
  this.plugin.config.set(config_1.PluginConfig.Viewport.ShowTrajectoryControls, !this.initParams.hideCanvasControls.includes('trajectory'));
442
+ // Update layout
443
+ commands_1.PluginCommands.Layout.Update(this.plugin, { state: (0, helpers_1.pluginLayoutStateFromInitParams)(this.initParams) });
444
444
  // Set background colour
445
445
  if (this.initParams.bgColor || this.initParams.lighting) {
446
446
  yield this.canvas.applySettings({ color: this.initParams.bgColor, lighting: this.initParams.lighting });
@@ -776,7 +776,7 @@ class PDBeMolstarPlugin {
776
776
  return;
777
777
  const asm = this.state.select(this.assemblyRef)[0].obj;
778
778
  const defaultMapParams = transformers_1.InitVolumeStreaming.createDefaultParams(asm, this.plugin);
779
- const pdbeMapParams = helpers_1.PDBeVolumes.mapParams(defaultMapParams, this.initParams.mapSettings, '');
779
+ const pdbeMapParams = helpers_1.PDBeVolumes.mapParams(defaultMapParams, this.initParams.mapSettings);
780
780
  if (pdbeMapParams) {
781
781
  yield this.plugin.runTask(this.state.applyAction(transformers_1.InitVolumeStreaming, pdbeMapParams, this.assemblyRef));
782
782
  if (pdbeMapParams.method !== 'em' && !this.initParams.ligandView)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdbe-molstar",
3
- "version": "3.6.0",
3
+ "version": "3.7.1",
4
4
  "description": "Molstar implementation for PDBe",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,22 +0,0 @@
1
- import { MinimizeRmsd } from 'molstar/lib/mol-math/linear-algebra/3d/minimize-rmsd';
2
- import { Structure } from 'molstar/lib/mol-model/structure';
3
- import { ElementIndex, ResidueIndex } from 'molstar/lib/mol-model/structure/model/indexing';
4
- import { StructureElement } from 'molstar/lib/mol-model/structure/structure/element';
5
- import { Unit } from 'molstar/lib/mol-model/structure/structure/unit';
6
- export interface AlignmentResultEntry {
7
- transform: MinimizeRmsd.Result;
8
- pivot: number;
9
- other: number;
10
- }
11
- export interface AlignmentResult {
12
- entries: AlignmentResultEntry[];
13
- zeroOverlapPairs: [number, number][];
14
- failedPairs: [number, number][];
15
- }
16
- type IncludeResidueTest = (traceElementOrFirstAtom: StructureElement.Location<Unit.Atomic>, residueIndex: ResidueIndex, startIndex: ElementIndex, endIndex: ElementIndex) => boolean;
17
- export declare function alignAndSuperposeWithSIFTSMapping(structures: Structure[], options?: {
18
- traceOnly?: boolean;
19
- includeResidueTest?: IncludeResidueTest;
20
- applyTestIndex?: number[];
21
- }): AlignmentResult;
22
- export {};
@@ -1,153 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.alignAndSuperposeWithSIFTSMapping = alignAndSuperposeWithSIFTSMapping;
4
- const int_1 = require("molstar/lib/mol-data/int");
5
- const minimize_rmsd_1 = require("molstar/lib/mol-math/linear-algebra/3d/minimize-rmsd");
6
- const element_1 = require("molstar/lib/mol-model/structure/structure/element");
7
- const sifts_mapping_1 = require("./sifts-mapping");
8
- function alignAndSuperposeWithSIFTSMapping(structures, options) {
9
- var _a, _b;
10
- const indexMap = new Map();
11
- for (let i = 0; i < structures.length; i++) {
12
- let includeResidueTest = (_a = options === null || options === void 0 ? void 0 : options.includeResidueTest) !== null && _a !== void 0 ? _a : _includeAllResidues;
13
- if ((options === null || options === void 0 ? void 0 : options.applyTestIndex) && !options.applyTestIndex.includes(i))
14
- includeResidueTest = _includeAllResidues;
15
- buildIndex(structures[i], indexMap, i, (_b = options === null || options === void 0 ? void 0 : options.traceOnly) !== null && _b !== void 0 ? _b : true, includeResidueTest);
16
- }
17
- const index = Array.from(indexMap.values());
18
- // TODO: support non-first structure pivots
19
- const pairs = findPairs(structures.length, index);
20
- const zeroOverlapPairs = [];
21
- const failedPairs = [];
22
- const entries = [];
23
- for (const p of pairs) {
24
- if (p.count === 0) {
25
- zeroOverlapPairs.push([p.i, p.j]);
26
- }
27
- else {
28
- const [a, b] = getPositionTables(index, p.i, p.j, p.count);
29
- const transform = minimize_rmsd_1.MinimizeRmsd.compute({ a, b });
30
- if (Number.isNaN(transform.rmsd)) {
31
- failedPairs.push([p.i, p.j]);
32
- }
33
- else {
34
- entries.push({ transform, pivot: p.i, other: p.j });
35
- }
36
- }
37
- }
38
- return { entries, zeroOverlapPairs, failedPairs };
39
- }
40
- function getPositionTables(index, pivot, other, N) {
41
- const xs = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
42
- const ys = minimize_rmsd_1.MinimizeRmsd.Positions.empty(N);
43
- let o = 0;
44
- for (const { pivots } of index) {
45
- const a = pivots[pivot];
46
- const b = pivots[other];
47
- if (!a || !b)
48
- continue;
49
- const l = Math.min(a[2] - a[1], b[2] - b[1]);
50
- // TODO: check if residue types match?
51
- for (let i = 0; i < l; i++) {
52
- let eI = (a[1] + i);
53
- xs.x[o] = a[0].conformation.x(eI);
54
- xs.y[o] = a[0].conformation.y(eI);
55
- xs.z[o] = a[0].conformation.z(eI);
56
- eI = (b[1] + i);
57
- ys.x[o] = b[0].conformation.x(eI);
58
- ys.y[o] = b[0].conformation.y(eI);
59
- ys.z[o] = b[0].conformation.z(eI);
60
- o++;
61
- }
62
- }
63
- return [xs, ys];
64
- }
65
- function findPairs(N, index) {
66
- const pairwiseCounts = [];
67
- for (let i = 0; i < N; i++) {
68
- pairwiseCounts[i] = [];
69
- for (let j = 0; j < N; j++)
70
- pairwiseCounts[i][j] = 0;
71
- }
72
- for (const { pivots } of index) {
73
- for (let i = 0; i < N; i++) {
74
- if (!pivots[i])
75
- continue;
76
- const lI = pivots[i][2] - pivots[i][1];
77
- for (let j = i + 1; j < N; j++) {
78
- if (!pivots[j])
79
- continue;
80
- const lJ = pivots[j][2] - pivots[j][1];
81
- pairwiseCounts[i][j] = pairwiseCounts[i][j] + Math.min(lI, lJ);
82
- }
83
- }
84
- }
85
- const ret = [];
86
- for (let j = 1; j < N; j++) {
87
- ret[j - 1] = { i: 0, j, count: pairwiseCounts[0][j] };
88
- }
89
- // TODO: support non-first structure pivots
90
- // for (let i = 0; i < N - 1; i++) {
91
- // let max = 0, maxJ = i;
92
- // for (let j = i + 1; j < N; j++) {
93
- // if (pairwiseCounts[i][j] > max) {
94
- // maxJ = j;
95
- // max = pairwiseCounts[i][j];
96
- // }
97
- // }
98
- // ret[i] = { i, j: maxJ, count: max };
99
- // }
100
- return ret;
101
- }
102
- function _includeAllResidues() { return true; }
103
- function buildIndex(structure, index, sI, traceOnly, includeTest) {
104
- const loc = element_1.StructureElement.Location.create(structure);
105
- for (const unit of structure.units) {
106
- if (unit.kind !== 0 /* Unit.Kind.Atomic */)
107
- continue;
108
- const { elements, model } = unit;
109
- loc.unit = unit;
110
- const map = sifts_mapping_1.SIFTSMapping.Provider.get(model).value;
111
- if (!map)
112
- return;
113
- const { dbName, accession, num } = map;
114
- const chainsIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.chainAtomSegments, elements);
115
- const residuesIt = int_1.Segmentation.transientSegments(unit.model.atomicHierarchy.residueAtomSegments, elements);
116
- const traceElementIndex = unit.model.atomicHierarchy.derived.residue.traceElementIndex;
117
- while (chainsIt.hasNext) {
118
- const chainSegment = chainsIt.move();
119
- residuesIt.setSegment(chainSegment);
120
- while (residuesIt.hasNext) {
121
- const residueSegment = residuesIt.move();
122
- const rI = residueSegment.index;
123
- if (!dbName[rI])
124
- continue;
125
- const traceElement = traceElementIndex[rI];
126
- let start, end;
127
- if (traceOnly) {
128
- start = traceElement;
129
- if (start === -1)
130
- continue;
131
- end = start + 1;
132
- }
133
- else {
134
- start = elements[residueSegment.start];
135
- end = elements[residueSegment.end - 1] + 1;
136
- }
137
- loc.element = (traceElement >= 0 ? traceElement : start);
138
- if (!includeTest(loc, rI, start, end))
139
- continue;
140
- const key = `${dbName[rI]}-${accession[rI].split('-')[0]}-${num[rI]}`;
141
- if (!index.has(key)) {
142
- index.set(key, { key, pivots: { [sI]: [unit, start, end] } });
143
- }
144
- else {
145
- const entry = index.get(key);
146
- if (!entry.pivots[sI]) {
147
- entry.pivots[sI] = [unit, start, end];
148
- }
149
- }
150
- }
151
- }
152
- }
153
- }