Skip to content
Snippets Groups Projects
Select Git revision
  • 8e1876fc25c219d26b6c9e85a543e7ade324d434
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

object.ts

Blame
  • operators.ts 4.00 KiB
    /*
     * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Koya Sakuma <koya.sakuma.work@gmail.com>
     */
    
    
    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';
    import { macroproperties } from './macroproperties';
    
    const propNames = Object.keys(macroproperties).sort(h.strLenSortFn)
        .filter(name => !macroproperties[name].isUnsupported).join('|');
    
    
    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: P.MonadicParser.alt(h.infixOp(/AND|&/i)),
            // 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',
    	abbr: [','],
            type: h.binaryLeft,
    	rule: P.MonadicParser.alt(h.infixOp(/OR|\||\|\||,/i)),
    //        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.0, LYS:A.CA)'],
            name: 'aaa',
            type: h.prefixRemoveKet,
            rule: h.prefixOpNoWhiteSpace(/within\s*\(\s*([-+]?[0-9]*\.?[0-9]+)\s*,/, 1).map((x: any) => {
                console.log(x)
    	    return parseFloat(x)}),
    	map: (radius: number, selection: Expression) => {
    
                return B.struct.modifier.includeSurroundings({ 0: selection, radius });
            }
        },
      */
        {
            '@desc': 'Selects atoms in s1 that are within X Angstroms of any atom in s2.',
            '@examples': ['chain A WITHIN 3 OF chain B'],
            name: 'within',
            abbr: ['w2.'],
            //   type: h.binaryLeft,
            type: h.prefixRemoveKet,
            rule: h.prefixOpNoWhiteSpace(/within\s*\(\s*([-+]?[0-9]*\.?[0-9]+)\s*,/i, 1).map((x: any) => {