Browse Source

HELP-16678: show model if ligand not in assembly

JonStargaryen 4 years ago
parent
commit
857b7452a7
2 changed files with 14 additions and 1 deletions
  1. 4 0
      CHANGELOG.md
  2. 10 1
      src/viewer/helpers/preset.ts

+ 4 - 0
CHANGELOG.md

@@ -2,6 +2,10 @@
 
 [Semantic Versioning](https://semver.org/)
 
+## [1.2.2] - 2021-02-26
+### Bug fixes
+- switch to 'model' when ligand preset is requested but ligand is not present in assembly '1' - HELP-16678
+
 ## [1.2.1] - 2021-02-18
 ### Bug fixes
 - limit number of exchanges per position

+ 10 - 1
src/viewer/helpers/preset.ts

@@ -291,9 +291,18 @@ export const RcsbPreset = TrajectoryHierarchyPresetProvider({
         }
 
         if (p.kind === 'feature' && structure?.obj) {
-            const loci = targetToLoci(p.target, structure.obj.data);
+            let loci = targetToLoci(p.target, structure.obj.data);
             // if target is only defined by chain: then don't force first residue
             const chainMode = p.target.label_asym_id && !p.target.auth_seq_id && !p.target.label_seq_id && !p.target.label_comp_id;
+            // HELP-16678: check for rare case where ligand is not present in requested assembly
+            if (loci.elements.length === 0 && !!p.assemblyId) {
+                // switch to Model (a.k.a. show coordinate independent of assembly )
+                const { selection } = plugin.managers.structure.hierarchy;
+                const s = selection.structures[0];
+                await plugin.managers.structure.hierarchy.updateStructure(s, { ...params, preset: { ...params.preset, assemblyId: void 0 } });
+                // update loci
+                loci = targetToLoci(p.target, structure.obj.data);
+            }
             const target = chainMode ? loci : StructureElement.Loci.firstResidue(loci);
             plugin.managers.structure.focus.setFromLoci(target);
             plugin.managers.camera.focusLoci(target);