molstar
Version:
A comprehensive macromolecular library.
110 lines (109 loc) • 8.07 kB
TypeScript
/**
* Copyright (c) 2023-2026 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Adam Midlik <midlik@gmail.com>
* @author David Sehnal <david.sehnal@gmail.com>
*/
import { Mat4, Vec3 } from '../../mol-math/linear-algebra.js';
import { StructureComponentParams } from '../../mol-plugin-state/helpers/structure-component.js';
import { StructureFromModel } from '../../mol-plugin-state/transforms/model.js';
import { StructureRepresentation3D, VolumeRepresentation3D } from '../../mol-plugin-state/transforms/representation.js';
import { StateTransformer } from '../../mol-state/index.js';
import { Clip } from '../../mol-util/clip.js';
import { MVSAnnotationColorThemeProps } from './components/annotation-color-theme.js';
import { MVSAnnotationSpec } from './components/annotation-prop.js';
import { MVSAnnotationStructureComponentProps } from './components/annotation-structure-component.js';
import { MVSAnnotationTooltipsProps } from './components/annotation-tooltips-prop.js';
import { CustomLabelTextProps } from './components/custom-label/visual.js';
import { CustomTooltipsProps } from './components/custom-tooltips-prop.js';
import { ElementOfSet } from './helpers/utils.js';
import { MolstarLoadingContext } from './load.js';
import { UpdateTarget } from './load-generic.js';
import { Subtree } from './tree/generic/tree-schema.js';
import { MolstarNode, MolstarNodeParams, MolstarSubtree, MolstarTree } from './tree/molstar/molstar-tree.js';
export declare const AnnotationFromUriKinds: Set<"component_from_uri" | "color_from_uri" | "label_from_uri" | "tooltip_from_uri">;
export type AnnotationFromUriKind = ElementOfSet<typeof AnnotationFromUriKinds>;
export declare const AnnotationFromSourceKinds: Set<"component_from_source" | "color_from_source" | "label_from_source" | "tooltip_from_source">;
export type AnnotationFromSourceKind = ElementOfSet<typeof AnnotationFromSourceKinds>;
/** Return a 4x4 matrix representing a rotation followed by a translation */
export declare function transformFromRotationTranslation(rotation: number[] | null | undefined, translation: number[] | null | undefined): Mat4;
export declare function decomposeRotationMatrix(rotation: number[] | null | undefined): {
axis: Vec3;
angle: number;
};
export declare function transformAndInstantiateStructure(target: UpdateTarget, node: MolstarSubtree<'structure' | 'component' | 'component_from_source' | 'component_from_uri'>): UpdateTarget;
export declare function transformAndInstantiateVolume(target: UpdateTarget, node: MolstarSubtree<'volume'>): UpdateTarget;
/** Collect distinct annotation specs from all nodes in `tree` and set `context.annotationMap[node]` to respective annotationIds */
export declare function collectAnnotationReferences(tree: Subtree<MolstarTree>, context: MolstarLoadingContext): MVSAnnotationSpec[];
/** Collect annotation tooltips from all nodes in `tree` and map them to annotationIds. */
export declare function collectAnnotationTooltips(tree: MolstarSubtree<'structure'>, context: MolstarLoadingContext): MVSAnnotationTooltipsProps['tooltips'];
/** Collect inline tooltips from all nodes in `tree`. */
export declare function collectInlineTooltips(tree: MolstarSubtree<'structure'>, context: MolstarLoadingContext): CustomTooltipsProps['tooltips'];
/** Collect inline labels from all nodes in `tree`. */
export declare function collectInlineLabels(tree: MolstarSubtree<'structure'>, context: MolstarLoadingContext): CustomLabelTextProps['items'];
/** Return `true` for components nodes which only serve for tooltip placement (not to be created in the MolStar object hierarchy) */
export declare function isPhantomComponent(node: MolstarSubtree<'component' | 'component_from_uri' | 'component_from_source'>): boolean | undefined;
/** Create props for `StructureFromModel` transformer from a structure node. */
export declare function structureProps(node: MolstarNode<'structure'>): StateTransformer.Params<StructureFromModel>;
/** Create value for `type` prop for `StructureComponent` transformer based on a MVS selector. */
export declare function componentPropsFromSelector(selector?: MolstarNodeParams<'component'>['selector']): StructureComponentParams['type'];
/** Return a pretty name for a value of selector param, e.g. "protein" -> 'Protein', {label_asym_id: "A"} -> 'Custom Selection: {label_asym_id: "A"}' */
export declare function prettyNameFromSelector(selector?: MolstarNodeParams<'component'>['selector']): string;
/** Create props for `StructureRepresentation3D` transformer from a label_from_* node. */
export declare function labelFromXProps(node: MolstarNode<'label_from_uri' | 'label_from_source'>, context: MolstarLoadingContext): Partial<StateTransformer.Params<StructureRepresentation3D>>;
/** Create props for `AnnotationStructureComponent` transformer from a component_from_* node. */
export declare function componentFromXProps(node: MolstarNode<'component_from_uri' | 'component_from_source'>, context: MolstarLoadingContext): Partial<MVSAnnotationStructureComponentProps>;
export declare function representationProps(node: MolstarSubtree<'representation'>): Partial<StateTransformer.Params<StructureRepresentation3D>>;
/** Create value for `type.params.alpha` prop for `StructureRepresentation3D` transformer from a representation node based on 'opacity' nodes in its subtree. */
export declare function alphaForNode(node: MolstarSubtree<'representation' | 'volume_representation'>): number;
export declare function clippingForNode(node: MolstarSubtree<'representation' | 'volume_representation' | 'primitives' | 'primitives_from_uri'>): Clip.Props | undefined;
/** Create value for `colorTheme` prop for `StructureRepresentation3D` transformer from a representation node based on color* nodes in its subtree. */
export declare function colorThemeForNode(node: MolstarSubtree<'color' | 'color_from_uri' | 'color_from_source' | 'representation' | 'volume'> | undefined, context: MolstarLoadingContext): StateTransformer.Params<StructureRepresentation3D>['colorTheme'] | undefined;
export declare function palettePropsFromMVSPalette(palette: MolstarNode<'color_from_uri' | 'color_from_source'>['params']['palette']): MVSAnnotationColorThemeProps['palette'];
/** Create a mapping of nearest representation nodes for each node in the tree
* (to transfer coloring to label nodes smartly).
* Only considers nodes within the same 'structure' subtree. */
export declare function makeNearestReprMap(root: MolstarTree): Map<MolstarNode, {
kind: "representation";
params: ({
type: "line";
} & {
size_factor: number;
ignore_hydrogens: boolean;
} & {}) | ({
type: "carbohydrate";
} & {
size_factor: number;
} & {}) | ({
type: "spacefill";
} & {
size_factor: number;
ignore_hydrogens: boolean;
} & {}) | ({
type: "surface";
} & {
surface_type: "gaussian" | "molecular";
size_factor: number;
ignore_hydrogens: boolean;
} & {}) | ({
type: "backbone";
} & {
size_factor: number;
} & {}) | ({
type: "cartoon";
} & {
size_factor: number;
tubular_helices: boolean;
} & {}) | ({
type: "ball_and_stick";
} & {
size_factor: number;
ignore_hydrogens: boolean;
} & {});
custom?: import("./tree/generic/tree-schema.js").CustomProps;
ref?: string;
}>;
/** Create props for `VolumeRepresentation3D` transformer from a representation node. */
export declare function volumeRepresentationProps(node: MolstarSubtree<'volume_representation'>): Partial<StateTransformer.Params<VolumeRepresentation3D>>;
/** Create value for `colorTheme` prop for `StructureRepresentation3D` transformer from a representation node based on color* nodes in its subtree. */
export declare function volumeColorThemeForNode(node: MolstarSubtree<'volume_representation'> | undefined, context: MolstarLoadingContext): StateTransformer.Params<VolumeRepresentation3D>['colorTheme'] | undefined;