Quellcode durchsuchen

improve/fix InteractionsIntraUnitVisual marking

Alexander Rose vor 3 Jahren
Ursprung
Commit
ec4f15f549

+ 1 - 0
CHANGELOG.md

@@ -17,6 +17,7 @@ Note that since we don't clearly distinguish between a public and private interf
 - Fix marking of carbohydrate visuals (whole chain could get marked instead of single residue)
 - Add custom colors to "element-symbol", "molecule-type", "residue-name", and "secondary-structure" themes
 - Support/bugfixes for ``atom_site.pdbx_sifts_xref`` categories
+- Improve/fix marking of ``InteractionsIntraUnitVisual`` (mark when all contact-feature members are given)
 
 ## [v3.0.0-dev.10] - 2022-01-17
 

+ 22 - 5
src/mol-model-props/computed/representations/interactions-intra-unit-cylinder.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -123,6 +123,8 @@ function getInteractionLoci(pickingId: PickingId, structureGroup: StructureGroup
     return EmptyLoci;
 }
 
+const __contactIndicesSet = new Set<number>();
+
 function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean, isMarking: boolean) {
     let changed = false;
     if (Interactions.isLoci(loci)) {
@@ -156,21 +158,36 @@ function eachInteraction(loci: Loci, structureGroup: StructureGroup, apply: (int
 
         const { offset } = contacts;
         const { offsets: fOffsets, indices: fIndices } = features.elementsIndex;
+        const { members, offsets } = features;
 
-        // TODO: when isMarking, all elements of contact features need to be in the loci
         for (const e of loci.elements) {
             const unitIdx = group.unitIndexMap.get(e.unit.id);
-            if (unitIdx !== undefined) continue;
-            if (isMarking && OrderedSet.size(e.indices) === 1) continue;
+            if (unitIdx === undefined) continue;
 
+            __contactIndicesSet.clear();
             OrderedSet.forEach(e.indices, v => {
                 for (let i = fOffsets[v], il = fOffsets[v + 1]; i < il; ++i) {
                     const fI = fIndices[i];
                     for (let j = offset[fI], jl = offset[fI + 1]; j < jl; ++j) {
-                        if (apply(Interval.ofSingleton(unitIdx * groupCount + j))) changed = true;
+                        __contactIndicesSet.add(j);
                     }
                 }
             });
+
+            __contactIndicesSet.forEach(i => {
+                if (isMarking) {
+                    const fA = contacts.a[i];
+                    for (let j = offsets[fA], jl = offsets[fA + 1]; j < jl; ++j) {
+                        if (!OrderedSet.has(e.indices, members[j])) return;
+                    }
+                    const fB = contacts.b[i];
+                    for (let j = offsets[fB], jl = offsets[fB + 1]; j < jl; ++j) {
+                        if (!OrderedSet.has(e.indices, members[j])) return;
+                    }
+                }
+
+                if (apply(Interval.ofSingleton(unitIdx * groupCount + i))) changed = true;
+            });
         }
     }
     return changed;