From bc6bc1d57ad5ba0825db0e5b4db7a65fd69ba78f Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Tue, 22 Oct 2019 10:22:02 -0700
Subject: [PATCH] fix StructureElement.Stats

---
 src/mol-model/structure/structure/element/stats.ts | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mol-model/structure/structure/element/stats.ts b/src/mol-model/structure/structure/element/stats.ts
index 1af62b97c..a26a52ceb 100644
--- a/src/mol-model/structure/structure/element/stats.ts
+++ b/src/mol-model/structure/structure/element/stats.ts
@@ -52,13 +52,15 @@ export namespace Stats {
                 const { index, offsets } = unit.model.atomicHierarchy.residueAtomSegments
                 let i = 0
                 while (i < size) {
+                    let j = 0
                     const eI = elements[OrderedSet.getAt(indices, i)]
                     const rI = index[eI]
                     while (i < size && index[elements[OrderedSet.getAt(indices, i)]] === rI) {
                         ++i
+                        ++j
                     }
 
-                    if (offsets[rI + 1] - offsets[rI] === i) {
+                    if (offsets[rI + 1] - offsets[rI] === j) {
                         // full residue
                         stats.residueCount += 1
                         if (stats.residueCount === 1) {
@@ -66,7 +68,7 @@ export namespace Stats {
                         }
                     } else {
                         // partial residue
-                        stats.elementCount += i
+                        stats.elementCount += j
                     }
                 }
             } else {
-- 
GitLab