molstar
Version:
A comprehensive macromolecular library.
106 lines • 3.91 kB
JavaScript
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author David Sehnal <david.sehnal@gmail.com>
*/
import { StructureProperties as Props } from '../../../mol-model/structure';
import { ElementSymbol } from '../../../mol-model/structure/model/types';
export function getAtomsTests(params) {
if (!params)
return [{}];
if (Array.isArray(params)) {
return params.map(function (p) { return atomsTest(p); });
}
else {
return [atomsTest(params)];
}
}
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 = Props.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 = Props.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 = Props.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(Props.residue.label_seq_id);
values.push(+params.label_seq_id);
}
if (typeof params.auth_seq_id !== 'undefined') {
props.push(Props.residue.auth_seq_id);
values.push(+params.auth_seq_id);
}
if (typeof params.pdbx_PDB_ins_code !== 'undefined') {
props.push(Props.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(Props.atom.label_atom_id);
values.push(params.label_atom_id);
}
if (typeof params.auth_atom_id !== 'undefined') {
props.push(Props.atom.auth_atom_id);
values.push(params.auth_atom_id);
}
if (typeof params.type_symbol !== 'undefined') {
props.push(Props.atom.type_symbol);
values.push(ElementSymbol(params.type_symbol));
}
if (typeof params.label_comp_id !== 'undefined') {
props.push(Props.atom.label_comp_id);
values.push(params.label_comp_id);
}
if (typeof params.auth_comp_id !== 'undefined') {
props.push(Props.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