12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
- * @author Alexander Rose <alexander.rose@weirdbyte.de>
- * @author Panagiotis Tourlas <panagiot_tourlov@hotmail.com>
- *
- * @author Koya Sakuma
- * This module is based on jmol transpiler from MolQL and modified in similar manner as pymol and vmd tranpilers. \
- */
- import * as P from '../../../mol-util/monadic-parser';
- import * as h from '../helper';
- import { MolScriptBuilder } from '../../../mol-script/language/builder';
- const B = MolScriptBuilder;
- import { OperatorList } from '../types';
- import { Expression } from '../../language/expression';
- export const operators: OperatorList = [
- {
- '@desc': 'Selects atoms that are not included in s1.',
- '@examples': ['not ARG'],
- name: 'not',
- type: h.prefix,
- rule: P.MonadicParser.alt(P.MonadicParser.regex(/NOT/i).skip(P.MonadicParser.whitespace), P.MonadicParser.string('!').skip(P.MonadicParser.optWhitespace)),
- map: (op, selection) => h.invertExpr(selection),
- },
- {
- '@desc': 'Selects atoms included in both s1 and s2.',
- '@examples': ['ASP and .CA'],
- name: 'and',
- type: h.binaryLeft,
- rule: h.infixOp(/AND|&/i),
- map: (op, selection, by) => B.struct.modifier.intersectBy({ 0: selection, by })
- },
- {
- '@desc': 'Selects atoms included in either s1 or s2.',
- '@examples': ['ASP or GLU'],
- name: 'or',
- type: h.binaryLeft,
- rule: h.infixOp(/OR|\||\|\|/i),
- map: (op, s1, s2) => B.struct.combinator.merge([s1, s2])
- },
- {
- '@desc': 'Selects atoms within a specified distance of a selection',
- '@examples': ['within 5 of name FE'],
- name: 'within',
- type: h.prefix,
- rule: h.prefixOp(/within\s+([-+]?[0-9]*\.?[0-9]+)\s+of/, 1).map((x: any) => parseFloat(x)),
- map: (radius: number, selection: Expression) => {
- return B.struct.modifier.includeSurroundings({ 0: selection, radius });
- }
- },
- ];
|