bioinsilico 3 年 前
コミット
724688b30c
5 ファイル変更19 行追加9954 行削除
  1. 1 9943
      package-lock.json
  2. 1 1
      package.json
  3. 3 1
      src/viewer/helpers/selection.ts
  4. 6 6
      src/viewer/helpers/viewer.ts
  5. 8 3
      src/viewer/index.ts

ファイルの差分が大きいため隠しています
+ 1 - 9943
package-lock.json


+ 1 - 1
package.json

@@ -37,7 +37,7 @@
     "author": "RCSB PDB and Mol* Contributors",
     "license": "MIT",
     "devDependencies": {
-        "@types/react": "^17.0.2",
+        "@types/react": "^17.0.11",
         "@types/react-dom": "^17.0.0",
         "@typescript-eslint/eslint-plugin": "^4.9.1",
         "@typescript-eslint/parser": "^4.9.1",

+ 3 - 1
src/viewer/helpers/selection.ts

@@ -35,7 +35,7 @@ export type Target = {
     readonly struct_oper_id?: string
 }
 
-type SelectBase = {
+export type SelectBase = {
     readonly modelId: string
     readonly label_asym_id: string
 }
@@ -212,6 +212,8 @@ function targetToExpression(target: Target): Expression {
         residueTests.push(MS.core.rel.eq([target.auth_seq_id, MS.ammp('auth_seq_id')]));
     } else if (target.label_seq_id) {
         residueTests.push(MS.core.rel.eq([target.label_seq_id, MS.ammp('label_seq_id')]));
+    }else if(target.label_seq_range){
+        residueTests.push(MS.core.rel.inRange([MS.ammp('label_seq_id'), target.label_seq_range.beg, target.label_seq_range.end]));
     }
     if (target.label_comp_id) {
         residueTests.push(MS.core.rel.eq([target.label_comp_id, MS.ammp('label_comp_id')]));

+ 6 - 6
src/viewer/helpers/viewer.ts

@@ -11,7 +11,7 @@ import { MolScriptBuilder as MS } from 'molstar/lib/mol-script/language/builder'
 import { StructureRepresentationRegistry } from 'molstar/lib/mol-repr/structure/registry';
 import { StructureSelectionQuery } from 'molstar/lib/mol-plugin-state/helpers/structure-selection-query';
 import {
-    rangeToTest,
+    rangeToTest, SelectBase,
     SelectRange,
     SelectTarget,
     Target,
@@ -54,9 +54,9 @@ export function select(plugin: PluginContext, targets: SelectTarget | SelectTarg
 
         if (mode === 'hover') {
             plugin.managers.interactivity.lociHighlights.highlight({ loci });
+        }else if(mode === 'select'){
+            plugin.managers.structure.selection.fromLoci(modifier, loci);
         }
-
-        plugin.managers.structure.selection.fromLoci(modifier, loci);
     }
 }
 
@@ -78,7 +78,7 @@ export function clearSelection(plugin: PluginContext, mode: 'select' | 'hover',
     plugin.managers.interactivity.lociSelects.deselect({ loci });
 }
 
-export async function createComponent(plugin: PluginContext, componentLabel: string, targets: SelectTarget | SelectTarget[], representationType: StructureRepresentationRegistry.BuiltIn) {
+export async function createComponent(plugin: PluginContext, componentLabel: string, targets: SelectBase | SelectTarget | SelectTarget[], representationType: StructureRepresentationRegistry.BuiltIn) {
     for (const target of (Array.isArray(targets) ? targets : [targets])) {
         // TODO are there performance implications when a large collection of residues is selected? - could move modelId out of 'target'
         const structureRef = getStructureRefWithModelId(plugin.managers.structure.hierarchy.current.structures, target);
@@ -95,12 +95,12 @@ export async function createComponent(plugin: PluginContext, componentLabel: str
     }
 }
 
-function toResidues(target: SelectTarget): number[] {
+function toResidues(target: SelectBase | SelectTarget): number[] {
     if ('label_seq_range' in target) {
         return toRange(target.label_seq_range.beg, target.label_seq_range.end);
     }
 
-    if (target.label_seq_id) {
+    if ('label_seq_id' in target) {
         return [target.label_seq_id];
     }
 

+ 8 - 3
src/viewer/index.ts

@@ -29,13 +29,14 @@ import { PluginLayoutControlsDisplay } from 'molstar/lib/mol-plugin/layout';
 import { SuperposeColorThemeProvider } from './helpers/superpose/color';
 import { encodeStructureData, downloadAsZipFile } from './helpers/export';
 import { setFocusFromRange, removeComponent, clearSelection, createComponent, select } from './helpers/viewer';
-import { SelectRange, SelectTarget, Target } from './helpers/selection';
+import {SelectBase, SelectRange, SelectTarget, Target} from './helpers/selection';
 import { StructureRepresentationRegistry } from 'molstar/lib/mol-repr/structure/registry';
 import { Mp4Export } from 'molstar/lib/extensions/mp4-export';
 import { DefaultPluginUISpec, PluginUISpec } from 'molstar/lib/mol-plugin-ui/spec';
 import { PluginUIContext } from 'molstar/lib/mol-plugin-ui/context';
 import { ANVILMembraneOrientation, MembraneOrientationPreset } from 'molstar/lib/extensions/anvil/behavior';
 import { MembraneOrientationRepresentationProvider } from 'molstar/lib/extensions/anvil/representation';
+import {PluginContext} from "molstar/lib/mol-plugin/context";
 
 /** package version, filled in at bundle build time */
 declare const __RCSB_MOLSTAR_VERSION__: string;
@@ -191,6 +192,10 @@ export class Viewer {
         return this._plugin;
     }
 
+    pluginCall(f: (plugin: PluginContext) => void){
+        f(this.plugin);
+    }
+
     private get customState() {
         return this._plugin.customState as ViewerState;
     }
@@ -269,11 +274,11 @@ export class Viewer {
         select(this._plugin, targets, mode, modifier);
     }
 
-    clearSelection(mode: 'select' | 'hover', target?: { modelId: string; target: Target }) {
+    clearSelection(mode: 'select' | 'hover', target?: { modelId: string; } & Target) {
         clearSelection(this._plugin, mode, target);
     }
 
-    async createComponent(label: string, targets: SelectTarget | SelectTarget[], representationType: StructureRepresentationRegistry.BuiltIn) {
+    async createComponent(label: string, targets: SelectBase | SelectTarget | SelectTarget[], representationType: StructureRepresentationRegistry.BuiltIn) {
         await createComponent(this._plugin, label, targets, representationType);
     }
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません