UNPKG

molstar

Version:

A comprehensive macromolecular library.

79 lines (78 loc) 3.79 kB
/** * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { __assign, __awaiter, __generator } from "tslib"; import { ParamDefinition as PD } from '../../mol-util/param-definition'; import { StructureProperties, Unit } from '../../mol-model/structure'; import { CustomPropertyDescriptor } from '../../mol-model/custom-property'; import { ANVILParams, computeANVIL, isInMembranePlane } from './algorithm'; import { CustomStructureProperty } from '../../mol-model-props/common/custom-structure-property'; import { Vec3 } from '../../mol-math/linear-algebra'; import { QuerySymbolRuntime } from '../../mol-script/runtime/query/base'; import { CustomPropSymbol } from '../../mol-script/language/symbol'; import { Type } from '../../mol-script/language/type'; export var MembraneOrientationParams = __assign({}, ANVILParams); export { MembraneOrientation }; var MembraneOrientation; (function (MembraneOrientation) { var Tag; (function (Tag) { Tag["Representation"] = "membrane-orientation-3d"; })(Tag = MembraneOrientation.Tag || (MembraneOrientation.Tag = {})); var pos = Vec3(); MembraneOrientation.symbols = { isTransmembrane: QuerySymbolRuntime.Dynamic(CustomPropSymbol('computed', 'membrane-orientation.is-transmembrane', Type.Bool), function (ctx) { var _a = ctx.element, unit = _a.unit, structure = _a.structure; var _b = StructureProperties.atom, x = _b.x, y = _b.y, z = _b.z; if (!Unit.isAtomic(unit)) return 0; var membraneOrientation = MembraneOrientationProvider.get(structure).value; if (!membraneOrientation) return 0; Vec3.set(pos, x(ctx.element), y(ctx.element), z(ctx.element)); var _c = membraneOrientation, normalVector = _c.normalVector, planePoint1 = _c.planePoint1, planePoint2 = _c.planePoint2; return isInMembranePlane(pos, normalVector, planePoint1, planePoint2); }) }; })(MembraneOrientation || (MembraneOrientation = {})); export var MembraneOrientationProvider = CustomStructureProperty.createProvider({ label: 'Membrane Orientation', descriptor: CustomPropertyDescriptor({ name: 'anvil_computed_membrane_orientation', symbols: MembraneOrientation.symbols, // TODO `cifExport` }), type: 'root', defaultParams: MembraneOrientationParams, getParams: function (data) { return MembraneOrientationParams; }, isApplicable: function (data) { return true; }, obtain: function (ctx, data, props) { return __awaiter(void 0, void 0, void 0, function () { var p; var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: p = __assign(__assign({}, PD.getDefaultValues(MembraneOrientationParams)), props); _a = {}; return [4 /*yield*/, computeAnvil(ctx, data, p)]; case 1: return [2 /*return*/, (_a.value = _b.sent(), _a)]; } }); }); } }); function computeAnvil(ctx, data, props) { return __awaiter(this, void 0, void 0, function () { var p; return __generator(this, function (_a) { switch (_a.label) { case 0: p = __assign(__assign({}, PD.getDefaultValues(ANVILParams)), props); return [4 /*yield*/, computeANVIL(data, p).runInContext(ctx.runtime)]; case 1: return [2 /*return*/, _a.sent()]; } }); }); }