@molstudio/core 0.0.0-stage → 0.1.0
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/dist/LICENSE +21 -0
- package/dist/MolStudio.d.ts +147 -0
- package/dist/MolStudio.js +867 -0
- package/dist/data-access.d.ts +10 -0
- package/dist/data-access.js +74 -0
- package/dist/hover-label.d.ts +7 -0
- package/dist/hover-label.js +50 -0
- package/dist/image-encode.d.ts +10 -0
- package/dist/image-encode.js +124 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -0
- package/dist/plugins.d.ts +27 -0
- package/dist/plugins.js +1 -0
- package/dist/structure-parts.d.ts +37 -0
- package/dist/structure-parts.js +193 -0
- package/dist/types.d.ts +202 -0
- package/dist/types.js +1 -0
- package/dist/volume-stats.d.ts +4 -0
- package/dist/volume-stats.js +31 -0
- package/package.json +40 -4
- package/README.md +0 -3
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 shuuul
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { BuiltInTrajectoryFormat } from "molstar/lib/mol-plugin-state/formats/trajectory";
|
|
2
|
+
import { PluginContext } from "molstar/lib/mol-plugin/context";
|
|
3
|
+
import type { MolStudioPlugin } from "./plugins";
|
|
4
|
+
import type { AtomTable, ColorScheme, ImageExportOptions, ImageFraming, ImageLimits, OverridablePart, SequenceResidue, StructurePart, RepresentationKind, StudioSnapshot, VolumeGrid, VolumeHistogram, VolumeStyle } from "./types";
|
|
5
|
+
export type StructureFormat = BuiltInTrajectoryFormat;
|
|
6
|
+
export type VolumeFormat = "ccp4" | "dsn6" | "cube" | "dx" | "dscif";
|
|
7
|
+
export interface LoadDataOptions<F extends string> {
|
|
8
|
+
data: string | Uint8Array<ArrayBuffer>;
|
|
9
|
+
label: string;
|
|
10
|
+
format: F;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Owns a UI-less Mol* plugin and exposes the viewer as a list of objects
|
|
14
|
+
* (structures, volumes) with a small set of display operations.
|
|
15
|
+
* Mol* state stays the single source of truth; snapshots are derived from it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class MolStudio {
|
|
18
|
+
readonly plugin: PluginContext;
|
|
19
|
+
private snapshot;
|
|
20
|
+
private readonly plugins;
|
|
21
|
+
private readonly listeners;
|
|
22
|
+
private readonly subscriptions;
|
|
23
|
+
private rebuildScheduled;
|
|
24
|
+
/** Author-recommended contour levels (absolute) fetched from EMDB, keyed by volume ref. */
|
|
25
|
+
private readonly authorContours;
|
|
26
|
+
private readonly isoUpdates;
|
|
27
|
+
private readonly overrideCreations;
|
|
28
|
+
/** The view from before Mol*'s focus view began, so leaving focus can return to it. */
|
|
29
|
+
private cameraBeforeFocus;
|
|
30
|
+
private constructor();
|
|
31
|
+
static create(target: HTMLElement): Promise<MolStudio>;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
subscribe: (listener: () => void) => (() => void);
|
|
34
|
+
getSnapshot: () => StudioSnapshot;
|
|
35
|
+
private publish;
|
|
36
|
+
private scheduleRebuild;
|
|
37
|
+
/** Registers a plugin and returns a function that unregisters it. */
|
|
38
|
+
registerPlugin(plugin: MolStudioPlugin): () => void;
|
|
39
|
+
private unregisterPlugin;
|
|
40
|
+
runAction(pluginId: string, actionId: string, objectId: string): Promise<void>;
|
|
41
|
+
private publishActions;
|
|
42
|
+
getAtoms(objectId: string): AtomTable;
|
|
43
|
+
/** The grid is shared with the viewer when its layout allows; treat `values` as read-only. */
|
|
44
|
+
getVolumeGrid(objectId: string): VolumeGrid;
|
|
45
|
+
loadStructure({ data, label, format }: LoadDataOptions<StructureFormat>): Promise<void>;
|
|
46
|
+
loadStructureFromUrl(url: string, label: string, format: StructureFormat, isBinary: boolean): Promise<void>;
|
|
47
|
+
loadPdb(id: string): Promise<void>;
|
|
48
|
+
loadAlphaFoldDb(uniprotId: string): Promise<void>;
|
|
49
|
+
/** Accepts `EMD-1832` or the bare number `1832`; the map opens at the author-recommended contour. */
|
|
50
|
+
loadEmdb(id: string): Promise<void>;
|
|
51
|
+
loadVolume({ data, label, format }: LoadDataOptions<VolumeFormat>): Promise<void>;
|
|
52
|
+
loadVolumeFromUrl(url: string, label: string, format: VolumeFormat, isBinary: boolean): Promise<void>;
|
|
53
|
+
private applyStructurePreset;
|
|
54
|
+
private applyVolumeVisuals;
|
|
55
|
+
setVisible(id: string, visible: boolean): void;
|
|
56
|
+
/**
|
|
57
|
+
* Structure display operations take a target: a structure id changes its main (polymer) component,
|
|
58
|
+
* a component ref (see `StructureObject.components`) changes that component alone.
|
|
59
|
+
*/
|
|
60
|
+
setRepresentation(target: string, kind: RepresentationKind): Promise<void>;
|
|
61
|
+
setColorScheme(target: string, scheme: ColorScheme): Promise<void>;
|
|
62
|
+
/** Colors the target uniformly with `hex`. */
|
|
63
|
+
setColor(target: string, hex: string): Promise<void>;
|
|
64
|
+
/** A structure id changes every component; a component ref or volume id changes only that. */
|
|
65
|
+
setOpacity(target: string, opacity: number): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Latest call wins: while an isosurface is being rebuilt, further levels for the same volume replace
|
|
68
|
+
* each other and only the last one is applied next. Live dragging therefore never queues up work.
|
|
69
|
+
* The returned promise settles once the surface matches the most recent level.
|
|
70
|
+
*/
|
|
71
|
+
setIsoLevel(id: string, sigma: number): Promise<void>;
|
|
72
|
+
/** Fetches (once) and applies the EMDB author-recommended contour level. */
|
|
73
|
+
applyAuthorLevel(id: string): Promise<void>;
|
|
74
|
+
getVolumeHistogram(id: string): VolumeHistogram;
|
|
75
|
+
private fetchAuthorContour;
|
|
76
|
+
private requireVolumeData;
|
|
77
|
+
private volumeName;
|
|
78
|
+
setVolumeStyle(id: string, style: VolumeStyle): Promise<void>;
|
|
79
|
+
setVolumeColor(id: string, hex: string): Promise<void>;
|
|
80
|
+
/** Moves the camera to an object, or to one structure component by ref. */
|
|
81
|
+
focus(target: string): void;
|
|
82
|
+
remove(id: string): Promise<void>;
|
|
83
|
+
getSequence(objectId: string, chainIndex: number): SequenceResidue[];
|
|
84
|
+
/** Highlights a part in the 3D view the way pointer hover does; `null` clears the highlight. */
|
|
85
|
+
highlightPart(part: StructurePart | null): void;
|
|
86
|
+
/** Moves the camera to a part; a residue also gets Mol*'s focus view with its surroundings. */
|
|
87
|
+
focusPart(part: StructurePart): void;
|
|
88
|
+
/** Leaves Mol*'s focus view, removing its target and surroundings components, and returns to the earlier view. */
|
|
89
|
+
clearFocus(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Hides or shows an entity, chain, or residue in every component by making it fully transparent,
|
|
92
|
+
* which also removes it from picking. Component visibility (`setVisible`) is independent of this.
|
|
93
|
+
*/
|
|
94
|
+
setPartVisible(part: StructurePart, visible: boolean): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Gives an entity or chain its own component, drawn like the structure until changed, and hides it in
|
|
97
|
+
* the other components. Returns the component ref (the existing one if the part already has it), which
|
|
98
|
+
* the display operations accept as their target.
|
|
99
|
+
*/
|
|
100
|
+
overridePart(part: OverridablePart): Promise<string>;
|
|
101
|
+
private createOverride;
|
|
102
|
+
/** Removes a part's own component, so the part is drawn by the structure's components again. */
|
|
103
|
+
resetPart(part: OverridablePart): Promise<void>;
|
|
104
|
+
private overrideOf;
|
|
105
|
+
private componentPart;
|
|
106
|
+
/**
|
|
107
|
+
* Hides each override's part in the components it replaces: the structure's own components and, for
|
|
108
|
+
* a chain, an override of its entity, so the more specific display wins where parts overlap.
|
|
109
|
+
*/
|
|
110
|
+
private maskOverrides;
|
|
111
|
+
private hiddenChainsOf;
|
|
112
|
+
/** Transparency layers of a component, read from state so they are current right after a commit. */
|
|
113
|
+
private transparencyLayers;
|
|
114
|
+
private partLoci;
|
|
115
|
+
private residueRef;
|
|
116
|
+
resetCamera(): void;
|
|
117
|
+
setSpinning(spinning: boolean): void;
|
|
118
|
+
setBackground(hex: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Keeps the orientation axes in the bottom-left corner of the canvas region that floating UI leaves
|
|
121
|
+
* uncovered; offsets are CSS pixels from the canvas's bottom-left corner.
|
|
122
|
+
*/
|
|
123
|
+
setAxesInset(left: number, bottom: number): void;
|
|
124
|
+
imageLimits(): ImageLimits;
|
|
125
|
+
/** A quick, unsmoothed render of the framing as a PNG data URL, for previews. */
|
|
126
|
+
previewImage(framing: ImageFraming, maxDim?: number): Promise<string>;
|
|
127
|
+
/** Renders the image at full quality and encodes it with its print resolution. */
|
|
128
|
+
exportImage(options: ImageExportOptions): Promise<Blob>;
|
|
129
|
+
/** Points Mol*'s screenshot helper at the framing; white is composited later onto a transparent render. */
|
|
130
|
+
private prepareScreenshot;
|
|
131
|
+
private buildObjects;
|
|
132
|
+
private describeStructure;
|
|
133
|
+
private describeVolume;
|
|
134
|
+
private applicableSchemes;
|
|
135
|
+
private requireObject;
|
|
136
|
+
private requireStructure;
|
|
137
|
+
private requireStructureData;
|
|
138
|
+
private requireComponent;
|
|
139
|
+
/** Representations a structure display operation changes; see `setRepresentation`. */
|
|
140
|
+
private displayTarget;
|
|
141
|
+
private requireVolume;
|
|
142
|
+
private requireCanvas;
|
|
143
|
+
/** The top-level data node an object was created from (the loaded file or download). */
|
|
144
|
+
private rootRef;
|
|
145
|
+
private rootLabel;
|
|
146
|
+
private updateEach;
|
|
147
|
+
}
|