Browse Source

check model and coordinates element count

Alexander Rose 3 years ago
parent
commit
ed6511799b
2 changed files with 6 additions and 0 deletions
  1. 1 0
      CHANGELOG.md
  2. 5 0
      src/mol-model/structure/model/model.ts

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ Note that since we don't clearly distinguish between a public and private interf
 
 ## [Unreleased]
 
+- Check that model and coordinates have same element count when creating a trajectory
 
 ## [v3.5.0] - 2022-03-25
 

+ 5 - 0
src/mol-model/structure/model/model.ts

@@ -99,9 +99,14 @@ export namespace Model {
         const isIdentity = Column.isIdentity(srcIndex);
         const srcIndexArray = isIdentity ? void 0 : srcIndex.toArray({ array: Int32Array });
         const coarseGrained = isCoarseGrained(model);
+        const elementCount = model.atomicHierarchy.atoms._rowCount;
 
         for (let i = 0, il = frames.length; i < il; ++i) {
             const f = frames[i];
+            if (f.elementCount !== elementCount) {
+                throw new Error(`Frame element count mismatch, got ${f.elementCount} but expected ${elementCount}.`);
+            }
+
             const m = {
                 ...model,
                 id: UUID.create22(),