浏览代码

Issue #805: createFeatureViewerConfing function added

cycle20 1 年之前
父节点
当前提交
5a0156a085
共有 3 个文件被更改,包括 76 次插入73 次删除
  1. 5 5
      build.sh
  2. 66 65
      src/examples/assembly-tm/FeatureViewConfig.ts
  3. 5 3
      src/examples/assembly-tm/index.ts

+ 5 - 5
build.sh

@@ -1,14 +1,14 @@
-cd ../molstar3
-npm run build
-npm pack
+#cd ../molstar3
+#npm run build
+#npm pack
 
 cd ../rcsb-molstar
-npm i /lhome/csongor/molstar3/molstar-3.40.1.tgz
+#npm i /lhome/csongor/molstar3/molstar-3.40.1.tgz
 npm run build
 npm pack
 
 cd ../rcsb-saguaro-3d
 npm i /lhome/csongor/rcsb-molstar/rcsb-rcsb-molstar-2.8.0.tgz
-npm i /lhome/csongor/molstar3/molstar-3.40.1.tgz
+#npm i /lhome/csongor/molstar3/molstar-3.40.1.tgz
 npm run devServer
 

+ 66 - 65
src/examples/assembly-tm/FeatureViewConfig.ts

@@ -13,7 +13,6 @@ import {
     LoadMolstarInterface, LoadMolstarReturnType
 } from "../../RcsbFvStructure/StructureViewers/MolstarViewer/MolstarActionManager";
 import {RcsbFvStateManager} from "../../RcsbFvState/RcsbFvStateManager";
-import { pdbEntry } from ".";
 
 export const rowConfig: Array<RcsbFvRowConfigInterface> = [
     {
@@ -32,74 +31,76 @@ export const rowConfig: Array<RcsbFvRowConfigInterface> = [
     }
 ];
 
-// TODO: must be set by a more clever way
-const modelId = `1afo_model`;
-console.log('PDBENTRY:', pdbEntry);
 
-export const fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
-    boardId: `${pdbEntry}_board`,
-    boardConfig: {
-        rowTitleWidth: 190,
-        includeAxis: true
-    },
-    rowConfig: rowConfig,
-    sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
-        stateManager.selectionState.clearSelection("select", {modelId: modelId, labelAsymId:"A"});
-        if(sequenceRegion.length > 0) {
-            const regions = sequenceRegion.map(r => ({
-                modelId: modelId,
-                labelAsymId: "A",
-                region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface
-            }));
-            stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select");
-            plugin.select(regions.map(r => ({
-                ...r,
-                begin: r.region.begin,
-                end: r.region.end
-            })), "select", "set");
-        }else{
-            plugin.clearSelection("select", {modelId: modelId, labelAsymId: "A"})
-            plugin.resetCamera();
-        }
-    },
-    sequenceElementClickCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, d: RcsbFvTrackDataElementInterface) => {
-        if(d!=null)
-            plugin.cameraFocus(modelId, "A", d.begin, d.end ?? d.begin);
-    },
-    sequenceHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, elements: Array<RcsbFvTrackDataElementInterface>) => {
-        console.log('HOEVER...', elements);
-        if(elements == null || elements.length == 0)
-            plugin.clearSelection("hover");
-        else {
-            const e = elements[0];
-            console.log({
+export function createFeatureViewerConfing(pdbEntry: string, labelAsymId: string) {
+    const modelId = `${pdbEntry}_model`;
+
+    const fvConfig: FeatureViewInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
+        boardId: `${pdbEntry}_board`,
+        boardConfig: {
+            rowTitleWidth: 190,
+            includeAxis: true
+        },
+        rowConfig: rowConfig,
+        sequenceSelectionChangeCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, sequenceRegion: Array<RcsbFvTrackDataElementInterface>) => {
+            stateManager.selectionState.clearSelection("select", {modelId: modelId, labelAsymId: labelAsymId});
+            if(sequenceRegion.length > 0) {
+                const regions = sequenceRegion.map(r => ({
+                    modelId: modelId,
+                    labelAsymId: labelAsymId,
+                    region: {begin: r.begin, end: r.end ?? r.begin, source: "sequence"} as RegionSelectionInterface
+                }));
+                stateManager.selectionState.addSelectionFromMultipleRegions(regions, "select");
+                plugin.select(regions.map(r => ({
+                    ...r,
+                    begin: r.region.begin,
+                    end: r.region.end
+                })), "select", "set");
+            }else{
+                plugin.clearSelection("select", {modelId: modelId, labelAsymId: labelAsymId})
+                plugin.resetCamera();
+            }
+        },
+        sequenceElementClickCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, d: RcsbFvTrackDataElementInterface) => {
+            if(d!=null)
+                plugin.cameraFocus(modelId, "A", d.begin, d.end ?? d.begin);
+        },
+        sequenceHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, stateManager: RcsbFvStateManager, elements: Array<RcsbFvTrackDataElementInterface>) => {
+            console.log('HOEVER...', elements);
+            if(elements == null || elements.length == 0)
+                plugin.clearSelection("hover");
+            else {
+                const e = elements[0];
+                console.log({
+                        modelId: modelId,
+                        labelAsymId: labelAsymId,
+                        begin: e.begin,
+                        end: e.end ?? e.begin
+                });
+                plugin.select(elements.map(e=>({
                     modelId: modelId,
-                    labelAsymId: "A",
+                    labelAsymId: labelAsymId,
                     begin: e.begin,
                     end: e.end ?? e.begin
-            });
-            plugin.select(elements.map(e=>({
-                modelId: modelId,
-                labelAsymId: "A",
-                begin: e.begin,
-                end: e.end ?? e.begin
-            })), "hover", "set");
-        }
-    },
-    structureSelectionCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
-        const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "select");
-        if(sel == null) {
-            pfv.clearSelection("select");
-            plugin.resetCamera();
-        }else {
-            pfv.setSelection({elements: sel.regions, mode: "select"});
+                })), "hover", "set");
+            }
+        },
+        structureSelectionCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
+            const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "select");
+            if(sel == null) {
+                pfv.clearSelection("select");
+                plugin.resetCamera();
+            }else {
+                pfv.setSelection({elements: sel.regions, mode: "select"});
+            }
+        },
+        structureHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
+            const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "hover");
+            if(sel == null)
+                pfv.clearSelection("hover");
+            else
+                pfv.setSelection({elements:sel.regions, mode:"hover"});
         }
