Prechádzať zdrojové kódy

membrane preset fallback for tiny structures

JonStargaryen 3 rokov pred
rodič
commit
d6782a3166
3 zmenil súbory, kde vykonal 28 pridanie a 4 odobranie
  1. 5 0
      CHANGELOG.md
  2. 14 4
      src/viewer/helpers/preset.ts
  3. 9 0
      src/viewer/index.html

+ 5 - 0
CHANGELOG.md

@@ -2,6 +2,11 @@
 
 [Semantic Versioning](https://semver.org/)
 
+## [1.8.6] - 2021-08-23
+### General
+- Display warning if membrane preset calculation fails
+- Add fallback if membrane preset calculation fails
+
 ## [1.8.5] - 2021-08-11
 ### General
 - Update strucmotif integration with rcsb.org

+ 14 - 4
src/viewer/helpers/preset.ts

@@ -238,10 +238,20 @@ export const RcsbPreset = TrajectoryHierarchyPresetProvider({
         } else if (p.kind === 'empty') {
             console.warn('Using empty representation');
         } else if (p.kind === 'membrane') {
-            representation = await plugin.builders.structure.representation.applyPreset(structureProperties!, MembraneOrientationPreset);
-
-            // reset the camera because the membranes render 1st and the structure might not be fully visible
-            requestAnimationFrame(() => plugin.canvas3d?.requestCameraReset());
+            try {
+                representation = await plugin.builders.structure.representation.applyPreset(structureProperties!, MembraneOrientationPreset);
+
+                // reset the camera because the membranes render 1st and the structure might not be fully visible
+                requestAnimationFrame(() => plugin.canvas3d?.requestCameraReset());
+            } catch (error) {
+                const msg = 'Membrane calculation failed! - This can happen for tiny structures with only a dozen of residues.';
+                plugin.log.error(msg);
+                console.error(msg);
+                console.error(error);
+
+                // fall back to default representation to show something
+                representation = await plugin.builders.structure.representation.applyPreset(structureProperties!, 'auto');
+            }
         } else {
             representation = await plugin.builders.structure.representation.applyPreset(structureProperties!, 'auto');
         }

+ 9 - 0
src/viewer/index.html

@@ -314,6 +314,15 @@
                         assemblyId: '1'
                     }
                 },
+                {
+                    id: '5XES',
+                    // this will fail membrane calculation due to tiny size but should still show default representation
+                    info: 'failing membrane: TK9 NMR structure in SDS micelle',
+                    props: {
+                        kind: 'membrane',
+                        assemblyId: '1'
+                    }
+                },
                 {
                     id: '6WJC',
                     info: 'ligand validation: Muscarinic acetylcholine receptor 1 - muscarinic toxin 7 complex: Focus + Density',