Browse Source

improved computing of covalent bonds with hydrogen

- added more X-H pair thresholds
- removed maxCovalentHydrogenBondingLength param
Alexander Rose 5 years ago
parent
commit
c833598c26

File diff suppressed because it is too large
+ 2 - 26
src/mol-model/structure/structure/unit/bonds/common.ts


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

@@ -125,25 +125,15 @@ function findPairBonds(unitA: Unit.Atomic, unitB: Unit.Atomic, props: BondComput
             }
 
             const beI = getElementIdx(type_symbolB.value(bI)!);
-            const isMetal = metalA || MetalsSet.has(beI);
 
             const isHb = isHydrogen(beI);
             if (isHa && isHb) continue;
 
+            const isMetal = (metalA || MetalsSet.has(beI)) && !(isHa || isHb);
+
             const dist = Math.sqrt(squaredDistances[ni]);
             if (dist === 0) continue;
 
-            if (isHa || isHb) {
-                if (dist < props.maxCovalentHydrogenBondingLength) {
-                    // covalent bonds involving a hydrogen are always of order 1
-                    builder.add(_aI, _bI, {
-                        order: 1,
-                        flag: BondType.Flag.Covalent | BondType.Flag.Computed
-                    });
-                }
-                continue;
-            }
-
             const thresholdAB = getElementPairThreshold(aeI, beI);
             const pairingThreshold = thresholdAB > 0
                 ? thresholdAB

+ 5 - 14
src/mol-model/structure/structure/unit/bonds/intra-compute.ts

@@ -127,7 +127,11 @@ function _computeBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUni
             if (altA && altB && altA !== altB) continue;
 
             const beI = getElementIdx(type_symbol.value(bI)!);
-            const isMetal = metalA || MetalsSet.has(beI);
+
+            const isHb = isHydrogen(beI);
+            if (isHa && isHb) continue;
+
+            const isMetal = (metalA || MetalsSet.has(beI)) && !(isHa || isHb);
 
             const rbI = residueIndex[bI];
             // handle "component dictionary" bonds.
@@ -147,22 +151,9 @@ function _computeBonds(unit: Unit.Atomic, props: BondComputationProps): IntraUni
                 continue;
             }
 
-            const isHb = isHydrogen(beI);
-            if (isHa && isHb) continue;
-
             const dist = Math.sqrt(squaredDistances[ni]);
             if (dist === 0) continue;
 
-            if (isHa || isHb) {
-                if (dist < props.maxCovalentHydrogenBondingLength) {
-                    atomA[atomA.length] = _aI;
-                    atomB[atomB.length] = _bI;
-                    order[order.length] = 1; // covalent bonds involving hydrogen are always of order 1
-                    flags[flags.length] = BondType.Flag.Covalent | BondType.Flag.Computed;
-                }
-                continue;
-            }
-
             const thresholdAB = getElementPairThreshold(aeI, beI);
             const pairingThreshold = thresholdAB > 0
                 ? thresholdAB

Some files were not shown because too many files changed in this diff