pdbe-molstar 3.3.0 → 3.3.2
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.
- package/README.md +2 -0
- package/build/pdbe-molstar-component.js +2 -2
- package/build/pdbe-molstar-light.css +2 -2
- package/build/pdbe-molstar-plugin.js +2 -2
- package/build/pdbe-molstar-plugin.js.LICENSE.txt +1 -1
- package/build/pdbe-molstar.css +2 -2
- package/lib/domain-annotations/prop.d.ts +1 -8
- package/lib/domain-annotations/prop.js +7 -1
- package/lib/extensions/state-gallery/behavior.d.ts +5 -2
- package/lib/extensions/state-gallery/behavior.js +4 -3
- package/lib/extensions/state-gallery/config.d.ts +4 -0
- package/lib/extensions/state-gallery/config.js +3 -0
- package/lib/extensions/state-gallery/manager.d.ts +34 -5
- package/lib/extensions/state-gallery/manager.js +54 -37
- package/lib/extensions/state-gallery/titles.d.ts +26 -0
- package/lib/extensions/state-gallery/titles.js +68 -0
- package/lib/extensions/state-gallery/ui.d.ts +11 -3
- package/lib/extensions/state-gallery/ui.js +31 -23
- package/lib/helpers.d.ts +5 -4
- package/lib/helpers.js +2 -0
- package/lib/plugin-custom-state.d.ts +11 -3
- package/lib/plugin-custom-state.js +23 -20
- package/lib/spec.d.ts +3 -1
- package/lib/styles/pdbe-molstar/_index.scss +9 -2
- package/lib/viewer.d.ts +6 -8
- package/lib/viewer.js +39 -14
- package/package.json +7 -7
|
@@ -119,9 +119,14 @@
|
|
|
119
119
|
.pdbemolstar-state-gallery-state-button {
|
|
120
120
|
height: 24px;
|
|
121
121
|
line-height: 24px;
|
|
122
|
+
padding-inline: 5px;
|
|
122
123
|
text-align: left;
|
|
123
124
|
overflow: hidden;
|
|
124
|
-
text-overflow: ellipsis
|
|
125
|
+
text-overflow: ellipsis;
|
|
126
|
+
|
|
127
|
+
.msp-icon {
|
|
128
|
+
margin-right: 3px;
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
.pdbemolstar-state-gallery-legend {
|
|
@@ -152,9 +157,11 @@
|
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
.pdbemolstar-state-gallery-title {
|
|
155
|
-
|
|
160
|
+
margin: 5px;
|
|
161
|
+
min-height: 2.9em; // Enough for one normal line + one <small> line
|
|
156
162
|
display: flex;
|
|
157
163
|
flex-direction: row;
|
|
164
|
+
align-items: center;
|
|
158
165
|
text-align: center;
|
|
159
166
|
font-weight: bold;
|
|
160
167
|
|
package/lib/viewer.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { StructureRef } from 'molstar/lib/mol-plugin-state/manager/structure/hie
|
|
|
6
6
|
import { PluginContext } from 'molstar/lib/mol-plugin/context';
|
|
7
7
|
import { Color } from 'molstar/lib/mol-util/color/color';
|
|
8
8
|
import * as Foldseek from './extensions/foldseek';
|
|
9
|
+
import { StateGalleryManager } from './extensions/state-gallery/manager';
|
|
9
10
|
import { StateGalleryControls } from './extensions/state-gallery/ui';
|
|
10
11
|
import { LoadParams, QueryParam } from './helpers';
|
|
11
12
|
import { AnyColor, InitParams } from './spec';
|
|
@@ -73,11 +74,7 @@ export declare class PDBeMolstarPlugin {
|
|
|
73
74
|
/** Helper methods related to canvas and layout */
|
|
74
75
|
canvas: {
|
|
75
76
|
/** Set canvas background color. */
|
|
76
|
-
setBgColor: (color?:
|
|
77
|
-
r: number;
|
|
78
|
-
g: number;
|
|
79
|
-
b: number;
|
|
80
|
-
}) => Promise<void>;
|
|
77
|
+
setBgColor: (color?: AnyColor) => Promise<void>;
|
|
81
78
|
/** Set controls panel visibility. Without `isVisible` parameter, toggle controls panel visibility. */
|
|
82
79
|
toggleControls: (isVisible?: boolean) => void;
|
|
83
80
|
/** Set full-screen mode on or off. Without `isExpanded` parameter, toggle full-screen mode. */
|
|
@@ -136,7 +133,8 @@ export declare class PDBeMolstarPlugin {
|
|
|
136
133
|
keepRepresentations?: boolean;
|
|
137
134
|
}) => Promise<void>;
|
|
138
135
|
/** Remove any coloring and extra representations previously added by the `select` method.
|
|
139
|
-
*
|
|
136
|
+
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure;
|
|
137
|
+
* if not provided, will apply to all loaded structures.
|
|
140
138
|
* If `keepColors`, current residue coloring is preserved. If `keepRepresentations`, current added representations are preserved. */
|
|
141
139
|
clearSelection: (structureNumberOrId?: number | string, options?: {
|
|
142
140
|
keepColors?: boolean;
|
|
@@ -152,7 +150,7 @@ export declare class PDBeMolstarPlugin {
|
|
|
152
150
|
structureNumber?: number;
|
|
153
151
|
}) => Promise<void>;
|
|
154
152
|
/** Remove any custom tooltips added by the `tooltips` method. */
|
|
155
|
-
clearTooltips: (structureNumberOrId?: number) => Promise<void>;
|
|
153
|
+
clearTooltips: (structureNumberOrId?: number | string) => Promise<void>;
|
|
156
154
|
/** Set highlight and/or selection color.
|
|
157
155
|
* Highlight color is used when the user hovers over a part of the structure or when applying the `highlight` method.
|
|
158
156
|
* Selection color is used when creating selections with Selection Mode (the mouse cursor icon) and is not related to the color used by the `select` method. */
|
|
@@ -181,7 +179,7 @@ export declare class PDBeMolstarPlugin {
|
|
|
181
179
|
static extensions: {
|
|
182
180
|
Foldseek: typeof Foldseek;
|
|
183
181
|
StateGallery: {
|
|
184
|
-
StateGalleryManager: typeof
|
|
182
|
+
StateGalleryManager: typeof StateGalleryManager;
|
|
185
183
|
StateGalleryCustomState: (plugin: PluginContext) => Partial<import("./extensions/state-gallery/behavior").StateGalleryCustomState>;
|
|
186
184
|
UI: {
|
|
187
185
|
StateGalleryControls: typeof StateGalleryControls;
|
package/lib/viewer.js
CHANGED
|
@@ -43,6 +43,7 @@ const custom_events_1 = require("./custom-events");
|
|
|
43
43
|
const behavior_4 = require("./domain-annotations/behavior");
|
|
44
44
|
const Foldseek = tslib_1.__importStar(require("./extensions/foldseek"));
|
|
45
45
|
const behavior_5 = require("./extensions/state-gallery/behavior");
|
|
46
|
+
const manager_1 = require("./extensions/state-gallery/manager");
|
|
46
47
|
const ui_1 = require("./extensions/state-gallery/ui");
|
|
47
48
|
const helpers_1 = require("./helpers");
|
|
48
49
|
const plugin_custom_state_1 = require("./plugin-custom-state");
|
|
@@ -75,7 +76,7 @@ class PDBeMolstarPlugin {
|
|
|
75
76
|
this.canvas = {
|
|
76
77
|
/** Set canvas background color. */
|
|
77
78
|
setBgColor: (color) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
if (
|
|
79
|
+
if (color === undefined || color === null)
|
|
79
80
|
return;
|
|
80
81
|
yield this.canvas.applySettings({ color });
|
|
81
82
|
}),
|
|
@@ -265,7 +266,8 @@ class PDBeMolstarPlugin {
|
|
|
265
266
|
}
|
|
266
267
|
}),
|
|
267
268
|
/** Remove any coloring and extra representations previously added by the `select` method.
|
|
268
|
-
*
|
|
269
|
+
* `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure;
|
|
270
|
+
* if not provided, will apply to all loaded structures.
|
|
269
271
|
* If `keepColors`, current residue coloring is preserved. If `keepRepresentations`, current added representations are preserved. */
|
|
270
272
|
clearSelection: (structureNumberOrId, options) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
271
273
|
// Structure list to apply to
|
|
@@ -520,7 +522,7 @@ class PDBeMolstarPlugin {
|
|
|
520
522
|
pdbePluginSpec.behaviors.push(spec_1.PluginSpec.Behavior(camera_1.FocusLoci, { bindings: this.initParams.focusBindings }));
|
|
521
523
|
}
|
|
522
524
|
// Create/ Initialise Plugin
|
|
523
|
-
const onBeforeUIRender = (plugin) => {
|
|
525
|
+
const onBeforeUIRender = (plugin) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
524
526
|
// This needs to run after the plugin is created but before the UI is rendered
|
|
525
527
|
(0, plugin_custom_state_1.PluginCustomState)(plugin).initParams = Object.assign({}, this.initParams);
|
|
526
528
|
(0, plugin_custom_state_1.PluginCustomState)(plugin).events = {
|
|
@@ -528,7 +530,15 @@ class PDBeMolstarPlugin {
|
|
|
528
530
|
superpositionInit: this._ev(),
|
|
529
531
|
isBusy: this._ev(),
|
|
530
532
|
};
|
|
531
|
-
|
|
533
|
+
if (this.initParams.galleryView && this.initParams.moleculeId) {
|
|
534
|
+
try {
|
|
535
|
+
yield manager_1.StateGalleryManager.create(plugin, this.initParams.moleculeId); // sets extension custom state
|
|
536
|
+
}
|
|
537
|
+
catch (err) {
|
|
538
|
+
console.error(`Failed to initialize StateGalleryManager for entry ${this.initParams.moleculeId}.\n${err}`);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
});
|
|
532
542
|
if (Array.isArray(target)) {
|
|
533
543
|
this.targetElement = (0, split_ui_1.resolveHTMLElement)(target[0].target);
|
|
534
544
|
this.plugin = yield (0, split_ui_1.createPluginSplitUI)({
|
|
@@ -569,6 +579,9 @@ class PDBeMolstarPlugin {
|
|
|
569
579
|
// Initialise superposition
|
|
570
580
|
(0, superposition_1.initSuperposition)(this.plugin, this.events.loadComplete);
|
|
571
581
|
}
|
|
582
|
+
else if (this.initParams.galleryView) {
|
|
583
|
+
// Do nothing, StateGalleryManager initialized in onBeforeUIRender
|
|
584
|
+
}
|
|
572
585
|
else {
|
|
573
586
|
// Load Molecule CIF or coordQuery and Parse
|
|
574
587
|
const dataSource = this.getMoleculeSrcUrl();
|
|
@@ -714,10 +727,9 @@ class PDBeMolstarPlugin {
|
|
|
714
727
|
representationPreset: 'auto',
|
|
715
728
|
});
|
|
716
729
|
structRef = this.plugin.state.data.selectQ(q => q.byRef(data.ref).subtree().ofType(objects_1.PluginStateObject.Molecule.Structure))[0].transform.ref;
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
730
|
+
yield this.deleteStructureComponents(structRef, this.initParams.hideStructure);
|
|
731
|
+
yield this.applyVisualStyles(structRef, this.initParams.visualStyle);
|
|
732
|
+
yield commands_1.PluginCommands.Camera.Reset(this.plugin, { durationMs: fullLoad ? 0 : undefined });
|
|
721
733
|
}
|
|
722
734
|
else {
|
|
723
735
|
const model = yield this.plugin.builders.structure.createModel(trajectory);
|
|
@@ -786,12 +798,14 @@ class PDBeMolstarPlugin {
|
|
|
786
798
|
* E.g. `styles={polymer:'putty',nonStandard:'ball-and-stick'}` - apply only putty to polymer, only ball-and-stick to non-standard residues, leave other components untouched.
|
|
787
799
|
* E.g. `styles='ball-and-stick'` - apply only ball-and-stick to all components. */
|
|
788
800
|
applyVisualStyles(structureRef, styles) {
|
|
789
|
-
var _a, _b
|
|
801
|
+
var _a, _b;
|
|
790
802
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
791
803
|
if (styles === undefined)
|
|
792
804
|
return;
|
|
793
805
|
const components = this.plugin.state.data.selectQ(q => q.byRef(structureRef).subtree().withTransformer(model_1.StructureComponent));
|
|
794
806
|
const compStyles = (0, spec_2.resolveVisualStyleSpec)(styles);
|
|
807
|
+
const addedReprs = [];
|
|
808
|
+
const update = this.plugin.build();
|
|
795
809
|
for (const comp of components) {
|
|
796
810
|
const compType = (0, helpers_1.getComponentTypeFromTags)((_a = comp.obj) === null || _a === void 0 ? void 0 : _a.tags);
|
|
797
811
|
if (compType === undefined)
|
|
@@ -799,16 +813,23 @@ class PDBeMolstarPlugin {
|
|
|
799
813
|
const compStyle = compStyles[compType];
|
|
800
814
|
if (compStyle === undefined)
|
|
801
815
|
continue;
|
|
802
|
-
const update = this.plugin.build();
|
|
803
816
|
const existingReprs = this.plugin.state.data.selectQ(q => q.byValue(comp).subtree().withTransformer(representation_1.StructureRepresentation3D));
|
|
804
817
|
for (const repr of existingReprs) {
|
|
805
818
|
update.delete(repr);
|
|
806
819
|
}
|
|
807
820
|
const newReprProps = (0, structure_representation_params_1.createStructureRepresentationParams)(this.plugin, (_b = comp.obj) === null || _b === void 0 ? void 0 : _b.data, Object.assign({ color: this.defaultColorTheme() }, compStyle));
|
|
808
|
-
const newRepr =
|
|
809
|
-
|
|
810
|
-
|
|
821
|
+
const newRepr = update.to(comp).apply(representation_1.StructureRepresentation3D, newReprProps).selector;
|
|
822
|
+
addedReprs.push({ style: compStyle, repr: newRepr });
|
|
823
|
+
}
|
|
824
|
+
yield update.commit();
|
|
825
|
+
// Sometimes Molstar applies different repr type than requested (especially for water), we must remove such unwanted reprs:
|
|
826
|
+
const rubbishReprs = addedReprs.filter(r => { var _a, _b; return ((_b = (_a = r.repr.cell) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.values.type.name) !== r.style.type; });
|
|
827
|
+
if (rubbishReprs.length > 0) {
|
|
828
|
+
const update = this.plugin.build();
|
|
829
|
+
for (const r of rubbishReprs) {
|
|
830
|
+
update.delete(r.repr);
|
|
811
831
|
}
|
|
832
|
+
yield update.commit();
|
|
812
833
|
}
|
|
813
834
|
});
|
|
814
835
|
}
|
|
@@ -819,6 +840,8 @@ class PDBeMolstarPlugin {
|
|
|
819
840
|
deleteStructureComponents(structureRef, deleteComponents) {
|
|
820
841
|
var _a, _b;
|
|
821
842
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
843
|
+
if (deleteComponents.length === 0)
|
|
844
|
+
return;
|
|
822
845
|
const comps = this.plugin.state.data.selectQ(q => q.byRef(structureRef).subtree().withTransformer(model_1.StructureComponent));
|
|
823
846
|
const deleteTags = deleteComponents.flatMap(comp => { var _a; return (_a = helpers_1.StructureComponentTags[comp]) !== null && _a !== void 0 ? _a : []; });
|
|
824
847
|
const update = this.plugin.build();
|
|
@@ -829,7 +852,9 @@ class PDBeMolstarPlugin {
|
|
|
829
852
|
update.delete(comp);
|
|
830
853
|
}
|
|
831
854
|
}
|
|
832
|
-
|
|
855
|
+
if (update.editInfo.count > 0) {
|
|
856
|
+
yield update.commit();
|
|
857
|
+
}
|
|
833
858
|
});
|
|
834
859
|
}
|
|
835
860
|
/** Get loci corresponding to a selection within a structure.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdbe-molstar",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"description": "Molstar implementation for PDBe",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -55,19 +55,19 @@
|
|
|
55
55
|
"babel-loader": "^8.2.5",
|
|
56
56
|
"concurrently": "^7.3.0",
|
|
57
57
|
"cpx2": "^7.0.1",
|
|
58
|
-
"css-loader": "^
|
|
58
|
+
"css-loader": "^7.1.2",
|
|
59
59
|
"eslint": "^9.9.0",
|
|
60
60
|
"file-loader": "^6.2.0",
|
|
61
61
|
"http-server": "^14.1.0",
|
|
62
62
|
"mini-css-extract-plugin": "^2.6.1",
|
|
63
63
|
"react": "^18.2.0",
|
|
64
64
|
"react-dom": "^18.2.0",
|
|
65
|
-
"sass": "^1.
|
|
66
|
-
"sass-loader": "^
|
|
67
|
-
"style-loader": "^
|
|
65
|
+
"sass": "^1.80.4",
|
|
66
|
+
"sass-loader": "^16.0.2",
|
|
67
|
+
"style-loader": "^4.0.0",
|
|
68
68
|
"typescript": "^4.6.4",
|
|
69
69
|
"typescript-eslint": "^8.2.0",
|
|
70
|
-
"webpack": "^5.
|
|
70
|
+
"webpack": "^5.95.0",
|
|
71
71
|
"webpack-cli": "^5.1.4"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"d3-scale": "^4.0.2",
|
|
79
79
|
"d3-selection": "^3.0.0",
|
|
80
80
|
"lit": "^3.1.1",
|
|
81
|
-
"molstar": "4.
|
|
81
|
+
"molstar": "4.8.0",
|
|
82
82
|
"path-browserify": "^1.0.1",
|
|
83
83
|
"stream-browserify": "^3.0.0",
|
|
84
84
|
"vm-browserify": "^1.1.2"
|