From f2c04a13af82229ffadc42c9be9bcbc934fc5bc0 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Fri, 30 Aug 2019 17:28:33 -0700
Subject: [PATCH] adjust grid-cell-count in partitionAtomicUnitByResidue

---
 src/mol-model/structure/structure/structure.ts | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mol-model/structure/structure/structure.ts b/src/mol-model/structure/structure/structure.ts
index 0cf0f2fe7..1cb7b5ba3 100644
--- a/src/mol-model/structure/structure/structure.ts
+++ b/src/mol-model/structure/structure/structure.ts
@@ -579,20 +579,23 @@ namespace Structure {
 
     // keeps atoms of residues together
     function partitionAtomicUnitByResidue(model: Model, indices: SortedArray, builder: StructureBuilder) {
-        model.atomicHierarchy.residueAtomSegments.offsets
+        const { residueAtomSegments } = model.atomicHierarchy
 
         const startIndices: number[] = []
         const endIndices: number[] = []
 
-        const residueIt = Segmentation.transientSegments(model.atomicHierarchy.residueAtomSegments, indices)
+        const residueIt = Segmentation.transientSegments(residueAtomSegments, indices)
         while (residueIt.hasNext) {
             const residueSegment = residueIt.move();
             startIndices[startIndices.length] = indices[residueSegment.start]
             endIndices[endIndices.length] = indices[residueSegment.end]
         }
 
+        const firstResidueAtomCount = endIndices[0] - startIndices[0]
+        const gridCellCount = 512 * firstResidueAtomCount
+
         const { x, y, z } = model.atomicConformation;
-        const lookup = GridLookup3D({ x, y, z, indices: SortedArray.ofSortedArray(startIndices) }, 8192);
+        const lookup = GridLookup3D({ x, y, z, indices: SortedArray.ofSortedArray(startIndices) }, gridCellCount);
         const { offset, count, array } = lookup.buckets;
 
         for (let i = 0, _i = offset.length; i < _i; i++) {
-- 
GitLab