molstar
Version:
A comprehensive macromolecular library.
44 lines (43 loc) • 2.1 kB
JavaScript
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { __awaiter, __generator } from "tslib";
import { Task } from '../../mol-task';
import { Coordinates, Time } from '../../mol-model/structure/coordinates';
import { Cell } from '../../mol-math/geometry/spacegroup/cell';
import { Vec3 } from '../../mol-math/linear-algebra';
export function coordinatesFromXtc(file) {
var _this = this;
return Task.create('Parse XTC', function (ctx) { return __awaiter(_this, void 0, void 0, function () {
var deltaTime, offsetTime, frames, i, il, box, x, y, z;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, ctx.update('Converting to coordinates')];
case 1:
_a.sent();
deltaTime = Time(file.deltaTime, 'step');
offsetTime = Time(file.timeOffset, deltaTime.unit);
frames = [];
for (i = 0, il = file.frames.length; i < il; ++i) {
box = file.boxes[i];
x = Vec3.fromArray(Vec3(), box, 0);
y = Vec3.fromArray(Vec3(), box, 3);
z = Vec3.fromArray(Vec3(), box, 6);
frames.push({
elementCount: file.frames[i].count,
cell: Cell.fromBasis(x, y, z),
x: file.frames[i].x,
y: file.frames[i].y,
z: file.frames[i].z,
xyzOrdering: { isIdentity: true },
time: Time(offsetTime.value + deltaTime.value * i, deltaTime.unit)
});
}
return [2 /*return*/, Coordinates.create(frames, deltaTime, offsetTime)];
}
});
}); });
}