Browse Source

Issue #805: minor refact. + clean up

cycle20 1 year ago
parent
commit
f822f82717
3 changed files with 11 additions and 22 deletions
  1. 6 12
      src/tmdet-extension/behavior.ts
  2. 4 4
      src/tmdet-extension/prop.ts
  3. 1 6
      src/viewer/index.ts

+ 6 - 12
src/tmdet-extension/behavior.ts

@@ -30,7 +30,7 @@ import { PluginUIContext } from 'molstar/lib/mol-plugin-ui/context';
 
 // TMDET imports
 import { MembraneOrientationRepresentationProvider, MembraneOrientationParams, MembraneOrientationRepresentation } from './representation';
-import { MembraneOrientationProvider, MembraneOrientation, TmDetDescriptorCache } from './prop';
+import { MembraneOrientationProvider, MembraneOrientation, TmDetDescriptorCache, MembraneOrientationNameSpace } from './prop';
 import { applyTransformations, createMembraneOrientation } from './transformation';
 import { ComponentsType, PDBTMDescriptor, PMS } from './types';
 import { registerTmDetSymmetry } from './symmetry';
@@ -39,7 +39,7 @@ import { TmDetColorThemeProvider, updateSiteColors } from './tmdet-color-theme';
 //import { loadInitialSnapshot, rotateCamera, storeCameraSnapshot } from './camera';
 import { DebugUtil } from './debug-utils';
 
-const Tag = MembraneOrientation.Tag;
+const Tag = MembraneOrientationNameSpace.Tag;
 const TMDET_MEMBRANE_ORIENTATION = 'TMDET Membrane Orientation';
 export const TMDET_STRUCTURE_PRESET_ID = 'tmdet-preset-membrane-orientation';
 
@@ -110,7 +110,7 @@ export const isTransmembrane = StructureSelectionQuery('Residues Embedded in Mem
         MS.struct.modifier.union([
             MS.struct.generator.atomGroups({
                 'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']),
-                'atom-test': MembraneOrientation.symbols.isTransmembrane.symbol(),
+                'atom-test': MembraneOrientationNameSpace.symbols.isTransmembrane.symbol(),
             })
         ])
     ])
@@ -133,6 +133,9 @@ export const isTransmembrane = StructureSelectionQuery('Residues Embedded in Mem
 
 
 export let membraneOrientation: MembraneOrientation;
+export function setMembraneOrientation(orientation: MembraneOrientation) {
+    membraneOrientation = orientation;
+}
 
 export async function loadWithUNITMPMembraneRepresentation(plugin: PluginUIContext, params: any) {
     //storeCameraSnapshot(plugin); // store if it is not stored yet
@@ -161,15 +164,6 @@ export async function loadWithUNITMPMembraneRepresentation(plugin: PluginUIConte
     })(); }, 500);
 }
 
-export async function registerRegionDescriptor(plugin: PluginUIContext, url: string, side1: "Inside"|"Outside"|null) {
-    const params = { regionDescriptorUrl: url };
-    const pdbtmDescriptor: PDBTMDescriptor = await downloadRegionDescriptor(plugin, params);
-    pdbtmDescriptor.side1 = side1;
-    TmDetDescriptorCache.add(pdbtmDescriptor);
-    membraneOrientation = createMembraneOrientation(pdbtmDescriptor);
-    DebugUtil.log('TMDET Membrane Orientation Params:', membraneOrientation);
-}
-
 async function downloadRegionDescriptor(plugin: PluginUIContext, params: any): Promise<any> {
     // run a fetch task
     const downloadResult: string = await plugin.runTask(plugin.fetch({ url: params.regionDescriptorUrl })) as string;

+ 4 - 4
src/tmdet-extension/prop.ts

@@ -33,7 +33,7 @@ export const MembraneOrientationParams = {
 export type MembraneOrientationParams = typeof MembraneOrientationParams
 export type MembraneOrientationProps = PD.Values<MembraneOrientationParams>
 
-export { MembraneOrientation };
+export { MembraneOrientationNameSpace };
 
 /**
  * Simple storage to made PDBTM descriptor available globally.
@@ -83,7 +83,7 @@ class ChainListCache {
 }
 export const TmDetChainListCache = new ChainListCache();
 
-interface MembraneOrientation {
+export interface MembraneOrientation {
     // point in membrane boundary
     readonly planePoint1: Vec3,
     // point in opposite side of membrane boundary
@@ -95,7 +95,7 @@ interface MembraneOrientation {
     readonly centroid: Vec3
 }
 
-namespace MembraneOrientation {
+namespace MembraneOrientationNameSpace {
     export enum Tag {
         Representation = 'tmdet-membrane-orientation-3d'
     }
@@ -120,7 +120,7 @@ export const MembraneOrientationProvider: CustomStructureProperty.Provider<Membr
     label: 'TMDET Membrane Orientation Provider',
     descriptor: CustomPropertyDescriptor({
         name: 'tmdet_computed_membrane_orientation',
-        symbols: MembraneOrientation.symbols,
+        symbols: MembraneOrientationNameSpace.symbols,
         // TODO `cifExport`
     }),
     type: 'root',

+ 1 - 6
src/viewer/index.ts

@@ -53,7 +53,7 @@ import { AssemblySymmetry } from 'molstar/lib/extensions/rcsb/assembly-symmetry/
 import { wwPDBChemicalComponentDictionary } from 'molstar/lib/extensions/wwpdb/ccd/behavior';
 import { ChemicalCompontentTrajectoryHierarchyPreset } from 'molstar/lib/extensions/wwpdb/ccd/representation';
 import { StateTransforms } from 'molstar/lib/mol-plugin-state/transforms';
-import { TMDETMembraneOrientation, registerRegionDescriptor } from '../tmdet-extension/behavior';
+import { TMDETMembraneOrientation } from '../tmdet-extension/behavior';
 
 /** package version, filled in at bundle build time */
 declare const __RCSB_MOLSTAR_VERSION__: string;
@@ -343,11 +343,6 @@ export class Viewer {
     }
 
     loadStructureFromUrl<P, S>(url: string, format: BuiltInTrajectoryFormat, isBinary: boolean, config?: {props?: PresetProps & { dataLabel?: string }; matrix?: Mat4; reprProvider?: TrajectoryHierarchyPresetProvider<P, S>, params?: P}) {
-        console.log('RCSB loadStructureFromUrl II', this.customState);
-        const pdbId = '1afo';
-        const descriptorUrl = `/${pdbId}.json`;
-        registerRegionDescriptor(this._plugin, descriptorUrl, "Inside");
-
         return this.customState.modelLoader.load({ fileOrUrl: url, format, isBinary }, config?.props, config?.matrix, config?.reprProvider, config?.params);
     }