From 4455bab6ac1ae7b21c01f194c597ef8b4edef24b Mon Sep 17 00:00:00 2001 From: dsehnal <david.sehnal@gmail.com> Date: Tue, 13 Dec 2022 16:06:19 +0100 Subject: [PATCH] Fix struct_conn bond assignment for ions --- CHANGELOG.md | 1 + .../structure/unit/bonds/inter-compute.ts | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae05abb51..0e022d7ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Note that since we don't clearly distinguish between a public and private interf - Add per-pixel object clipping - Fix `QualityAssessment` assignment bug for structures with different auth vs label sequence numbering - Refresh `ApplyActionControl`'s param definition when toggling expanded state +- Fix `struct_conn` bond assignment for ions ## [v3.26.0] - 2022-12-04 diff --git a/src/mol-model/structure/structure/unit/bonds/inter-compute.ts b/src/mol-model/structure/structure/unit/bonds/inter-compute.ts index ab11f3f7b..1b803d401 100644 --- a/src/mol-model/structure/structure/unit/bonds/inter-compute.ts +++ b/src/mol-model/structure/structure/unit/bonds/inter-compute.ts @@ -20,6 +20,7 @@ import { InterUnitGraph } from '../../../../../mol-math/graph/inter-unit-graph'; import { StructConn } from '../../../../../mol-model-formats/structure/property/bonds/struct_conn'; import { equalEps } from '../../../../../mol-math/linear-algebra/3d/common'; import { Model } from '../../../model'; +import { StructureProperties } from '../../properties'; // avoiding namespace lookup improved performance in Chrome (Aug 2020) const v3distance = Vec3.distance; @@ -249,13 +250,27 @@ function computeInterUnitBonds(structure: Structure, props?: Partial<InterBondCo (!Unit.isAtomic(a) || mtA[a.residueIndex[a.elements[0]]] !== MoleculeType.Water) && (!Unit.isAtomic(b) || mtB[b.residueIndex[b.elements[0]]] !== MoleculeType.Water) ); - const notIon = ( - (!Unit.isAtomic(a) || mtA[a.residueIndex[a.elements[0]]] !== MoleculeType.Ion) && - (!Unit.isAtomic(b) || mtB[b.residueIndex[b.elements[0]]] !== MoleculeType.Ion) - ); + + const sameModel = a.model === b.model; + const notIonA = (!Unit.isAtomic(a) || mtA[a.residueIndex[a.elements[0]]] !== MoleculeType.Ion) || (sameModel && hasStructConnRecord(a)); + const notIonB = (!Unit.isAtomic(b) || mtB[b.residueIndex[b.elements[0]]] !== MoleculeType.Ion) || (sameModel && hasStructConnRecord(b)); + const notIon = notIonA && notIonB; return Structure.validUnitPair(s, a, b) && (notWater || !p.ignoreWater) && (notIon || !p.ignoreIon); }), }); } +function hasStructConnRecord(unit: Unit) { + const elements = unit.elements; + const structConn = StructConn.Provider.get(unit.model); + if (structConn) { + for (let i = 0, _i = elements.length; i < _i; i++) { + if (structConn.byAtomIndex.get(elements[i])) { + return true; + } + } + } + return false; +} + export { computeInterUnitBonds }; -- GitLab