Browse Source

fix entity-id coloring broken for non-ihm models

Alexander Rose 3 years ago
parent
commit
1feb3c2095

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 - Fix marking pass not working with ``transparentBackground``
 - Fix pdbe xray maps url not https
+- Fix entity-id color theme broken for non-IHM models
 
 ## [v3.0.0] - 2022-01-23
 

+ 24 - 2
src/mol-model/structure/model/properties/coarse/hierarchy.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
@@ -63,6 +63,28 @@ export interface CoarseHierarchy {
     gaussians: CoarseElements
 }
 
+const EmptyCoarseElements: CoarseElements = {
+    chainKey: [],
+    entityKey: [],
+    findSequenceKey: () => -1 as ElementIndex,
+    findChainKey: () => -1 as ChainIndex,
+    getEntityFromChain: () => -1 as EntityIndex,
+
+    count: 0,
+    entity_id: Column.Undefined(0, Column.Schema.str),
+    asym_id: Column.Undefined(0, Column.Schema.str),
+    seq_id_begin: Column.Undefined(0, Column.Schema.int),
+    seq_id_end: Column.Undefined(0, Column.Schema.int),
+    chainElementSegments: Segmentation.create([]),
+
+    polymerRanges: SortedRanges.ofSortedRanges([]),
+    gapRanges: SortedRanges.ofSortedRanges([]),
+};
+
 export namespace CoarseHierarchy {
-    export const Empty: CoarseHierarchy = { isDefined: false } as any;
+    export const Empty: CoarseHierarchy = {
+        isDefined: false,
+        spheres: EmptyCoarseElements,
+        gaussians: EmptyCoarseElements
+    };
 }

+ 12 - 9
src/mol-theme/color/entity-id.ts

@@ -38,15 +38,18 @@ function getEntityIdSerialMap(structure: Structure) {
             const k = key(label_entity_id.value(j), i);
             if (!map.has(k)) map.set(k, map.size);
         }
-        const { entity_id: spheres_entity_id } = structure.models[i].coarseHierarchy.spheres;
-        for (let j = 0, jl = spheres_entity_id.rowCount; j < jl; ++j) {
-            const k = key(spheres_entity_id.value(j), i);
-            if (!map.has(k)) map.set(k, map.size);
-        }
-        const { entity_id: gaussians_entity_id } = structure.models[i].coarseHierarchy.gaussians;
-        for (let j = 0, jl = gaussians_entity_id.rowCount; j < jl; ++j) {
-            const k = key(gaussians_entity_id.value(j), i);
-            if (!map.has(k)) map.set(k, map.size);
+        const { coarseHierarchy } = structure.models[i];
+        if (coarseHierarchy.isDefined) {
+            const { entity_id: spheres_entity_id } = coarseHierarchy.spheres;
+            for (let j = 0, jl = spheres_entity_id.rowCount; j < jl; ++j) {
+                const k = key(spheres_entity_id.value(j), i);
+                if (!map.has(k)) map.set(k, map.size);
+            }
+            const { entity_id: gaussians_entity_id } = coarseHierarchy.gaussians;
+            for (let j = 0, jl = gaussians_entity_id.rowCount; j < jl; ++j) {
+                const k = key(gaussians_entity_id.value(j), i);
+                if (!map.has(k)) map.set(k, map.size);
+            }
         }
     }
     return map;