Browse Source

add option to ignore ions for inter-unit bonds

Alexander Rose 3 years ago
parent
commit
67feef0b1d

+ 1 - 0
CHANGELOG.md

@@ -7,6 +7,7 @@ Note that since we don't clearly distinguish between a public and private interf
 ## [Unreleased]
 
 - Fix issue with unit boundary reuse (do at visual level instead)
+- Add option to ignore ions for inter-unit bond computation
 
 ## [v3.3.0] - 2022-02-27
 

+ 4 - 1
src/mol-model/structure/structure/structure.ts

@@ -238,7 +238,10 @@ class Structure {
             // no need to compute InterUnitBonds if parent's ones are empty
             this.state.interUnitBonds = new InterUnitBonds(new Map());
         } else {
-            this.state.interUnitBonds = computeInterUnitBonds(this, { ignoreWater: !this.dynamicBonds });
+            this.state.interUnitBonds = computeInterUnitBonds(this, {
+                ignoreWater: !this.dynamicBonds,
+                ignoreIon: !this.dynamicBonds,
+            });
         }
         return this.state.interUnitBonds;
     }

+ 8 - 2
src/mol-model/structure/structure/unit/bonds/inter-compute.ts

@@ -193,11 +193,13 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput
 export interface InterBondComputationProps extends BondComputationProps {
     validUnitPair: (structure: Structure, unitA: Unit, unitB: Unit) => boolean
     ignoreWater: boolean
+    ignoreIon: boolean
 }
 
 const DefaultInterBondComputationProps = {
     ...DefaultBondComputationProps,
-    ignoreWater: true
+    ignoreWater: true,
+    ignoreIon: true,
 };
 
 function findBonds(structure: Structure, props: InterBondComputationProps) {
@@ -233,7 +235,11 @@ 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)
             );
-            return Structure.validUnitPair(s, a, b) && (notWater || !p.ignoreWater);
+            const notIon = (
+                (!Unit.isAtomic(a) || mtA[a.residueIndex[a.elements[0]]] !== MoleculeType.Ion) &&
+                (!Unit.isAtomic(b) || mtB[b.residueIndex[b.elements[0]]] !== MoleculeType.Ion)
+            );
+            return Structure.validUnitPair(s, a, b) && (notWater || !p.ignoreWater) && (notIon || !p.ignoreIon);
         }),
     });
 }

+ 1 - 1
src/mol-plugin-state/helpers/root-structure.ts

@@ -17,7 +17,7 @@ import { PluginStateObject as SO } from '../objects';
 import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmetry';
 
 const CommonStructureParams = {
-    dynamicBonds: PD.Optional(PD.Boolean(false, { description: 'Ensure bonds are recalculated upon model changes. Also enables calculation of inter-unit bonds in water molecules.' })),
+    dynamicBonds: PD.Optional(PD.Boolean(false, { description: 'Ensure bonds are recalculated upon model changes. Also enables calculation of inter-unit bonds in water molecules and ions.' })),
 };
 type CommonStructureProps = PD.ValuesFor<typeof CommonStructureParams>