Quellcode durchsuchen

Issue #805: working on matrix transformations

cycle20 vor 1 Jahr
Ursprung
Commit
e771b843a2

+ 32 - 0
src/RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager.ts

@@ -27,6 +27,8 @@ import {StateTransformer} from "molstar/lib/mol-state/transformer";
 import {
     StructureRepresentationPresetProvider
 } from "molstar/lib/mol-plugin-state/builder/structure/representation-preset";
+// import { TmDetDescriptorCache } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/prop";
+import { DebugUtil } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/debug-utils";
 
 export enum LoadMethod {
     loadPdbId = "loadPdbId",
@@ -92,6 +94,36 @@ export class MolstarActionManager<P,L> implements ViewerActionManagerInterface<L
                 } else if (lC.loadMethod == LoadMethod.loadStructureFromUrl) {
                     const config: LoadParams<P,L> = lC.loadParams as LoadParams<P,L>;
                     out.push(await this.viewer.loadStructureFromUrl(config.url!, config.format!, config.isBinary!,{props: config.props, matrix: config.matrix, reprProvider: config.reprProvider, params: config.params}) as L|undefined);
+
+                    DebugUtil.log('LOAD STRUCT. URL RESULT:', out[0]);
+                    // const pdbtmDescriptor = TmDetDescriptorCache.get('1afo'); // TODO
+                    // let matrix = undefined;
+                    // if (pdbtmDescriptor) {
+                    //     matrix = DebugUtil.descriptorMxToMat4(pdbtmDescriptor!.additional_entry_annotations.membrane.transformation_matrix as any);
+                    // }
+
+                    // this.viewer.plugin.managers.structure.hierarchy.applyPreset()
+                    // const selector = await this.viewer.plugin.builders.structure.hierarchy.applyPreset(
+                    //     trajectory, 'default', { representationPreset: TMDET_STRUCTURE_PRESET_ID as any });
+        
+                    // if (matrix && selector?.structureProperties) {
+                    //     const params = {
+                    //         transform: {
+                    //             name: 'matrix' as const,
+                    //             params: { data: matrix, transpose: false }
+                    //         }
+                    //     };
+                    //     setTimeout(async () => {
+                    //             console.log(this.viewer.plugin);
+                    //             // const b = this.plugin.state.data.build().to(selector.structureProperties)
+                    //             //     .insert(StateTransforms.Model.TransformStructureConformation, params);
+                    //             // await this.plugin.runTask(this.plugin.state.data.updateTree(b));
+                    //         },
+                    //         2000
+                    //     );
+                    // }
+        
+
                 } else if (lC.loadMethod == LoadMethod.loadSnapshotFromUrl) {
                     const config: LoadParams<P,L> = lC.loadParams as LoadParams<P,L>;
                    await this.viewer.loadSnapshotFromUrl(config.url!, config.type!);

+ 1 - 2
src/examples/assembly-tm/UniTmpHelper.ts

@@ -2,9 +2,8 @@ import { RcsbFvDisplayTypes } from "@rcsb/rcsb-saguaro";
 
 import { getColorByLocation, getLabelByLocation } from "./UniTmpColor";
 import { PDBTMDescriptor } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/types";
-import { TmDetDescriptorCache } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/prop";
+import { setMembraneOrientation, TmDetDescriptorCache } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/prop";
 import { createMembraneOrientation } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/transformation";
-import { setMembraneOrientation } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/behavior";
 import { DebugUtil } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/debug-utils";
 
 export async function fetchHtpDescriptor(entryId: string) {

+ 0 - 8
src/examples/assembly-tm/index.ts

@@ -1,7 +1,6 @@
 import {RcsbFv3DCustom, RcsbFv3DCustomInterface} from "../../RcsbFv3D/RcsbFv3DCustom";
 import { DebugUtil } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/debug-utils";
 import { createFeatureViewerConfing } from "./FeatureViewConfig";
-import { TmDetDescriptorCache } from "@rcsb/rcsb-molstar/build/src/tmdet-extension/prop";
 import { registerRegionDescriptorData } from "./UniTmpHelper";
 
 document.addEventListener("DOMContentLoaded", (event) => {
@@ -29,13 +28,6 @@ document.addEventListener("DOMContentLoaded", (event) => {
             structurePanelConfig: molstarConfig
         };
         DebugUtil.log('Panel config', panel3dConfig);
-        const pdbtmDescriptor = TmDetDescriptorCache.get(pdbEntry);
-        if (pdbtmDescriptor) {
-            const mx = DebugUtil.descriptorMxToMat4(pdbtmDescriptor!.additional_entry_annotations.membrane.transformation_matrix as any);
-            DebugUtil.log('Membrane transformation matrix:', mx);
-            (panel3dConfig.structurePanelConfig!.loadConfig as any).loadParams.matrix = mx;
-        }
-
 
         const panel3d = new RcsbFv3DCustom(panel3dConfig);
         panel3d.render();

+ 30 - 1
src/examples/assembly-tm/preset.ts

@@ -18,6 +18,9 @@ import { Mat4 } 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 '@rcsb/rcsb-molstar/build/src/tmdet-extension/behavior';
+import { TmDetDescriptorCache } from '@rcsb/rcsb-molstar/build/src/tmdet-extension/prop';
+import { DebugUtil } from '@rcsb/rcsb-molstar/build/src/tmdet-extension/debug-utils';
+import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms';
 
 type BaseProps = {
     assemblyId?: string
@@ -162,12 +165,38 @@ export const TmDetRcsbPreset = TrajectoryHierarchyPresetProvider({
         } else if (p.kind === 'nakb') {
             console.warn('nakb case not implemented in TmDetRcsbPreset');
         } else {
+
             console.log('HERE WE GO:', { structure: structure, structureProps: structureProperties, presetParams: presetParams });
             //representation = await plugin.builders.structure.representation.applyPreset(structureProperties!, 'auto', presetParams);
             representation = await plugin.builders.structure.representation.applyPreset(
                 structureProperties!, 'auto', { theme: { globalName: 'tmdet-custom-color-theme' } });
-            await plugin.builders.structure.hierarchy.applyPreset(
+            const selector = await plugin.builders.structure.hierarchy.applyPreset(
                 trajectory, 'default', { representationPreset: TMDET_STRUCTURE_PRESET_ID as any });
+
+            // Transformation:
+            // const pdbtmDescriptor = TmDetDescriptorCache.get('1afo'); // TODO
+            // let matrix = undefined;
+            // if (pdbtmDescriptor) {
+            //     matrix = DebugUtil.descriptorMxToMat4(pdbtmDescriptor!.additional_entry_annotations.membrane.transformation_matrix as any);
+            // }
+
+            // if (matrix && selector?.structureProperties) {
+            //     const params = {
+            //         transform: {
+            //             name: 'matrix' as const,
+            //             params: { data: matrix, transpose: false }
+            //         }
+            //     };
+            //     setTimeout(async () => {
+            //             console.log(this.plugin);
+            //             // const b = this.plugin.state.data.build().to(selector.structureProperties)
+            //             //     .insert(StateTransforms.Model.TransformStructureConformation, params);
+            //             // await this.plugin.runTask(this.plugin.state.data.updateTree(b));
+            //         },
+            //         2000
+            //     );
+            // }
+
         }
 
         console.log('STRUCTURE REPRESENTATION:', representation);