Browse Source

adjusted maxCovalentHydrogenBondingLength

Alexander Rose 5 years ago
parent
commit
e3483f11b1

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


+ 12 - 13
src/mol-model/structure/structure/unit/links/inter-compute.ts

@@ -8,7 +8,7 @@
 import { LinkType } from '../../../model/types';
 import Structure from '../../structure';
 import Unit from '../../unit';
-import { getElementIdx, getElementPairThreshold, getElementThreshold, isHydrogen, LinkComputationParameters, MetalsSet } from './common';
+import { getElementIdx, getElementPairThreshold, getElementThreshold, isHydrogen, LinkComputationProps, MetalsSet, DefaultLinkComputationProps } from './common';
 import { InterUnitBonds } from './data';
 import { UniqueArray } from '../../../../../mol-data/generic';
 import { SortedArray } from '../../../../../mol-data/int';
@@ -39,7 +39,7 @@ function addLink(indexA: number, indexB: number, order: number, flag: LinkType.F
 
 const _imageTransform = Mat4.zero();
 
-function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, params: LinkComputationParameters, map: Map<number, InterUnitBonds.UnitPairBonds[]>) {
+function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, props: LinkComputationProps, map: Map<number, InterUnitBonds.UnitPairBonds[]>) {
     const state: PairState = { mapAB: new Map(), mapBA: new Map(), bondedA: UniqueArray.create(), bondedB: UniqueArray.create() };
     let bondCount = 0;
 
@@ -68,7 +68,7 @@ function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, params: LinkCompu
         if (isNotIdentity) Vec3.transformMat4(imageA, imageA, imageTransform);
         if (Vec3.squaredDistance(imageA, bCenter) > testDistanceSq) continue;
 
-        const structConnEntries = params.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
+        const structConnEntries = props.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
         if (structConnEntries && structConnEntries.length) {
             for (const se of structConnEntries) {
                 if (se.distance < MAX_RADIUS) continue;
@@ -126,7 +126,7 @@ function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, params: LinkCompu
             }
 
             if (isHa || isHb) {
-                if (dist < params.maxHbondLength) {
+                if (dist < props.maxCovalentHydrogenBondingLength) {
                     addLink(_aI, _bI, 1, LinkType.Flag.Covalent | LinkType.Flag.Computed, state); // TODO: check if correct
                     bondCount++;
                 }
@@ -153,15 +153,15 @@ function findPairLinks(unitA: Unit.Atomic, unitB: Unit.Atomic, params: LinkCompu
     return bondCount;
 }
 
-export interface InterLinkComputationParameters extends LinkComputationParameters {
+export interface InterLinkComputationProps extends LinkComputationProps {
     validUnitPair: (unitA: Unit, unitB: Unit) => boolean
 }
 
-function findLinks(structure: Structure, params: InterLinkComputationParameters) {
+function findLinks(structure: Structure, props: InterLinkComputationProps) {
     const map = new Map<number, InterUnitBonds.UnitPairBonds[]>();
     if (!structure.units.some(u => Unit.isAtomic(u))) return new InterUnitBonds(map);
 
-    const { validUnitPair } = params;
+    const { validUnitPair } = props;
     const lookup = structure.lookup3d;
     const imageCenter = Vec3.zero();
 
@@ -175,8 +175,8 @@ function findLinks(structure: Structure, params: InterLinkComputationParameters)
             const other = structure.units[closeUnits.indices[i]];
             if (!Unit.isAtomic(other) || unit.id >= other.id || !validUnitPair(unit, other)) continue;
 
-            if (other.elements.length >= unit.elements.length) findPairLinks(unit, other, params, map);
-            else findPairLinks(other, unit, params, map);
+            if (other.elements.length >= unit.elements.length) findPairLinks(unit, other, props, map);
+            else findPairLinks(other, unit, props, map);
         }
     }
 
@@ -192,11 +192,10 @@ function ValidUnitPair(structure: Structure) {
     }
 }
 
-function computeInterUnitBonds(structure: Structure, params?: Partial<InterLinkComputationParameters>): InterUnitBonds {
+function computeInterUnitBonds(structure: Structure, props?: Partial<InterLinkComputationProps>): InterUnitBonds {
     return findLinks(structure, {
-        maxHbondLength: (params && params.maxHbondLength) || 1.15,
-        forceCompute: !!(params && params.forceCompute),
-        validUnitPair: (params && params.validUnitPair) || ValidUnitPair(structure),
+        ...DefaultLinkComputationProps,
+        validUnitPair: (props && props.validUnitPair) || ValidUnitPair(structure),
     });
 }
 

+ 7 - 10
src/mol-model/structure/structure/unit/links/intra-compute.ts

@@ -8,7 +8,7 @@ import { LinkType } from '../../../model/types'
 import { IntraUnitLinks } from './data'
 import Unit from '../../unit'
 import { IntAdjacencyGraph } from '../../../../../mol-math/graph';
-import { LinkComputationParameters, getElementIdx, MetalsSet, getElementThreshold, isHydrogen, getElementPairThreshold } from './common';
+import { LinkComputationProps, getElementIdx, MetalsSet, getElementThreshold, isHydrogen, getElementPairThreshold, DefaultLinkComputationProps } from './common';
 import { SortedArray } from '../../../../../mol-data/int';
 import { StructConn, ComponentBond } from '../../../../../mol-model-formats/structure/mmcif/bonds';
 
@@ -25,7 +25,7 @@ function getGraph(atomA: number[], atomB: number[], _order: number[], _flags: nu
     return builder.createGraph({ flags, order });
 }
 
-function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): IntraUnitLinks {
+function _computeBonds(unit: Unit.Atomic, props: LinkComputationProps): IntraUnitLinks {
     const MAX_RADIUS = 4;
 
     const { x, y, z } = unit.model.atomicConformation;
@@ -50,7 +50,7 @@ function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): In
         const aI =  atoms[_aI];
         const raI = residueIndex[aI];
 
-        if (!params.forceCompute && raI !== lastResidue) {
+        if (!props.forceCompute && raI !== lastResidue) {
             const resn = label_comp_id.value(raI)!;
             if (!!component && component.entries.has(resn)) {
                 componentMap = component.entries.get(resn)!.map;
@@ -69,7 +69,7 @@ function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): In
         const thresholdA = getElementThreshold(aeI);
         const altA = label_alt_id.value(aI);
         const metalA = MetalsSet.has(aeI);
-        const structConnEntries = params.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
+        const structConnEntries = props.forceCompute ? void 0 : structConn && structConn.getAtomEntries(aI);
 
         if (structConnEntries) {
             for (const se of structConnEntries) {
@@ -141,7 +141,7 @@ function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): In
             }
 
             if (isHa || isHb) {
-                if (dist < params.maxHbondLength) {
+                if (dist < props.maxCovalentHydrogenBondingLength) {
                     atomA[atomA.length] = _aI;
                     atomB[atomB.length] = _bI;
                     order[order.length] = 1;
@@ -167,11 +167,8 @@ function _computeBonds(unit: Unit.Atomic, params: LinkComputationParameters): In
     return getGraph(atomA, atomB, order, flags, atomCount);
 }
 
-function computeIntraUnitBonds(unit: Unit.Atomic, params?: Partial<LinkComputationParameters>) {
-    return _computeBonds(unit, {
-        maxHbondLength: (params && params.maxHbondLength) || 1.15,
-        forceCompute: !!(params && params.forceCompute),
-    });
+function computeIntraUnitBonds(unit: Unit.Atomic, props?: Partial<LinkComputationProps>) {
+    return _computeBonds(unit, { ...DefaultLinkComputationProps, ...props });
 }
 
 export { computeIntraUnitBonds }

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