UNPKG

pdbe-molstar

Version:
238 lines (237 loc) 14.5 kB
import { loadMVS } from 'molstar/lib/extensions/mvs/load'; import { MVSData } from 'molstar/lib/extensions/mvs/mvs-data'; import { Canvas3DProps } from 'molstar/lib/mol-canvas3d/canvas3d'; import { Mat3 } from 'molstar/lib/mol-math/linear-algebra'; import { EmptyLoci } from 'molstar/lib/mol-model/loci'; import { StructureElement } from 'molstar/lib/mol-model/structure'; import { StructureRef } from 'molstar/lib/mol-plugin-state/manager/structure/hierarchy-state'; import { PluginContext } from 'molstar/lib/mol-plugin/context'; import { Color } from 'molstar/lib/mol-util/color/color'; import * as Complexes from './extensions/complexes'; import * as Foldseek from './extensions/foldseek'; import * as Interactions from './extensions/interactions'; import { StateGalleryManager } from './extensions/state-gallery/manager'; import { StateGalleryControls } from './extensions/state-gallery/ui'; import { LoadParams, QueryParam } from './helpers'; import { AnyColor, InitParams } from './spec'; import { LayoutSpec } from './ui/split-ui/split-ui'; export declare class PDBeMolstarPlugin { /** Helper for creating events (e.g. RxJS Subjects) */ private _ev; readonly events: { loadComplete: import("rxjs").Subject<boolean>; }; plugin: PluginContext; initParams: InitParams; targetElement: HTMLElement; assemblyRef: string; defaultRendererProps: Canvas3DProps['renderer']; defaultMarkingProps: Canvas3DProps['marking']; isHighlightColorUpdated: boolean; isSelectedColorUpdated: boolean; /** Keeps track of representations added by `.visual.select` for each structure. */ private addedReprs; /** Maps structure IDs (assigned when loading) to cell refs. */ private structureRefMap; /** Extract InitParams from attributes of an HTML element */ static initParamsFromHtmlAttributes(element: HTMLElement): Partial<InitParams>; render(target: string | HTMLElement | LayoutSpec, options: Partial<InitParams>): Promise<void>; getMoleculeSrcUrl(): { url: string; format: string; isBinary: boolean; }; get state(): import("molstar/lib/mol-state").State; createLigandStructure(isBranched: boolean): Promise<void>; load({ url, format, isBinary, assemblyId, progressMessage, id }: LoadParams, fullLoad?: boolean): Promise<void>; /** Remove loaded structure(s). * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure. * If `structureNumberOrId` is undefined, remove all structures. * You will likely need to call `await this.visual.reset({ camera: true })` afterwards. */ deleteStructure(structureNumberOrId?: number | string): Promise<void>; /** Apply representations to structure components based on `styles`, also removing any existing representations. * Components not included in `styles` will keep their representations. * 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. * E.g. `styles='ball-and-stick'` - apply only ball-and-stick to all components. */ private applyVisualStyles; private defaultColorTheme; /** Remove all structure components of the given structure which correspond to any component type listed in `deleteComponents`. */ private deleteStructureComponents; /** Get loci corresponding to a selection within a structure. * If `params` contains more items, return loci for the union of the selections. * If `structureNumber` is provided, use the specified structure (numbered from 1!); otherwise use the last added structure. */ getLociForParams(params: QueryParam[], structureNumberOrId?: number | string): StructureElement.Loci | EmptyLoci; getLociByPLDDT(score: number, structureNumber?: number): StructureElement.Loci | { kind: "empty-loci"; }; /** For each item in params, get loci and bundle */ private getSelections; private getBundle; normalizeColor(colorVal: AnyColor | null | undefined, defaultColor?: Color): Color; /** Get structure ref for a structure with given `structureNumberOrId`. * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure. * If `structureNumberOrId` is undefined, return refs for all loaded structures. */ private getStructures; /** Get StructureRef for a structure with given `structureNumberOrId`. * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure. */ getStructure(structureNumberOrId: number | string): StructureRef | undefined; /** Helper methods related to canvas and layout */ canvas: { /** Set canvas background color. */ setBgColor: (color?: AnyColor) => Promise<void>; /** Set controls panel visibility. Without `isVisible` parameter, toggle controls panel visibility. */ toggleControls: (isVisible?: boolean) => void; /** Set full-screen mode on or off. Without `isExpanded` parameter, toggle full-screen mode. */ toggleExpanded: (isExpanded?: boolean) => void; applySettings: (settings?: { color?: AnyColor; lighting?: string; }) => Promise<void>; }; /** Helper methods related to 3D visuals */ visual: { /** Change the visibility of individual entity visuals */ visibility: (data: { polymer?: boolean; het?: boolean; water?: boolean; carbs?: boolean; nonStandard?: boolean; maps?: boolean; }) => Promise<void>; /** Change the visibility of a structure. * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure. * If `visibility` is undefined, toggle current visibility state. */ structureVisibility: (structureNumberOrId: string | number, visibility?: boolean) => Promise<void>; /** With `isSpinning` parameter, switch visual rotation on or off. Without `isSpinning` parameter, toggle rotation. If `resetCamera`, also reset the camera zoom. */ toggleSpin: (isSpinning?: boolean, resetCamera?: boolean) => Promise<void>; /** Focus (zoom) on the part of the structure defined by `selection`. * If `selection` contains more items, focus on the union of those. * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure; * if not provided, will use the last added structure. */ focus: (selection: QueryParam[], structureNumberOrId?: number | string) => Promise<void>; /** Apply interactive focus behavior on the part of the structure defined by `data` (i.e. emulate user clicking on a substructure). * This includes behaviors like "show non-covalent interactions" or "show streamed volume data" * but not camera adjustment (call `.visual.focus` for that). * If `data` contains more items, focus on the union of those. * If `structureId` or `structureNumber` is provided, use the specified structure (numbered from 1!); * otherwise use the last added structure. */ interactivityFocus: (params: { data: QueryParam[]; structureId?: string; structureNumber?: number; }) => Promise<void>; /** Trigger highlight on the part of the structure defined by `data` * (this will look the same as when the user hovers over a part of the structure). * If `focus`, also zoom on the highlighted part. * If `structureId` or `structureNumber` is provided, use the specified structure (numbered from 1!); otherwise use the last added structure. */ highlight: (params: { data: QueryParam[]; color?: AnyColor; focus?: boolean; structureId?: string; structureNumber?: number; }) => Promise<void>; /** Remove any current highlight and reset the highlight color to its default value. */ clearHighlight: () => Promise<void>; /** Color the parts of the structure defined by `data`. Color the rest of the structure in `nonSelectedColor` if provided. * If any items in `data` contain `focus`, zoom to the union of these items. * If any items in `data` contain `sideChain` or `representation`, add extra representations to them (colored in `representationColor` if provided). * If `structureNumber` is provided, apply to the specified structure (numbered from 1!); otherwise apply to all loaded structures. * Remove any previously added coloring and extra representations, unless `keepColors` and/or `keepRepresentations` is set. */ select: (params: { data: QueryParam[]; nonSelectedColor?: AnyColor; structureId?: string; structureNumber?: number; keepColors?: boolean; keepRepresentations?: boolean; }) => Promise<void>; /** Remove any coloring and extra representations previously added by the `select` method. * `structureNumberOrId` is either index (numbered from 1!) or the ID that was provided when loading the structure; * if not provided, will apply to all loaded structures. * If `keepColors`, current residue coloring is preserved. If `keepRepresentations`, current added representations are preserved. */ clearSelection: (structureNumberOrId?: number | string, options?: { keepColors?: boolean; keepRepresentations?: boolean; }) => Promise<void>; /** Add interactive tooltips to parts of the structure. The added tooltips will be shown on a separate line in the tooltip box. * Repeated call to this function removes any previously added tooltips. * `structureNumber` counts from 1; if not provided, tooltips will be applied to all loaded structures. * Example: `await this.visual.tooltips({ data: [{ struct_asym_id: 'A', tooltip: 'Chain A' }, { struct_asym_id: 'B', tooltip: 'Chain B' }] });`. */ tooltips: (params: { data: QueryParam[]; structureId?: string; structureNumber?: number; }) => Promise<void>; /** Remove any custom tooltips added by the `tooltips` method. */ clearTooltips: (structureNumberOrId?: number | string) => Promise<void>; /** Set highlight and/or selection color. * Highlight color is used when the user hovers over a part of the structure or when applying the `highlight` method. * 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. */ setColor: (params: { highlight?: AnyColor; select?: AnyColor; }) => Promise<void>; /** Reset various settings to defaults: * `camera` resets camera position (i.e. zooms on the whole scene). * `theme` resets color theme for visual representations. * `highlightColor` and `selectColor` reset colors previously set by the `setColor` method. */ reset: (params: { camera?: boolean; theme?: boolean; highlightColor?: boolean; selectColor?: boolean; }) => Promise<void>; setViewDirection: (view: "front" | "back" | "right" | "left" | "top" | "bottom" | Mat3, options?: { durationMs: number; }) => Promise<void>; /** Change parameters of the plugin instance. * Can be used to load a different structure. * If `fullLoad`, remove currently loaded structure before loading the new one; * otherwise add the new structure to existing structures. */ update: (options: Partial<InitParams>, fullLoad?: boolean) => Promise<boolean>; }; clear(): Promise<void>; /** Helper functions related to specific views or use cases */ static extensions: { Complexes: typeof Complexes; Foldseek: typeof Foldseek; Interactions: typeof Interactions; MVS: { MVSData: { SupportedVersion: number; fromMVSJ(mvsjString: string): MVSData; toMVSJ(mvsData: MVSData, space?: string | number): string; isValid(mvsData: MVSData, options?: { noExtra?: boolean; }): boolean; validationIssues(mvsData: MVSData, options?: { noExtra?: boolean; }): string[] | undefined; toPrettyString(mvsData: MVSData): string; createBuilder(): import("molstar/lib/extensions/mvs/tree/mvs/mvs-builder").Root; createMultistate(snapshots: import("molstar/lib/extensions/mvs/mvs-data").Snapshot[], metadata?: Pick<import("molstar/lib/extensions/mvs/mvs-data").GlobalMetadata, "title" | "description" | "description_format">): import("molstar/lib/extensions/mvs/mvs-data").MVSData_States; stateToStates(state: import("molstar/lib/extensions/mvs/mvs-data").MVSData_State): import("molstar/lib/extensions/mvs/mvs-data").MVSData_States; }; loadMVS: typeof loadMVS; }; StateGallery: { StateGalleryManager: typeof StateGalleryManager; StateGalleryCustomState: (plugin: PluginContext) => Partial<import("./extensions/state-gallery/behavior").StateGalleryCustomState>; UI: { StateGalleryControls: typeof StateGalleryControls; }; }; }; /** Components for building custom UI layouts */ static UIComponents: { readonly PDBeViewport: import("react").ComponentClass<{}, any>; readonly SequenceView: typeof import("molstar/lib/mol-plugin-ui/sequence").SequenceView; readonly Log: typeof import("molstar/lib/mol-plugin-ui/plugin").Log; readonly PDBeLeftPanelControls: import("react").ComponentClass<{}, any>; readonly DefaultLeftPanelControls: import("react").ComponentClass<{}, any>; readonly DefaultRightPanelControls: typeof import("molstar/lib/mol-plugin-ui/plugin").ControlsWrapper; }; static MAIN_STRUCTURE_ID: string; }