UNPKG

molstar

Version:

A comprehensive macromolecular library.

110 lines 4.33 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.getAtomsTests = void 0; var structure_1 = require("../../../mol-model/structure"); var types_1 = require("../../../mol-model/structure/model/types"); function getAtomsTests(params) { if (!params) return [{}]; if (Array.isArray(params)) { return params.map(function (p) { return atomsTest(p); }); } else { return [atomsTest(params)]; } } exports.getAtomsTests = getAtomsTests; function atomsTest(params) { return { entityTest: entityTest(params), chainTest: chainTest(params), residueTest: residueTest(params), atomTest: atomTest(params) }; } function entityTest(params) { if (!params || typeof params.label_entity_id === 'undefined') return void 0; var p = structure_1.StructureProperties.entity.id, id = '' + params.label_entity_id; return function (ctx) { return p(ctx.element) === id; }; } function chainTest(params) { if (!params) return void 0; if (typeof params.label_asym_id !== 'undefined') { var p_1 = structure_1.StructureProperties.chain.label_asym_id, id_1 = '' + params.label_asym_id; return function (ctx) { return p_1(ctx.element) === id_1; }; } if (typeof params.auth_asym_id !== 'undefined') { var p_2 = structure_1.StructureProperties.chain.auth_asym_id, id_2 = '' + params.auth_asym_id; return function (ctx) { return p_2(ctx.element) === id_2; }; } return void 0; } function residueTest(params) { if (!params) return void 0; var props = [], values = []; if (typeof params.label_seq_id !== 'undefined') { props.push(structure_1.StructureProperties.residue.label_seq_id); values.push(+params.label_seq_id); } if (typeof params.auth_seq_id !== 'undefined') { props.push(structure_1.StructureProperties.residue.auth_seq_id); values.push(+params.auth_seq_id); } if (typeof params.pdbx_PDB_ins_code !== 'undefined') { props.push(structure_1.StructureProperties.residue.pdbx_PDB_ins_code); values.push(params.pdbx_PDB_ins_code); } return andEqual(props, values); } function atomTest(params) { if (!params) return void 0; var props = [], values = []; if (typeof params.label_atom_id !== 'undefined') { props.push(structure_1.StructureProperties.atom.label_atom_id); values.push(params.label_atom_id); } if (typeof params.auth_atom_id !== 'undefined') { props.push(structure_1.StructureProperties.atom.auth_atom_id); values.push(params.auth_atom_id); } if (typeof params.type_symbol !== 'undefined') { props.push(structure_1.StructureProperties.atom.type_symbol); values.push((0, types_1.ElementSymbol)(params.type_symbol)); } if (typeof params.label_comp_id !== 'undefined') { props.push(structure_1.StructureProperties.atom.label_comp_id); values.push(params.label_comp_id); } if (typeof params.auth_comp_id !== 'undefined') { props.push(structure_1.StructureProperties.atom.auth_comp_id); values.push(params.auth_comp_id); } return andEqual(props, values); } function andEqual(props, values) { switch (props.length) { case 0: return void 0; case 1: return function (ctx) { return props[0](ctx.element) === values[0]; }; case 2: return function (ctx) { return props[0](ctx.element) === values[0] && props[1](ctx.element) === values[1]; }; case 3: return function (ctx) { return props[0](ctx.element) === values[0] && props[1](ctx.element) === values[1] && props[2](ctx.element) === values[2]; }; default: { var len_1 = props.length; return function (ctx) { for (var i = 0; i < len_1; i++) if (!props[i](ctx.element) !== values[i]) return false; return true; }; } } } //# sourceMappingURL=atoms.js.map