molstar
Version:
A comprehensive macromolecular library.
52 lines • 2.47 kB
JavaScript
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAsymIdCount = exports.calcModelCenter = void 0;
var linear_algebra_1 = require("../../../mol-math/linear-algebra");
var array_1 = require("../../../mol-util/array");
function calcModelCenter(atomicConformation, coarseConformation) {
var rangesX = [];
var rangesY = [];
var rangesZ = [];
if (atomicConformation.x.length) {
rangesX.push.apply(rangesX, (0, array_1.arrayMinMax)(atomicConformation.x));
rangesY.push.apply(rangesY, (0, array_1.arrayMinMax)(atomicConformation.y));
rangesZ.push.apply(rangesZ, (0, array_1.arrayMinMax)(atomicConformation.z));
}
if (coarseConformation) {
if (coarseConformation.spheres.x.length) {
rangesX.push.apply(rangesX, (0, array_1.arrayMinMax)(coarseConformation.spheres.x));
rangesY.push.apply(rangesY, (0, array_1.arrayMinMax)(coarseConformation.spheres.y));
rangesZ.push.apply(rangesZ, (0, array_1.arrayMinMax)(coarseConformation.spheres.z));
}
if (coarseConformation.gaussians.x.length) {
rangesX.push.apply(rangesX, (0, array_1.arrayMinMax)(coarseConformation.gaussians.x));
rangesY.push.apply(rangesY, (0, array_1.arrayMinMax)(coarseConformation.gaussians.y));
rangesZ.push.apply(rangesZ, (0, array_1.arrayMinMax)(coarseConformation.gaussians.z));
}
}
var _a = (0, array_1.arrayMinMax)(rangesX), minX = _a[0], maxX = _a[1];
var _b = (0, array_1.arrayMinMax)(rangesY), minY = _b[0], maxY = _b[1];
var _c = (0, array_1.arrayMinMax)(rangesZ), minZ = _c[0], maxZ = _c[1];
var x = minX + (maxX - minX) / 2;
var y = minY + (maxY - minY) / 2;
var z = minZ + (maxZ - minZ) / 2;
return linear_algebra_1.Vec3.create(x, y, z);
}
exports.calcModelCenter = calcModelCenter;
function getAsymIdCount(model) {
var auth = new Set();
var label = new Set();
model.properties.structAsymMap.forEach(function (_a, label_id) {
var auth_id = _a.auth_id;
auth.add(auth_id);
label.add(label_id);
});
return { auth: auth.size, label: label.size };
}
exports.getAsymIdCount = getAsymIdCount;
//# sourceMappingURL=util.js.map
;