-    },
-    structureHoverCallback: (plugin: StructureViewerPublicInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType>, pfv: RcsbFv, stateManager: RcsbFvStateManager) => {
-        const sel: SaguaroRegionList | undefined = stateManager.selectionState.getSelectionWithCondition(modelId, "A", "hover");
-        if(sel == null)
-            pfv.clearSelection("hover");
-        else
-            pfv.setSelection({elements:sel.regions, mode:"hover"});
     }
+    return fvConfig;
 }

+ 5 - 3
src/examples/assembly-tm/index.ts

@@ -17,17 +17,19 @@ import {
     jsvLibDescriptorToTrackData
 } from "./UniTmpHelper";
 import { updateSiteColors } from "./UniTmpColor";
-import { fvConfig, rowConfig } from "./FeatureViewConfig";
+import { createFeatureViewerConfing, rowConfig } from "./FeatureViewConfig";
 import { RcsbPreset } from "@rcsb/rcsb-molstar/build/src/viewer/helpers/preset";
 
 const side1 = "Inside";
 const htpEntry = "GLPA_HUMAN";
-export const pdbEntry = "1afo";
-const pdbtmEntry = `${pdbEntry}_A`;
+const pdbEntry = "1afo";
+const labelAsymId = "B"
+const pdbtmEntry = `${pdbEntry}_${labelAsymId}`;
 
 
 
 
+const fvConfig = createFeatureViewerConfing(pdbEntry, labelAsymId);
 const block: FeatureBlockInterface<LoadMolstarInterface<unknown,unknown>,LoadMolstarReturnType> = {
     blockId:"MyBlock_1",
     featureViewConfig: [fvConfig]