UNPKG

pdbe-molstar

Version:
200 lines (199 loc) 9.8 kB
import { ComponentExpressionT } from 'molstar/lib/extensions/mvs/tree/mvs/param-types'; import { Mat3, Mat4 } from 'molstar/lib/mol-math/linear-algebra'; import { Model, Structure } from 'molstar/lib/mol-model/structure'; import { BuiltInTrajectoryFormat } from 'molstar/lib/mol-plugin-state/formats/trajectory'; import { StructureRef } from 'molstar/lib/mol-plugin-state/manager/structure/hierarchy-state'; import { PluginConfigItem } from 'molstar/lib/mol-plugin/config'; import { PluginContext } from 'molstar/lib/mol-plugin/context'; import { PluginLayoutStateProps } from 'molstar/lib/mol-plugin/layout'; import { Expression } from 'molstar/lib/mol-script/language/expression'; import { Overpaint } from 'molstar/lib/mol-theme/overpaint'; import { Color } from 'molstar/lib/mol-util/color'; import { AnyColor, InitParams } from './spec'; export type SupportedFormats = 'mmcif' | 'bcif' | 'cif' | 'pdb' | 'sdf'; export interface LoadParams { url: string; format?: BuiltInTrajectoryFormat; assemblyId?: string; isHetView?: boolean; isBinary?: boolean; progressMessage?: string; /** Arbitrary string identifier to refer to this structure later */ id?: string; } export interface MapParams { 'em'?: MapStyle; '2fo-fc'?: MapStyle; 'fo-fc(+ve)'?: MapStyle; 'fo-fc(-ve)'?: MapStyle; } interface MapStyle { opacity?: number; wireframe?: boolean; } export declare namespace PDBeVolumes { function mapParams(defaultParams: any, mapParams?: MapParams, ref?: string | number): any; function displayUsibilityMessage(plugin: PluginContext): void; function toggle(plugin: PluginContext): void; } export declare namespace AlphafoldView { function getLociByPLDDT(score: number, contextData: Structure): import("molstar/lib/mol-model/structure/structure/element/loci").Loci; } export interface LigandQueryParam { label_comp_id_list?: any; auth_asym_id?: string; struct_asym_id?: string; label_comp_id?: string; auth_seq_id?: number; show_all?: boolean; } export declare namespace LigandView { function query(ligandViewParams: LigandQueryParam): { core: Expression; surroundings: Expression; }; function branchedQuery(params: any): { core: Expression; surroundings: Expression; }; } export interface QueryParam { auth_seq_id?: number; entity_id?: string; auth_asym_id?: string; struct_asym_id?: string; residue_number?: number; start_residue_number?: number; end_residue_number?: number; auth_residue_number?: number; auth_ins_code_id?: string; start_auth_residue_number?: number; start_auth_ins_code_id?: string; end_auth_residue_number?: number; end_auth_ins_code_id?: string; atoms?: string[]; label_comp_id?: string; color?: any; sideChain?: boolean; representation?: string; representationColor?: any; focus?: boolean; tooltip?: string; /** @deprecated I don't know what this is */ start?: any; /** @deprecated I don't know what this is */ end?: any; atom_id?: number[]; uniprot_accession?: string; uniprot_residue_number?: number; start_uniprot_residue_number?: number; end_uniprot_residue_number?: number; } export declare function queryParamsToMvsComponentExpressions(params: QueryParam[]): ComponentExpressionT[]; export declare namespace QueryHelper { function getQueryObject(params: QueryParam[], contextData: Structure): Expression; function getInteractivityLoci(params: QueryParam[], contextData: Structure): import("molstar/lib/mol-model/structure/structure/element/loci").Loci; function getHetLoci(queryExp: Expression, contextData: Structure): import("molstar/lib/mol-model/structure/structure/element/loci").Loci; } export interface ModelInfo { hetNames: string[]; carbEntityCount: number; } export declare namespace ModelInfo { function get(model: Model, structures: any): Promise<ModelInfo>; } /** Run `action` with showing a message in the bottom-left corner of the plugin UI */ export declare function runWithProgressMessage(plugin: PluginContext, progressMessage: string | undefined, action: () => any): Promise<void>; /** Parameters for a request to ModelServer */ export interface ModelServerRequest { pdbId: string; queryType: 'full' | 'residueSurroundings' | 'atoms'; queryParams?: Record<string, any>; } /** Return URL for a ModelServer request. * If `queryType` is 'full' and `lowPrecisionCoords` is false, return URL of the static file instead (updated mmCIF or bCIF). */ export declare function getStructureUrl(initParams: InitParams, request: ModelServerRequest): string; /** Combine URL parts into one URL while avoiding double slashes. Examples: * combineUrl('https://example.org', '1tqn') -> 'https://example.org/1tqn'; * combineUrl('https://example.org/', '1tqn') -> 'https://example.org/1tqn'; */ export declare function combineUrl(firstPart: string, ...moreParts: string[]): string; /** Create a copy of object `object`, fill in missing/undefined keys using `defaults`. * This is similar to {...defaults,...object} but `undefined` in `object` will not override a value from `defaults`. */ export declare function addDefaults<T extends {}>(object: Partial<T> | undefined, defaults: T): T; /** Convert `colorVal` from any of supported color formats (e.g. 'yellow', '#ffff00', {r:255,g:255,b:0}) to `Color`. * Return default color (gray) if `colorVal` is undefined or null. */ export declare function normalizeColor(colorVal: AnyColor | null | undefined, defaultColor?: Color): Color; /** Apply overpaint to every representation of every component in a structure. * Excludes representations created as "added representations" by `PDBeMolstarPlugin.visual.select`. */ export declare function applyOverpaint(plugin: PluginContext, structRef: StructureRef, overpaintLayers: Overpaint.BundleLayer[]): Promise<void>; export declare const Tags: { /** Tag needed for `clearStructureOverpaint`; defined in src/mol-plugin-state/helpers/structure-overpaint.ts but private */ readonly Overpaint: "overpaint-controls"; /** Marks structure components added by `select` */ readonly AddedComponent: "pdbe-molstar.added-component"; }; export declare const StructureComponentTags: { polymer: string[]; het: string[]; water: string[]; carbs: string[]; nonStandard: string[]; coarse: string[]; maps: string[]; }; /** Return component type based on the component's PluginStateObject tags */ export declare function getComponentTypeFromTags(tags: string[] | undefined): keyof typeof StructureComponentTags | undefined; /** Return a new array containing `values` without duplicates (only first occurrence will be kept). * Values v1, v2 are considered duplicates when `key(v1)===key(v2)`. */ export declare function distinct<T>(values: T[], key?: ((value: T) => unknown)): T[]; /** Group elements by result of `groupFunction` applied to them */ export declare function groupElements<T, G>(elements: T[], groupFunction: (elem: T) => G): { /** Groups (results of `groupFunction`) in order as they first appeared in `elements` */ groups: G[]; /** Mapping of groups to lists of they members */ members: Map<G, T[]>; }; /** Return a mapping of elements to their index in the `elements` array */ export declare function createIndex<T>(elements: T[]): Map<T, number>; /** Return modulo of two numbers (a % b) within range [0, b) */ export declare function nonnegativeModulo(a: number, b: number): number; /** `{ status: 'completed', result: result }` means the job completed and returned/resolved to `result`. * `{ status: 'cancelled' }` means the job started but another jobs got enqueued before its completion. * `{ status: 'skipped' }` means the job did not start because another jobs got enqueued. */ export type PreemptiveQueueResult<Y> = { status: 'completed'; result: Awaited<Y>; } | { status: 'cancelled'; } | { status: 'skipped'; }; /** Queue for running jobs where enqueued jobs get discarded when a new job is enqueued. * (Discarded jobs may or may not actually be executed, but their result is not accessible anyway.) */ export declare class PreemptiveQueue<X, Y> { private readonly run; private running?; private queuing?; constructor(run: (args: X) => Y | Promise<Y>); /** Enqueue a job which will execute `run(args)`. * Return a promise that either resolves to `{ status: 'completed', result }` where `result` is `await run(args)`, * or resolves to `{ status: 'cancelled' }` if the job starts being executed but another jobs gets enqueued before its completion, * or resolves to `{ status: 'skipped' }` if the job does not even start before another jobs gets enqueued, * or rejects if the job is completed but throws an error. */ requestRun(args: X): Promise<PreemptiveQueueResult<Y>>; /** Request handling loop. Resolves when there are no more requests. Not to be awaited, should run in the background. */ private handleRequests; } /** Functions for working with plugin config items */ export declare namespace PluginConfigUtils { /** Type of config definition for given type of config values T */ type ConfigFor<T extends object> = { [key in keyof T]: PluginConfigItem<T[key]>; }; /** Retrieve config values for items in `configItems` from the current plugin config */ function getConfigValues<T extends object>(plugin: PluginContext | undefined, configItems: ConfigFor<T>, defaults: T): T; } export declare function pluginLayoutStateFromInitParams(initParams: InitParams): PluginLayoutStateProps; export declare function getRotationMat4(view: 'front' | 'back' | 'right' | 'left' | 'top' | 'bottom' | Mat3): Mat4; export {};