Browse Source

Fixed inter-unit bond computation for transformed units

David Sehnal 6 years ago
parent
commit
cad44a07f0

+ 6 - 6
src/mol-model/structure/model/formats/mmcif/bonds/struct_conn.ts

@@ -14,11 +14,11 @@ import { ModelPropertyDescriptor } from '../../../properties/custom';
 import { mmCIF_Database, mmCIF_Schema } from 'mol-io/reader/cif/schema/mmcif';
 import { SortedArray } from 'mol-data/int';
 import { CifWriter } from 'mol-io/writer/cif'
-import { ElementIndex } from '../../../indexing';
+import { ElementIndex, ResidueIndex } from '../../../indexing';
 
 export interface StructConn {
-    getResidueEntries(residueAIndex: number, residueBIndex: number): ReadonlyArray<StructConn.Entry>,
-    getAtomEntries(atomIndex: number): ReadonlyArray<StructConn.Entry>,
+    getResidueEntries(residueAIndex: ResidueIndex, residueBIndex: ResidueIndex): ReadonlyArray<StructConn.Entry>,
+    getAtomEntries(atomIndex: ElementIndex): ReadonlyArray<StructConn.Entry>,
     readonly entries: ReadonlyArray<StructConn.Entry>
 }
 
@@ -117,11 +117,11 @@ export namespace StructConn {
         }
 
 
-        getResidueEntries(residueAIndex: number, residueBIndex: number): ReadonlyArray<StructConn.Entry> {
+        getResidueEntries(residueAIndex: ResidueIndex, residueBIndex: ResidueIndex): ReadonlyArray<StructConn.Entry> {
             return this.getResiduePairIndex().get(_resKey(residueAIndex, residueBIndex)) || _emptyEntry;
         }
 
-        getAtomEntries(atomIndex: number): ReadonlyArray<StructConn.Entry> {
+        getAtomEntries(atomIndex: ElementIndex): ReadonlyArray<StructConn.Entry> {
             return this.getAtomIndex().get(atomIndex) || _emptyEntry;
         }
 
@@ -134,7 +134,7 @@ export namespace StructConn {
         distance: number,
         order: number,
         flags: number,
-        partners: { residueIndex: number, atomIndex: ElementIndex, symmetry: string }[]
+        partners: { residueIndex: ResidueIndex, atomIndex: ElementIndex, symmetry: string }[]
     }
 
     type StructConnType = typeof mmCIF_Schema.struct_conn.conn_type_id.T

+ 3 - 1
src/mol-model/structure/structure/unit/links/inter-compute.ts

@@ -153,11 +153,13 @@ function findLinks(structure: Structure, params: LinkComputationParameters) {
     if (!structure.units.some(u => Unit.isAtomic(u))) return new InterUnitBonds(map);
 
     const lookup = structure.lookup3d;
+    const imageCenter = Vec3.zero();
     for (const unit of structure.units) {
         if (!Unit.isAtomic(unit)) continue;
 
         const bs = unit.lookup3d.boundary.sphere;
-        const closeUnits = lookup.findUnitIndices(bs.center[0], bs.center[1], bs.center[2], bs.radius + MAX_RADIUS);
+        Vec3.transformMat4(imageCenter, bs.center, unit.conformation.operator.matrix);
+        const closeUnits = lookup.findUnitIndices(imageCenter[0], imageCenter[1], imageCenter[2], bs.radius + MAX_RADIUS);
         for (let i = 0; i < closeUnits.count; i++) {
             const other = structure.units[closeUnits.indices[i]];
             if (!Unit.isAtomic(other) || unit.id >= other.id) continue;