فهرست منبع

dcd nd coordinates fixes/tweaks

- cell optional
- elementCount only on frame
Alexander Rose 4 سال پیش
والد
کامیت
97612bf044
2فایلهای تغییر یافته به همراه14 افزوده شده و 14 حذف شده
  1. 7 7
      src/mol-io/reader/dcd/parser.ts
  2. 7 7
      src/mol-model/structure/coordinates/coordinates.ts

+ 7 - 7
src/mol-io/reader/dcd/parser.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -22,13 +22,15 @@ export interface DcdHeader {
 }
 
 export interface DcdFrame {
-    readonly cell: Cell
     readonly elementCount: number
 
     // positions
     readonly x: ArrayLike<number>
     readonly y: ArrayLike<number>
     readonly z: ArrayLike<number>
+
+    // optional cell
+    readonly cell?: Cell
 }
 
 export interface DcdFile {
@@ -147,17 +149,16 @@ export function _parseDcd(data: Uint8Array): DcdFile {
     }
 
     // frames
-
     const natom = header.NATOM;
     const natom4 = natom * 4;
 
     for (let i = 0, n = header.NSET; i < n; ++i) {
-        const frame: Mutable<DcdFrame> = Object.create({
-            elementCount: natom
-        });
+        const frame: Mutable<DcdFrame> = Object.create(null);
+        frame.elementCount = natom;
 
         if (extraBlock) {
             nextPos += 4; // block start
+            // TODO this is not standardized and we need to add heuristics to handle more variants
             // cell: A, alpha, B, beta, gamma, C (doubles)
             const size = Vec3.create(
                 dv.getFloat64(nextPos, ef),
@@ -199,7 +200,6 @@ export function _parseDcd(data: Uint8Array): DcdFile {
 
         frames.push(frame);
     }
-
     return { header, frames };
 }
 

+ 7 - 7
src/mol-model/structure/coordinates/coordinates.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -11,7 +11,6 @@ import { Column } from '../../../mol-data/db';
 
 export interface Frame {
     readonly elementCount: number
-    readonly cell: Cell
     readonly time: Time
 
     // positions
@@ -19,6 +18,9 @@ export interface Frame {
     readonly y: ArrayLike<number>
     readonly z: ArrayLike<number>
 
+    // optional cell
+    readonly cell?: Cell
+
     // optional velocities
     readonly velocities?: {
         readonly vx: ArrayLike<number>
@@ -62,9 +64,7 @@ interface Coordinates {
 
     readonly frames: Frame[]
 
-    /** Number of elements (e.g. atoms) in frames */
-    readonly elementCount: number
-
+    readonly hasCell: boolean
     readonly hasVelocities: boolean
     readonly hasForces: boolean
 
@@ -74,14 +74,14 @@ interface Coordinates {
 
 namespace Coordinates {
     export function create(frames: Frame[], deltaTime: Time, timeOffset: Time): Coordinates {
-        const elementCount = frames[0].elementCount;
+        const hasCell = !!frames[0].cell;
         const hasVelocities = !!frames[0].velocities;
         const hasForces = !!frames[0].forces;
 
         return {
             id: UUID.create22(),
             frames,
-            elementCount,
+            hasCell,
             hasVelocities,
             hasForces,
             deltaTime,