UNPKG

molstar

Version:

A comprehensive macromolecular library.

61 lines (60 loc) 3.62 kB
"use strict"; /** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal <david.sehnal@gmail.com> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.DscifFormat = exports.volumeFromDensityServerData = void 0; var tslib_1 = require("tslib"); var mol_task_1 = require("../../mol-task"); var geometry_1 = require("../../mol-math/geometry"); var linear_algebra_1 = require("../../mol-math/linear-algebra"); var custom_property_1 = require("../../mol-model/custom-property"); function volumeFromDensityServerData(source, params) { var _this = this; return mol_task_1.Task.create('Create Volume', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () { var info, values, cell, axis_order_fast_to_slow, normalizeOrder, sample_count, tensorSpace, data, origin, dimensions; return tslib_1.__generator(this, function (_a) { info = source.volume_data_3d_info, values = source.volume_data_3d; cell = geometry_1.SpacegroupCell.create(info.spacegroup_number.value(0), linear_algebra_1.Vec3.ofArray(info.spacegroup_cell_size.value(0)), linear_algebra_1.Vec3.scale(linear_algebra_1.Vec3.zero(), linear_algebra_1.Vec3.ofArray(info.spacegroup_cell_angles.value(0)), Math.PI / 180)); axis_order_fast_to_slow = info.axis_order.value(0); normalizeOrder = linear_algebra_1.Tensor.convertToCanonicalAxisIndicesFastToSlow(axis_order_fast_to_slow); sample_count = normalizeOrder(info.sample_count.value(0)); tensorSpace = linear_algebra_1.Tensor.Space(sample_count, linear_algebra_1.Tensor.invertAxisOrder(axis_order_fast_to_slow), Float32Array); data = linear_algebra_1.Tensor.create(tensorSpace, linear_algebra_1.Tensor.Data1(values.values.toArray({ array: Float32Array }))); origin = linear_algebra_1.Vec3.ofArray(normalizeOrder(info.origin.value(0))); dimensions = linear_algebra_1.Vec3.ofArray(normalizeOrder(info.dimensions.value(0))); return [2 /*return*/, { label: params === null || params === void 0 ? void 0 : params.label, entryId: params === null || params === void 0 ? void 0 : params.entryId, grid: { transform: { kind: 'spacegroup', cell: cell, fractionalBox: geometry_1.Box3D.create(origin, linear_algebra_1.Vec3.add(linear_algebra_1.Vec3.zero(), origin, dimensions)) }, cells: data, stats: { min: info.min_sampled.value(0), max: info.max_sampled.value(0), mean: info.mean_sampled.value(0), sigma: info.sigma_sampled.value(0) }, }, sourceData: DscifFormat.create(source), customProperties: new custom_property_1.CustomProperties(), _propertyData: Object.create(null), }]; }); }); }); } exports.volumeFromDensityServerData = volumeFromDensityServerData; var DscifFormat; (function (DscifFormat) { function is(x) { return (x === null || x === void 0 ? void 0 : x.kind) === 'dscif'; } DscifFormat.is = is; function create(dscif) { return { kind: 'dscif', name: dscif._name, data: dscif }; } DscifFormat.create = create; })(DscifFormat || (DscifFormat = {})); exports.DscifFormat = DscifFormat;