Quellcode durchsuchen

Issue #805: rotation is in progress - part 2

cycle20 vor 1 Jahr
Ursprung
Commit
bab6f1dbd5

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

@@ -2,6 +2,10 @@ import {RcsbFv3DCustom, RcsbFv3DCustomInterface} from "../../RcsbFv3D/RcsbFv3DCu
 import { DebugUtil } from "./tmdet-extension/debug-utils";
 import { createFeatureViewerConfing } from "./FeatureViewConfig";
 import { registerRegionDescriptorData } from "./UniTmpHelper";
+import { TmDetDescriptorCache } from "./tmdet-extension/prop";
+import { applyTransformations } from "./tmdet-extension/transformation";
+
+export { DebugUtil };
 
 document.addEventListener("DOMContentLoaded", (event) => {
     (async function(event) {
@@ -27,9 +31,20 @@ document.addEventListener("DOMContentLoaded", (event) => {
             sequencePanelConfig: sequenceConfig,
             structurePanelConfig: molstarConfig
         };
+        molstarConfig.structureViewerConfig.viewerProps.layoutShowSequence = true;
+        (molstarConfig as any).loadConfig.loadParams.params = {
+            preset: { modelIndex: 0 }
+        }
         DebugUtil.log('Panel config', panel3dConfig);
 
         const panel3d = new RcsbFv3DCustom(panel3dConfig);
         panel3d.render();
+
+        setTimeout(() => {
+                const descriptor = TmDetDescriptorCache.get('1afo');
+                applyTransformations((window as any).plugin as any, descriptor!);
+            },
+            2000
+        );
     })();
 });

+ 8 - 19
src/examples/assembly-tm/preset2.ts

@@ -9,17 +9,14 @@ import { TrajectoryHierarchyPresetProvider } from 'molstar/lib/mol-plugin-state/
 import { PluginStateObject } from 'molstar/lib/mol-plugin-state/objects';
 import {
     StateObjectSelector,
-    StateObject,
-    StateTransformer,
     StateObjectRef,
 } from 'molstar/lib/mol-state';
 import { Mat4, Vec3 } from 'molstar/lib/mol-math/linear-algebra';
 import { Target } from '@rcsb/rcsb-molstar/build/src/viewer/helpers/selection';
 import { MembraneOrientationPreset } 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';
+import { TmDetDescriptorCache } from './tmdet-extension/prop';
 
 type BaseProps = {
     assemblyId?: string
@@ -97,8 +94,6 @@ 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' },
@@ -119,12 +114,12 @@ export const TmDetRcsbPreset = TrajectoryHierarchyPresetProvider({
         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() }
-                    }
-                })
+            // .apply(StateTransforms.Model.TransformStructureConformation, {
+            //         transform: {
+            //             name: 'components',
+            //             params: { axis: Vec3.unitY, angle: 90, translation: Vec3.zero() }
+            //         }
+            //     })
             .commit();
 
         const builder = plugin.builders.structure;
@@ -132,14 +127,8 @@ export const TmDetRcsbPreset = TrajectoryHierarchyPresetProvider({
         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' } });
-
         const representation = await plugin.builders.structure.representation.applyPreset<any>(structureProperties, MembraneOrientationPreset, {});
 
-        // await plugin.builders.structure.hierarchy.applyPreset(
-        //     trajectory, 'default', { representationPreset: TMDET_STRUCTURE_PRESET_ID as any });
-
         (window as any).plugin = plugin;
 
         const result = {
@@ -150,7 +139,7 @@ export const TmDetRcsbPreset = TrajectoryHierarchyPresetProvider({
             structureProperties,
             representation
         };
-        console.log(result);
+        console.log('TmDetRcsbPreset apply result', result);
 
         return result;
     }

+ 2 - 1
src/examples/assembly-tm/tmdet-extension/prop.ts

@@ -127,8 +127,9 @@ export const MembraneOrientationProvider: CustomStructureProperty.Provider<Membr
     isApplicable: (data: Structure) => true,
     obtain: async (ctx: CustomProperty.Context, data: Structure, props: Partial<MembraneOrientationProps>) => {
         //DebugUtil.log('obtain:: DEBUG', data.customPropertyDescriptors);
+        console.log('MembraneOrientationProvider.obtain:: DEBUG descriptor:', TmDetDescriptorCache.get(data.model.entryId));
+        console.log('MembraneOrientationProvider.obtain:: DEBUG data:', data);
         let result = membraneOrientation;
-        //DebugUtil.log("RESULT of 'obtain:'", result);
         return { value: result };
     }
 });

+ 9 - 2
src/examples/assembly-tm/tmdet-extension/transformation.ts

@@ -8,7 +8,7 @@
  */
 
 import { MolScriptBuilder as MS } from 'molstar/lib/mol-script/language/builder';
-import { Mat4, Vec3 } from 'molstar/lib/mol-math/linear-algebra';
+import { Mat4, Quat, Vec3 } from 'molstar/lib/mol-math/linear-algebra';
 import { PDBTMDescriptor, PDBTMTransformationMatrix, PMS } from './types';
 import { createStructureRepresentationParams } from 'molstar/lib/mol-plugin-state/helpers/structure-representation-params';
 import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms';
@@ -122,10 +122,17 @@ function vneg(u: Vec3): Vec3 {
     return Vec3.negate(Vec3.zero(), u);
 }
 
+function rot90q(v: Vec3, axis: Vec3 = Vec3.create(1, 0, 0)): Vec3 {
+    const q = Quat.setAxisAngle(Quat(), axis, -Math.PI/2);
+    return Vec3.transformQuat(Vec3(), v, q);
+}
+
+
 export function createMembraneOrientation(pdbtmDescriptor: PDBTMDescriptor): MembraneOrientation {
     const membrane = pdbtmDescriptor.additional_entry_annotations.membrane;
 
-    const membraneNormal: Vec3 = Vec3.fromObj(membrane.normal);
+    let membraneNormal: Vec3 = Vec3.fromObj(membrane.normal);
+    membraneNormal = rot90q(membraneNormal);
     const result: MembraneOrientation = {
         planePoint1: membraneNormal,
         planePoint2: vneg(membraneNormal),