Ver código fonte

Revert "Issue #2: selector-way to identify new chains"

This reverts commit c8ab0239dba5009cdd9b0852db322efaea897135.
cycle20 2 anos atrás
pai
commit
063ac8a935
1 arquivos alterados com 38 adições e 62 exclusões
  1. 38 62
      src/extensions/tmdet/transformation.ts

+ 38 - 62
src/extensions/tmdet/transformation.ts

@@ -4,7 +4,7 @@ import { Mat4, Vec3 } from '../../mol-math/linear-algebra';
 import { PDBTMDescriptor, PDBTMTransformationMatrix, PMS } from './types';
 import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
 import { StateTransforms } from '../../mol-plugin-state/transforms';
-import { StateObjectRef, StateBuilder, StateObjectSelector, StateTransformer } from '../../mol-state';
+import { StateObjectRef, StateBuilder } from '../../mol-state';
 import { Expression } from '../../mol-script/language/expression';
 import { MembraneOrientation } from './prop';
 import { TmDetColorThemeProvider } from './tmdet-color-theme';
@@ -15,16 +15,14 @@ export async function applyTransformations(plugin: PluginUIContext, pdbtmDescrip
 
     const membraneTransformation = transformationForStateTransform(pdbtmDescriptor.additional_entry_annotations.membrane.transformation_matrix);
 
-    const selectors: StateObjectSelector<any, any>[] = [];
     if (annotations.biomatrix) {
         annotations.biomatrix.matrix_list.forEach(function(mx) {
             mx.apply_to_chain_list.forEach(async function(chainPair) {
                 let id  = chainPair.chain_id;
                 let newId = chainPair.new_chain_id;
                 const mtx = transformationForStateTransform(mx.transformation_matrix);
-                const composedTransformation = mtx; // Mat4.mul(Mat4(), membraneTransformation, mtx);
-                const selector = chainTransformation(plugin, composedTransformation, id, newId);
-                selectors.push(selector);
+                const composedTransformation = Mat4.mul(Mat4(), membraneTransformation, mtx);
+                chainTransformation(plugin, composedTransformation, id, newId);
                 // await plugin.runTask(Task.create(`TMDET: Transform '${id}' into '${newId}'`, async () => {
                 //     chainTransformation(plugin, mx.transformation_matrix, id, newId);
                 // }));
@@ -37,50 +35,14 @@ export async function applyTransformations(plugin: PluginUIContext, pdbtmDescrip
     //          plugin.runTask with "await" also cannot synchronize here.
     //
     // So this function call transforms only already existing components due to a side effect of another issue.
-    transformWholeModel(plugin, pdbtmDescriptor.additional_entry_annotations.membrane.transformation_matrix, selectors);
+    transformWholeModel(plugin, pdbtmDescriptor.additional_entry_annotations.membrane.transformation_matrix);
     // await plugin.runTask(Task.create(`TMDET: Apply membrane transformation`, async () => {
     //     transformWholeModel(plugin, pdbtmDescriptor.additional_entry_annotations.membrane.transformation_matrix);
     // }));
 
 }
 
-/**
- * Perform transformation on a chain.
- *
- * @param plugin UI context
- * @param transformationMatrix 4x4 matrix describes transformation and translation
- * @param chainId Id of chain to be selected for transformation
- * @param newId chain Id of transformation result
- */
- export function chainTransformation(plugin: PluginUIContext, transformationMatrix: Mat4, chainId: string, newId: string): StateObjectSelector<any, any> {
-    const query: Expression = getChainExpression(chainId);
-
-//    const transformation = transformationForStateTransform(transformationMatrix);
-    const transformation = transformationMatrix;
-    const structure: StateObjectRef<PMS> = plugin.managers.structure.hierarchy.current.models[0].structures[0].cell;
-    const update: StateBuilder.To<any, any> = plugin.build().to(structure);
-
-    update
-        .apply(
-            StateTransforms.Model.StructureSelectionFromExpression,
-            { label: newId, expression: query }
-        )
-        .apply(StateTransforms.Model.TransformStructureConformation, {
-            "transform": { name: "matrix", params: { data: transformation, transpose: false } }
-        })
-        .apply(
-            StateTransforms.Representation.StructureRepresentation3D,
-            createStructureRepresentationParams(plugin, structure.obj?.data, {
-                type: 'cartoon',
-                color: TmDetColorThemeProvider.name as any //, colorParams: { pdbtmDescriptor }
-            })
-        );
-    update.commit();
-    DebugUtil.log(`${chainId}->${newId} DONE; selector:`, update.selector);
-    return update.selector;
-}
-
-export function transformWholeModel(plugin: PluginUIContext, membraneMatrix: PDBTMTransformationMatrix, selectors: StateObjectSelector<any, any>[]) {
+export function transformWholeModel(plugin: PluginUIContext, membraneMatrix: PDBTMTransformationMatrix) {
     //
     // membrane transformation
     //
@@ -101,35 +63,49 @@ export function transformWholeModel(plugin: PluginUIContext, membraneMatrix: PDB
             .apply(StateTransforms.Model.TransformStructureConformation, {
                 "transform": { name: "matrix", params: { data: membraneTransformation, transpose: false } }
             })
-            /* .apply(
+            .apply(
                 StateTransforms.Representation.StructureRepresentation3D,
                 createStructureRepresentationParams(plugin, structure.obj?.data, {
                     type: 'cartoon',
                     color: TmDetColorThemeProvider.name as any //, colorParams: { pdbtmDescriptor }
                 })
-            ) */;
+            );
         update.commit();
     });
+}
 
+/**
+ * Perform transformation on a chain.
+ *
+ * @param plugin UI context
+ * @param transformationMatrix 4x4 matrix describes transformation and translation
+ * @param chainId Id of chain to be selected for transformation
+ */
+export function chainTransformation(plugin: PluginUIContext, transformationMatrix: Mat4, chainId: string, newId: string): void {
+    const query: Expression = getChainExpression(chainId);
 
-    type TSC = typeof StateTransforms.Model.TransformStructureConformation;
-    type SP = StateTransformer.Params<TSC>;
-
-    selectors.forEach(selector => {
-        const update = plugin.build().to(selector);
-        // apply<T extends StateTransformer<A, any, any>>(tr: T, params?: Partial<StateTransformer.Params<T>>, options?: Partial<StateTransform.Options>): To<StateTransformer.To<T>, T> {
-        // update<T extends StateTransformer<any, A, any>>(transformer: T, params: (old: StateTransformer.Params<T>) => Partial<StateTransformer.Params<T>> | void): Root
-        // update(params: Partial<StateTransformer.Params<T>> | ((old: StateTransformer.Params<T>) => Partial<StateTransformer.Params<T>> | void)): Root
-        // update<T extends StateTransformer<any, A, any>>(paramsOrTransformer: T | any, provider?: (old: StateTransformer.Params<T>) => StateTransformer.Params<T>) {
+//    const transformation = transformationForStateTransform(transformationMatrix);
+    const transformation = transformationMatrix;
+    const structure: StateObjectRef<PMS> = plugin.managers.structure.hierarchy.current.models[0].structures[0].cell;
+    const update: StateBuilder.To<any, any> = plugin.build().to(structure);
 
-        DebugUtil.log('selector:', selector);
-        update.update(StateTransforms.Model.TransformStructureConformation, (old: SP): SP => {
-            return {
-                "transform": { name: "matrix", params: { data: membraneTransformation, transpose: false } }
-            };
-        });
-        update.commit();
-    });
+    update
+        .apply(
+            StateTransforms.Model.StructureSelectionFromExpression,
+            { label: newId, expression: query }
+        )
+        .apply(StateTransforms.Model.TransformStructureConformation, {
+            "transform": { name: "matrix", params: { data: transformation, transpose: false } }
+        })
+        .apply(
+            StateTransforms.Representation.StructureRepresentation3D,
+            createStructureRepresentationParams(plugin, structure.obj?.data, {
+                type: 'cartoon',
+                color: TmDetColorThemeProvider.name as any //, colorParams: { pdbtmDescriptor }
+            })
+        );
+    update.commit();
+    DebugUtil.log(`${chainId}->${newId} DONE`);
 }
 
 // function vadd(a: Vec3, b: Vec3): Vec3 {