Browse Source

clearSelection for single chains

bioinsilico 4 years ago
parent
commit
606a0df480
2 changed files with 16 additions and 5 deletions
  1. 1 1
      package.json
  2. 15 4
      src/viewer/index.ts

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@rcsb/rcsb-molstar",
-    "version": "1.0.31",
+    "version": "1.0.32",
     "description": "RCSB PDB apps and props based on Mol*.",
     "homepage": "https://github.com/rcsb/rcsb-molstar#readme",
     "repository": {

+ 15 - 4
src/viewer/index.ts

@@ -262,11 +262,22 @@ export class Viewer {
         else if(mode === 'hover')
             this.plugin.managers.interactivity.lociHighlights.highlight({ loci });
     }
-    public clearSelection(mode: 'select'|'hover'): void {
-        if(mode == null || mode === 'select')
-            this.plugin.managers.interactivity.lociSelects.deselectAll();
-        else if(mode === 'hover')
+    public clearSelection(mode: 'select'|'hover', options?: {modelId: string; labelAsymId: string;}): void {
+        if(mode == null || mode === 'select') {
+            if(options == null){
+                this.plugin.managers.interactivity.lociSelects.deselectAll();
+            }else{
+                const data: Structure | undefined = getStructureWithModelId(this.plugin.managers.structure.hierarchy.current.structures, options.modelId);
+                if (data == null) return;
+                const sel: StructureSelection = Script.getStructureSelection(Q => Q.struct.generator.atomGroups({
+                    'chain-test': Q.core.rel.eq([options.labelAsymId, MolScriptBuilder.ammp('label_asym_id')])
+                }), data);
+                const loci: Loci = StructureSelection.toLociWithSourceUnits(sel);
+                this.plugin.managers.interactivity.lociSelects.deselect({loci});
+            }
+        }else if(mode === 'hover') {
             this.plugin.managers.interactivity.lociHighlights.clearHighlights();
+        }
     }
 
     public async createComponentFromSet(componentId: string, modelId: string, residues: Array<{asymId: string, position: number}>, representationType: 'ball-and-stick'|'spacefill'|'gaussian-surface'|'cartoon'){