|
@@ -0,0 +1,159 @@
|
|
|
+/**
|
|
|
+ * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
|
+ *
|
|
|
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
|
|
|
+ */
|
|
|
+
|
|
|
+import { ParamDefinition as PD } from 'molstar/lib/mol-util/param-definition';
|
|
|
+import { TrajectoryHierarchyPresetProvider } from 'molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset';
|
|
|
+import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects';
|
|
|
+import { RootStructureDefinition } from 'molstar/lib/mol-plugin-state/helpers/root-structure';
|
|
|
+import { StructureRepresentationPresetProvider } from 'molstar/lib/mol-plugin-state/builder/structure/representation-preset';
|
|
|
+import {
|
|
|
+ StateObjectSelector,
|
|
|
+ StateObject,
|
|
|
+ StateTransformer,
|
|
|
+ StateObjectRef,
|
|
|
+ StateTransform
|
|
|
+} from 'molstar/lib/mol-state';
|
|
|
+import { Mat4, Vec3 } from 'molstar/lib/mol-math/linear-algebra';
|
|
|
+import { MembraneOrientationPreset } from 'molstar/lib/extensions/anvil/behavior';
|
|
|
+import { Target } from '@rcsb/rcsb-molstar/build/src/viewer/helpers/selection';
|
|
|
+import { TMDET_STRUCTURE_PRESET_ID } from './tmdet-extension/behavior';
|
|
|
+import { TmDetDescriptorCache } from './tmdet-extension/prop';
|
|
|
+import { DebugUtil } from './tmdet-extension/debug-utils';
|
|
|
+import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms';
|
|
|
+import { applyTransformations } from './tmdet-extension/transformation';
|
|
|
+
|
|
|
+type BaseProps = {
|
|
|
+ assemblyId?: string
|
|
|
+ modelIndex?: number
|
|
|
+ plddt?: 'off' | 'single-chain' | 'on'
|
|
|
+}
|
|
|
+
|
|
|
+export { Mat4 } from 'molstar/lib/mol-math/linear-algebra';
|
|
|
+
|
|
|
+export type AlignmentProps = {
|
|
|
+ kind: 'alignment',
|
|
|
+ targets?: (Target & {
|
|
|
+ matrix?: Mat4
|
|
|
+ })[],
|
|
|
+ colors: {
|
|
|
+ value: number,
|
|
|
+ targets: Target[]
|
|
|
+ }[]
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+export type EmptyProps = {
|
|
|
+ kind: 'empty'
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type ValidationProps = {
|
|
|
+ kind: 'validation'
|
|
|
+ colorTheme?: string
|
|
|
+ showClashes?: boolean
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type StandardProps = {
|
|
|
+ kind: 'standard'
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type SymmetryProps = {
|
|
|
+ kind: 'symmetry'
|
|
|
+ symmetryIndex?: number
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type FeatureProps = {
|
|
|
+ kind: 'feature'
|
|
|
+ target: Target
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type DensityProps = {
|
|
|
+ kind: 'density'
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type MembraneProps = {
|
|
|
+ kind: 'membrane',
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+type FeatureDensityProps = {
|
|
|
+ kind: 'feature-density',
|
|
|
+ target: Target,
|
|
|
+ radius?: number,
|
|
|
+ hiddenChannels?: string[]
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+export type MotifProps = {
|
|
|
+ kind: 'motif',
|
|
|
+ label?: string,
|
|
|
+ targets: Target[],
|
|
|
+ color?: number
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+export type NakbProps = {
|
|
|
+ kind: 'nakb'
|
|
|
+} & BaseProps
|
|
|
+
|
|
|
+export type PresetProps = ValidationProps | StandardProps | SymmetryProps | FeatureProps | DensityProps | AlignmentProps |
|
|
|
+MembraneProps | FeatureDensityProps | MotifProps | NakbProps | EmptyProps;
|
|
|
+
|
|
|
+const RcsbParams = () => ({
|
|
|
+ preset: PD.Value<PresetProps>({ kind: 'standard', assemblyId: '' }, { isHidden: true })
|
|
|
+});
|
|
|
+
|
|
|
+type StructureObject = StateObjectSelector<PluginStateObject.Molecule.Structure, StateTransformer<StateObject<any, StateObject.Type<any>>, StateObject<any, StateObject.Type<any>>, any>>
|
|
|
+
|
|
|
+export const TmDetRcsbPreset = TrajectoryHierarchyPresetProvider({
|
|
|
+ id: 'tmdet-preset-trajectory-rcsb',
|
|
|
+ display: { name: 'TMDET RCSB Preset' },
|
|
|
+ isApplicable: () => true,
|
|
|
+ params: RcsbParams,
|
|
|
+ async apply(trajectory: StateObjectRef<PluginStateObject.Molecule.Trajectory>, params, plugin) {
|
|
|
+ console.log('TMDET RCSB PRESET: apply start', params);
|
|
|
+
|
|
|
+ const modelParams = { modelIndex: 0 };
|
|
|
+
|
|
|
+ const props = {
|
|
|
+ type: {
|
|
|
+ name: 'assembly' as const,
|
|
|
+ params: { id: '1' }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ await plugin.state.data.build().to(trajectory)
|
|
|
+ .apply(StateTransforms.Model.ModelFromTrajectory, modelParams, { ref: 'model' })
|
|
|
+ .apply(StateTransforms.Model.StructureFromModel, props, { ref: 'assembly' })
|
|
|
+ .apply(StateTransforms.Model.TransformStructureConformation, {
|
|
|
+ transform: {
|
|
|
+ name: 'components',
|
|
|
+ params: { axis: Vec3.unitY, angle: 90, translation: Vec3.zero() }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .commit();
|
|
|
+
|
|
|
+ const builder = plugin.builders.structure;
|
|
|
+ const model = new StateObjectSelector(plugin.state.data.build().to('model').ref, plugin.state.data);
|
|
|
+ const modelProperties = await builder.insertModelProperties(model.ref);
|
|
|
+ const structure = new StateObjectSelector(plugin.state.data.build().to('assembly').ref, plugin.state.data);
|
|
|
+ const structureProperties = await builder.insertStructureProperties(structure);
|
|
|
+ const representation = await plugin.builders.structure.representation.applyPreset(
|
|
|
+ structureProperties, 'auto', { theme: { globalName: 'tmdet-custom-color-theme' } });
|
|
|
+
|
|
|
+ // await plugin.builders.structure.hierarchy.applyPreset(
|
|
|
+ // trajectory, 'default', { representationPreset: TMDET_STRUCTURE_PRESET_ID as any });
|
|
|
+
|
|
|
+ (window as any).plugin = plugin;
|
|
|
+
|
|
|
+ const result = {
|
|
|
+ model,
|
|
|
+ modelProperties,
|
|
|
+ unitcell: undefined,
|
|
|
+ structure,
|
|
|
+ structureProperties,
|
|
|
+ representation
|
|
|
+ };
|
|
|
+ console.log(result);
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+});
|