From 7a61fd44fda2cac2e7996cd9ec23b20542c34a98 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Wed, 7 Sep 2022 18:32:43 -0700 Subject: [PATCH] remove rasmol transpiler - functionallity integrated into jmol transpiler --- CHANGELOG.md | 2 +- src/mol-plugin-ui/controls/parameters.tsx | 2 +- src/mol-script/script.ts | 2 - .../transpilers/_spec/examples.spec.ts | 1 - .../transpilers/_spec/rasmol.spec.ts | 64 --- src/mol-script/transpilers/all.ts | 2 - src/mol-script/transpilers/rasmol/examples.ts | 39 -- src/mol-script/transpilers/rasmol/keywords.ts | 390 ------------------ .../transpilers/rasmol/macroproperties.ts | 82 ---- .../transpilers/rasmol/markdown-docs.ts | 61 --- .../transpilers/rasmol/operators.ts | 58 --- src/mol-script/transpilers/rasmol/parser.ts | 387 ----------------- .../transpilers/rasmol/properties.ts | 131 ------ src/mol-script/transpilers/rasmol/symbols.ts | 38 -- 14 files changed, 2 insertions(+), 1257 deletions(-) delete mode 100644 src/mol-script/transpilers/_spec/rasmol.spec.ts delete mode 100644 src/mol-script/transpilers/rasmol/examples.ts delete mode 100644 src/mol-script/transpilers/rasmol/keywords.ts delete mode 100644 src/mol-script/transpilers/rasmol/macroproperties.ts delete mode 100644 src/mol-script/transpilers/rasmol/markdown-docs.ts delete mode 100644 src/mol-script/transpilers/rasmol/operators.ts delete mode 100644 src/mol-script/transpilers/rasmol/parser.ts delete mode 100644 src/mol-script/transpilers/rasmol/properties.ts delete mode 100644 src/mol-script/transpilers/rasmol/symbols.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 105f71e7d..626de8e21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Note that since we don't clearly distinguish between a public and private interf - Add custom labels to Confal pyramids - Improve naming of some internal types in Confal pyramids extension coordinate - Add example mmCIF file with categories necessary to display Confal pyramids -- [Experimental] Add support for PyMOL, VMD, Jmol and RasMol atom expressions in selection scripts +- [Experimental] Add support for PyMOL, VMD, and Jmol atom expressions in selection scripts ## [v3.13.0] - 2022-07-24 diff --git a/src/mol-plugin-ui/controls/parameters.tsx b/src/mol-plugin-ui/controls/parameters.tsx index 46d78ae8c..4a5980197 100644 --- a/src/mol-plugin-ui/controls/parameters.tsx +++ b/src/mol-plugin-ui/controls/parameters.tsx @@ -1496,7 +1496,7 @@ export class ScriptControl extends React.PureComponent<ParamProps<PD.Script>> { return <> {select} {this.props.value.language !== 'mol-script' && <div className='msp-help-text' style={{ padding: '10px' }}> - <Icon svg={WarningSvg} /> Support for PyMOL, VMD, Jmol, and RasMol selections is an experimental feature and may not always work as intended. + <Icon svg={WarningSvg} /> Support for PyMOL, VMD, and Jmol selections is an experimental feature and may not always work as intended. </div>} {text} </>; diff --git a/src/mol-script/script.ts b/src/mol-script/script.ts index a1e4e5d32..7497f49b8 100644 --- a/src/mol-script/script.ts +++ b/src/mol-script/script.ts @@ -27,7 +27,6 @@ namespace Script { 'pymol': 'PyMOL', 'vmd': 'VMD', 'jmol': 'Jmol', - 'rasmol': 'RasMol' }; export type Language = keyof typeof Info; @@ -48,7 +47,6 @@ namespace Script { case 'pymol': case 'jmol': case 'vmd': - case 'rasmol': return parse(script.language, script.expression); default: assertUnreachable(script.language); diff --git a/src/mol-script/transpilers/_spec/examples.spec.ts b/src/mol-script/transpilers/_spec/examples.spec.ts index 23ff1930b..ca45ce7e2 100644 --- a/src/mol-script/transpilers/_spec/examples.spec.ts +++ b/src/mol-script/transpilers/_spec/examples.spec.ts @@ -24,4 +24,3 @@ function testTranspilerExamples(name: string, transpiler: Transpiler) { testTranspilerExamples('pymol', transpilers.pymol); testTranspilerExamples('vmd', transpilers.vmd); testTranspilerExamples('jmol', transpilers.jmol); -testTranspilerExamples('rasmol', transpilers.rasmol); diff --git a/src/mol-script/transpilers/_spec/rasmol.spec.ts b/src/mol-script/transpilers/_spec/rasmol.spec.ts deleted file mode 100644 index 87865f3e3..000000000 --- a/src/mol-script/transpilers/_spec/rasmol.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> - */ - -import * as u from './utils'; -import { transpiler } from '../rasmol/parser'; -import { keywords } from '../rasmol/keywords'; -import { properties } from '../rasmol/properties'; -import { operators } from '../rasmol/operators'; - -const general = { - supported: [ - // value comparison - 'resno > 10', - // atom expression - '[LEU]100:A.CA', - '[LEU]100:A', - '[LEU]100:.CA', - '[LEU]:A.CA', - '[LEU].CA', - // residue numbering - '(1-10,15,21-30)', - // within with parentheses - '( within(5,[HEM]) ) and backbone', - // trimming - '[ALA] and [VAL] ', - ' [ALA] and [VAL] ', - ' [ALA] and [VAL]', - // within with whitespaces - 'within ( 5 , [HEM] ) ', - // un-braketed residue name - 'LEU and ILE', - // un-parenthesized residue index range - '100-120,220', - // un-parenthesized residue index - '20', - // within in the head or the middle of sentence - 'within ( 5 , [HEM] ) and backbone', - ], - unsupported: [ - ] -}; - -describe('rasmol general', () => { - general.supported.forEach(str => { - it(str, () => { - transpiler(str); - // compile(expr); - }); - }); - general.unsupported.forEach(str => { - it(str, () => { - const transpileStr = () => transpiler(str); - expect(transpileStr).toThrow(); - expect(transpileStr).not.toThrowError(RangeError); - }); - }); -}); - -describe('rasmol keywords', () => u.testKeywords(keywords, transpiler)); -describe('rasmol operators', () => u.testOperators(operators, transpiler)); -describe('rasmol properties', () => u.testProperties(properties, transpiler)); diff --git a/src/mol-script/transpilers/all.ts b/src/mol-script/transpilers/all.ts index ad3f967f7..b1434278e 100644 --- a/src/mol-script/transpilers/all.ts +++ b/src/mol-script/transpilers/all.ts @@ -7,11 +7,9 @@ import { transpiler as jmol } from './jmol/parser'; import { transpiler as pymol } from './pymol/parser'; import { transpiler as vmd } from './vmd/parser'; -import { transpiler as rasmol } from './rasmol/parser'; export const _transpiler = { pymol, vmd, jmol, - rasmol }; diff --git a/src/mol-script/transpilers/rasmol/examples.ts b/src/mol-script/transpilers/rasmol/examples.ts deleted file mode 100644 index 2bfd3d6b9..000000000 --- a/src/mol-script/transpilers/rasmol/examples.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017 MolQL contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - * @author David Sehnal <david.sehnal@gmail.com> - * - */ - -export const examples = [{ - name: 'Residue 50 or 135', - value: '(50) or (135)' -}, { - name: 'Residue 50 or 135', - value: '(50,135)' -}, { - name: 'Residue 20-22 or 8 or 2-16', - value: '(20-22,8,2-16)' -}, { - name: 'Residue with the index more than 10', - value: 'resno > 10' -}, { - name: 'Atoms assinged as backbone of protein or nucleic acid', - value: 'backbone' -}, { - name: 'ALA, LEU, or aromatic residue within 10 angstrom from HEM ', - value: '( [ALA] or [LEU] or aromatic ) and within( 10.0 ,[HEM])' -}, { - name: 'Residue within 10 angstrom from HEM but not HEM', - value: 'not [HEM] and within(5, [HEM])' -}, { - name: 'Residue within 10 angstrom from HEM but not HEM', - value: '( within(5, [HEM]) ) and not [HEM]' -}, { - name: 'C-beta atom ALA10 in chain A or all C-alpha atoms or all CG atoms from LYS', - value: '[ALA]10:A.CB or :.CA or [LYS].CG' -}, { - name: 'Pyrimidine residues', - value: 'pyrimidine' -}]; diff --git a/src/mol-script/transpilers/rasmol/keywords.ts b/src/mol-script/transpilers/rasmol/keywords.ts deleted file mode 100644 index 170846455..000000000 --- a/src/mol-script/transpilers/rasmol/keywords.ts +++ /dev/null @@ -1,390 +0,0 @@ -/** - * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> -**/ - - -import { MolScriptBuilder } from '../../../mol-script/language/builder'; -const B = MolScriptBuilder; -import * as h from '../helper'; -import { KeywordDict } from '../types'; - -const Backbone = { - nucleic: ['P', "O3'", "O5'", "C5'", "C4'", "C3'", 'OP1', 'OP2', 'O3*', 'O5*', 'C5*', 'C4*', 'C3*'], - protein: ['C', 'N', 'CA', 'O'] -}; - - -function nucleicExpr() { - return B.struct.combinator.merge([ - B.struct.generator.atomGroups({ - 'residue-test': B.core.set.has([ - B.core.type.set(['G', 'C', 'A', 'T', 'U', 'I', 'DG', 'DC', 'DA', 'DT', 'DU', 'DI', '+G', '+C', '+A', '+T', '+U', '+I']), - B.ammp('label_comp_id') - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.logic.and([ - B.core.set.isSubset([ - h.atomNameSet(['P']), - B.ammpSet('label_atom_id') - ]), - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.logic.or([ - B.core.set.isSubset([ - h.atomNameSet(["C1'", "C2'", "O3'", "C3'", "C4'", "C5'", "O5'"]), - B.ammpSet('label_atom_id') - ]), - B.core.set.isSubset([ - h.atomNameSet(['C1*', 'C2*', 'O3*', 'C3*', 'C4*', 'C5*', 'O5*']), - B.ammpSet('label_atom_id') - ]) - ]) - }) - ]); -} - - - -const ResDict = { - aliphatic: ['ALA', 'GLY', 'ILE', 'LEU', 'VAL'], - amino: ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLN', 'GLU', 'GLY', 'HIS', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL', 'ASX', 'GLX', 'UNK'], - acidic: ['ASP', 'GLU'], - aromatic: ['HIS', 'PHE', 'TRP', 'TYR'], - basic: ['ARG', 'HIS', 'LYS'], - buried: ['ALA', 'CYS', 'ILE', 'LEU', 'MET', 'PHE', 'TRP', 'VAL'], - cg: ['CYT', 'C', 'GUA', 'G'], - cyclic: ['HIS', 'PHE', 'PRO', 'TRP', 'TYR'], - hydrophobic: ['ALA', 'GLY', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'TYR', 'VAL'], - large: ['ARG', 'GLU', 'GLN', 'HIS', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'TRP', 'TYR'], - medium: ['ASN', 'ASP', 'CYS', 'PRO', 'THR', 'VAL'], - small: ['ALA', 'GLY', 'SER'], - nucleic: ['A', 'C', 'T', 'G', 'U', 'DA', 'DC', 'DT', 'DG', 'DU'], - protein: ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'CYX', 'GLN', 'GLU', 'GLY', 'HIS', 'HID', 'HIE', 'HIP', 'ILE', 'LEU', 'LYS', 'MET', 'MSE', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL'], - solvent: ['HOH', 'WAT', 'H20', 'TIP', 'SOL'] -}; - - -export const keywords: KeywordDict = { - // general terms - all: { - '@desc': 'all atoms; same as *', - abbr: ['*'], - map: () => B.struct.generator.all() - }, - none: { - '@desc': 'no atoms', - map: () => B.struct.generator.empty() - }, - selected: { - '@desc': 'atoms that have been selected; defaults to all when a file is first loaded' - }, - unitcell: { - '@desc': 'atoms within the current unitcell, which may be offset. This includes atoms on the faces and at the vertices of the unitcell.' - }, - ions: { - '@desc': '(specifically the PDB designations "PO4" and "SO4")' - }, - ligand: { - '@desc': '(originally "hetero and not solvent"; changed to "!(protein,nucleic,water,UREA)" for Jmol 12.2)' - }, - nucleic: { - '@desc': 'any group that (a) has one of the following group names: G, C, A, T, U, I, DG, DC, DA, DT, DU, DI, +G, +C, +A, +T, +U, +I; or (b) can be identified as a group that is only one atom, with name "P"; or (c) has all of the following atoms (prime, \', can replace * here): C1*, C2*, C3*, O3*, C4*, C5*, and O5*.', - map: () => nucleicExpr() - }, - purine: { - '@desc': 'any nucleic group that (a) has one of the following group names: A, G, I, DA, DG, DI, +A, +G, or +I; or (b) also has atoms N7, C8, and N9.', - map: () => B.struct.modifier.intersectBy({ - 0: nucleicExpr(), - by: B.struct.combinator.merge([ - B.struct.generator.atomGroups({ - 'residue-test': B.core.set.has([ - B.set(...['A', 'G', 'I', 'DA', 'DG', 'DI', '+A', '+G', '+I']), - B.ammp('label_comp_id') - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.set.isSubset([ - h.atomNameSet(['N7', 'C8', 'N9']), - B.ammpSet('label_atom_id') - ]) - }) - ]) - }) - }, - pyrimidine: { - '@desc': 'any nucleic group that (a) has one of the following group names: C, T, U, DC, DT, DU, +C, +T, +U; or (b) also has atom O2.', - map: () => B.struct.modifier.intersectBy({ - 0: nucleicExpr(), - by: B.struct.combinator.merge([ - B.struct.generator.atomGroups({ - 'residue-test': B.core.set.has([ - B.set(...['C', 'T', 'U', 'DC', 'DT', 'DU', '+C', '+T', '+U']), - B.ammp('label_comp_id') - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.logic.or([ - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName('O2*') - ]), - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName("O2'") - ]) - ]) - }) - ]) - }) - }, - dna: { - '@desc': 'any nucleic group that (a) has one of the following group names: DG, DC, DA, DT, DU, DI, T, +G, +C, +A, +T; or (b) has neither atom O2* or O2\'.', - map: () => B.struct.modifier.intersectBy({ - 0: nucleicExpr(), - by: B.struct.combinator.merge([ - B.struct.generator.atomGroups({ - 'residue-test': B.core.set.has([ - B.set(...['DG', 'DC', 'DA', 'DT', 'DU', 'DI', 'T', '+G', '+C', '+A', '+T']), - B.ammp('label_comp_id') - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.logic.not([ - B.core.logic.or([ - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName('O2*') - ]), - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName("O2'") - ]) - ]) - ]) - }) - ]) - }) - }, - rna: { - '@desc': 'any nucleic group that (a) has one of the following group names: G, C, A, U, I, +U, +I; or (b) has atom O2* or O2\'.', - map: () => B.struct.modifier.intersectBy({ - 0: nucleicExpr(), - by: B.struct.combinator.merge([ - B.struct.generator.atomGroups({ - 'residue-test': B.core.set.has([ - B.set(...['G', 'C', 'A', 'U', 'I', '+U', '+I']), - B.ammp('label_comp_id') - ]) - }), - B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.logic.or([ - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName('O2*') - ]), - B.core.set.has([ - B.ammpSet('label_atom_id'), - B.atomName("O2'") - ]) - ]) - }) - ]) - }) - }, - protein: { - '@desc': 'defined as a group that (a) has one of the following group names: ALA, ARG, ASN, ASP, CYS, GLN, GLU, GLY, HIS, ILE, LEU}, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL, ASX, GLX, or UNK; or (b) contains PDB atom designations [C, O, CA, and N] bonded correctly; or (c) does not contain "O" but contains [C, CA, and N] bonded correctly; or (d) has only one atom, which has name CA and does not have the group name CA (indicating a calcium atom).', - map: () => proteinExpr() - }, - acidic: { - '@desc': 'ASP GLU', - map: () => h.resnameExpr(ResDict.acidic) - }, - acyclic: { - '@desc': 'amino and not cyclic', - map: () => B.struct.modifier.intersectBy({ - 0: h.resnameExpr(ResDict.amino), - by: h.invertExpr(h.resnameExpr(ResDict.cyclic)) - }) - }, - aliphatic: { - '@desc': 'ALA GLY ILE LEU VAL', - map: () => h.resnameExpr(ResDict.aliphatic) - }, - amino: { - '@desc': 'all twenty standard amino acids, plus ASX, GLX, UNK', - map: () => h.resnameExpr(ResDict.amino) - }, - aromatic: { - '@desc': 'HIS PHE TRP TYR (see also "isaromatic" for aromatic bonds)', - map: () => h.resnameExpr(ResDict.aromatic) - }, - basic: { - '@desc': 'ARG HIS LYS', - map: () => h.resnameExpr(ResDict.basic) - }, - buried: { - '@desc': 'ALA CYS ILE LEU MET PHE TRP VAL', - map: () => h.resnameExpr(ResDict.buried) - }, - charged: { - '@desc': 'same as acidic or basic -- ASP GLU, ARG HIS LYS', - map: () => h.resnameExpr(ResDict.acidic.concat(ResDict.basic)) - }, - cyclic: { - '@desc': 'HIS PHE PRO TRP TYR', - map: () => h.resnameExpr(ResDict.cyclic) - }, - helix: { - '@desc': 'secondary structure-related.', - map: () => B.struct.generator.atomGroups({ - 'residue-test': B.core.flags.hasAny([ - B.struct.type.secondaryStructureFlags(['helix']), - B.ammp('secondaryStructureFlags') - ]) - }) - }, - hetero: { - '@desc': 'PDB atoms designated as HETATM', - map: () => B.struct.generator.atomGroups({ - 'atom-test': B.ammp('isHet') - }) - }, - hydrophobic: { - '@desc': 'ALA GLY ILE LEU MET PHE PRO TRP TYR VAL', - map: () => h.resnameExpr(ResDict.hydrophobic) - }, - large: { - '@desc': 'ARG GLU GLN HIS ILE LEU LYS MET PHE TRP TYR', - map: () => h.resnameExpr(ResDict.large) - }, - medium: { - '@desc': 'ASN ASP CYS PRO THR VAL', - map: () => h.resnameExpr(ResDict.medium) - }, - negative: { - '@desc': 'same as acidic -- ASP GLU', - map: () => h.resnameExpr(ResDict.acidic) - }, - neutral: { - '@desc': 'amino and not (acidic or basic)', - map: () => B.struct.modifier.intersectBy({ - 0: h.resnameExpr(ResDict.amino), - by: h.invertExpr(h.resnameExpr(ResDict.acidic.concat(ResDict.basic))) - }) - }, - polar: { - '@desc': 'amino and not hydrophobic', - map: () => B.struct.modifier.intersectBy({ - 0: h.resnameExpr(ResDict.amino), - by: h.invertExpr(h.resnameExpr(ResDict.hydrophobic)) - }) - }, - positive: { - '@desc': 'same as basic -- ARG HIS LYS', - map: () => h.resnameExpr(ResDict.basic) - }, - sheet: { - '@desc': 'secondary structure-related', - map: () => B.struct.generator.atomGroups({ - 'residue-test': B.core.flags.hasAny([ - B.struct.type.secondaryStructureFlags(['sheet']), - B.ammp('secondaryStructureFlags') - ]) - }) - }, - small: { - '@desc': 'ALA GLY SER', - map: () => h.resnameExpr(ResDict.small) - }, - turn: { - '@desc': 'secondary structure-related', - map: () => B.struct.generator.atomGroups({ - 'residue-test': B.core.flags.hasAny([ - B.struct.type.secondaryStructureFlags(['turn']), - B.ammp('secondaryStructureFlags') - ]) - }) - }, - alpha: { - '@desc': '(*.CA)', - map: () => B.struct.generator.atomGroups({ - 'atom-test': B.core.rel.eq([ - B.atomName('CA'), - B.ammp('label_atom_id') - ]) - }) - }, - base: { - '@desc': '(nucleic bases)' - }, - backbone: { - '@desc': '(*.C, *.CA, *.N, and all nucleic other than the bases themselves)', - abbr: ['mainchain'], - map: () => backboneExpr() - }, - sidechain: { - '@desc': '((protein or nucleic) and not backbone)' - }, - solvent: { - '@desc': 'PDB "HOH", water, also the connected set of H-O-H in any model', - map: () => h.resnameExpr(ResDict.solvent) - }, -}; - -function backboneExpr() { - return B.struct.combinator.merge([ - B.struct.generator.queryInSelection({ - 0: proteinExpr(), - query: B.struct.generator.atomGroups({ - 'atom-test': B.core.set.has([ - h.atomNameSet(Backbone.protein), - B.ammp('label_atom_id') - ]) - }) - }), - B.struct.generator.queryInSelection({ - 0: nucleicExpr(), - query: B.struct.generator.atomGroups({ - 'atom-test': B.core.set.has([ - h.atomNameSet(Backbone.nucleic), - B.ammp('label_atom_id') - ]) - }) - }) - ]); -} - -function proteinExpr() { - return B.struct.filter.pick({ - 0: B.struct.generator.atomGroups({ - 'group-by': B.ammp('residueKey') - }), - test: B.core.set.isSubset([ - h.atomNameSet(['C', 'N', 'CA', 'O']), - B.ammpSet('label_atom_id') - ]) - }); -} - diff --git a/src/mol-script/transpilers/rasmol/macroproperties.ts b/src/mol-script/transpilers/rasmol/macroproperties.ts deleted file mode 100644 index f991e2ed9..000000000 --- a/src/mol-script/transpilers/rasmol/macroproperties.ts +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> - */ - -import { MolScriptBuilder } from '../../../mol-script/language/builder'; -const B = MolScriptBuilder; -import { PropertyDict } from '../types'; - -function atomNameListMap(x: string) { return x.split(',').map(B.atomName); } -function listMap(x: string) { return x.split(',').map(x => x.replace(/^["']|["']$/g, '')); } -function rangeMap(x: string) { - const [min, max] = x.split('-').map(x => parseInt(x)); - return { min, max }; -} -function listOrRangeMap(x: string) { - if (x.includes('-') && x.includes(',')) { - const pSplit = x.split(',').map(x => x.replace(/^["']|["']$/g, '')); - const res: number[] = []; - pSplit.forEach(x => { - if (x.includes('-')) { - const [min, max] = x.split('-').map(x=>parseInt(x)); - for (let i = min; i <= max; i++) { - res.push(i); - } - } else { - res.push(parseInt(x)); - } - }); - return res; - } else if (x.includes('-') && !x.includes(',')) { - return rangeMap(x); - } else if (!x.includes('-') && x.includes(',')) { - return listMap(x).map(x => parseInt(x)); - } else { - return parseInt(x); - } -} -function elementListMap(x: string) { - return x.split(',').map(B.struct.type.elementSymbol); -} - -export const macroproperties: PropertyDict = { - symbol: { - '@desc': 'chemical-symbol-list: list of 1- or 2-letter chemical symbols from the periodic table', - '@examples': ['symbol O+N'], - abbr: ['e.'], regex: /[a-zA-Z'",]+/, map: elementListMap, - level: 'atom-test', property: B.acp('elementSymbol') - }, - name: { - '@desc': 'atom-name-list: list of up to 4-letter codes for atoms in proteins or nucleic acids', - '@examples': ['name CA+CB+CG+CD'], - abbr: ['n.'], regex: /[a-zA-Z0-9'",]+/, map: atomNameListMap, - level: 'atom-test', property: B.ammp('label_atom_id') - }, - resn: { - '@desc': 'residue-name-list: list of 3-letter codes for amino acids or list of up to 2-letter codes for nucleic acids', - '@examples': ['resn ASP+GLU+ASN+GLN', 'resn A+G'], - abbr: ['resname', 'r.'], regex: /[a-zA-Z0-9'",]+/, map: listMap, - level: 'residue-test', property: B.ammp('label_comp_id') - }, - resi: { - '@desc': 'residue-identifier-list list of up to 4-digit residue numbers or residue-identifier-range', - '@examples': ['resi 1+10+100+1000', 'resi 1-10'], - abbr: ['resident', 'residue', 'resid', 'i.'], regex: /[0-9,-]+/, map: listOrRangeMap, - level: 'residue-test', property: B.ammp('auth_seq_id') - }, - alt: { - '@desc': 'alternate-conformation-identifier-list list of single letters', - '@examples': ['alt A+B', 'alt ""', 'alt ""+A'], - abbr: [], regex: /[a-zA-Z0-9'",]+/, map: listMap, - level: 'atom-test', property: B.ammp('label_alt_id') - }, - chain: { - '@desc': 'chain-identifier-list list of single letters or sometimes numbers', - '@examples': ['chain A'], - abbr: ['c.'], regex: /[a-zA-Z0-9'",]+/, map: listMap, - level: 'chain-test', property: B.ammp('auth_asym_id') - }, - -}; diff --git a/src/mol-script/transpilers/rasmol/markdown-docs.ts b/src/mol-script/transpilers/rasmol/markdown-docs.ts deleted file mode 100644 index ea4dc8203..000000000 --- a/src/mol-script/transpilers/rasmol/markdown-docs.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> -*/ - -import { properties } from './properties'; -import { operators } from './operators'; -import { keywords } from './keywords'; - - -const _docs: string[] = [ - 'RasMol', - '============', - '--------------------------------', - '' -]; - -_docs.push(`## Properties\n\n`); -_docs.push('--------------------------------\n'); -for (const name in properties) { - if (properties[name].isUnsupported) continue; - - const names = [name]; - if (properties[name].abbr) names.push(...properties[name].abbr!); - _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`); - - if (properties[name]['@desc']) { - _docs.push(`*${properties[name]['@desc']}*\n`); - } -} - -_docs.push(`## Operators\n\n`); -_docs.push('--------------------------------\n'); -operators.forEach(o => { - if (o.isUnsupported) return; - - const names = [o.name]; - if (o.abbr) names.push(...o.abbr!); - _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`); - - if (o['@desc']) { - _docs.push(`*${o['@desc']}*\n`); - } -}); - -_docs.push(`## Keywords\n\n`); -_docs.push('--------------------------------\n'); -for (const name in keywords) { - if (!keywords[name].map) continue; - - const names = [name]; - if (keywords[name].abbr) names.push(...keywords[name].abbr!); - _docs.push(`\`\`\`\n${names.join(', ')}\n\`\`\`\n`); - - if (keywords[name]['@desc']) { - _docs.push(`*${keywords[name]['@desc']}*\n`); - } -} - -export const docs = _docs.join('\n'); diff --git a/src/mol-script/transpilers/rasmol/operators.ts b/src/mol-script/transpilers/rasmol/operators.ts deleted file mode 100644 index 8a1139af7..000000000 --- a/src/mol-script/transpilers/rasmol/operators.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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'; - -export const operators: OperatorList = [ - { - '@desc': 'Selects atoms in s1 that are within X Angstroms of any atom in s2.', - '@examples': ['within(5.0, [HEM])'], - name: 'within', - type: h.prefixRemoveKet, - rule: h.prefixOpNoWhiteSpace(/within\s*\(\s*([-+]?[0-9]*\.?[0-9]+)\s*,/, 1).map((x: any) => { - return parseFloat(x); - }), - map: (radius: number, target: Expression) => { - return B.struct.filter.within({ - 0: B.struct.generator.all(), - target, - 'max-radius': radius, - }); - }, - }, - { - '@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)), - 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)), - map: (op, s1, s2) => B.struct.combinator.merge([s1, s2]) - }, -]; - diff --git a/src/mol-script/transpilers/rasmol/parser.ts b/src/mol-script/transpilers/rasmol/parser.ts deleted file mode 100644 index e44fce0e2..000000000 --- a/src/mol-script/transpilers/rasmol/parser.ts +++ /dev/null @@ -1,387 +0,0 @@ -/** - * 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 { properties } from './properties'; -import { macroproperties } from './macroproperties'; -import { operators } from './operators'; -import { keywords } from './keywords'; -import { AtomGroupArgs } from '../types'; -import { Transpiler } from '../transpiler'; - - -function listMap(x: string) { return x.split(',').map(x => x.replace(/^["']|["']$/g, '')); } - -function listOrRangeMap(x: string) { - // cases - // case1: 1-100,200 - if (x.includes('-') && x.includes(',')) { - const pSplit = x.split(',').map(x => x.replace(/^["']|["']$/g, '')); - const res: number[] = []; - pSplit.forEach(x => { - if (x.includes('-') && !x.startsWith('-')) { - const [min, max] = x.split('-').map(x=>parseInt(x)); - for (let i = min; i <= max; i++) { - res.push(i); - } - } else if (x.includes('-') && x.startsWith('-') && x.match(/[0-9]+-[-0-9]+/)) { - const min = -parseInt(x.split('-')[1]); - let max; - if (x.includes('--')) { - max = -parseInt(x.split('-')[3]); - } else { - max = parseInt(x.split('-')[2]); - } - for (let i = min; i <= max; i++) { - res.push(i); - } - } else if (x.includes('-') && x.startsWith('-') && !x.match(/[0-9]+-[-0-9]+/)) { - res.push(parseInt(x)); - } else { - res.push(parseInt(x)); - } - }); - return res; - } else if (x.includes('-') && !x.includes(',')) { - const res: number[] = []; - if (!x.startsWith('-')) { - const [min, max] = x.split('-').map(x=>parseInt(x)); - for (let i = min; i <= max; i++) { - res.push(i); - } - } else if (x.startsWith('-') && x.match(/[0-9]+-[-0-9]+/)) { - const min = -parseInt(x.split('-')[1]); - let max; - if (x.includes('--')) { - max = -parseInt(x.split('-')[3]); - } else { - max = parseInt(x.split('-')[2]); - } - for (let i = min; i <= max; i++) { - res.push(i); - } - } else if (x.startsWith('-') && !x.match(/[0-9]+-[-0-9]+/)) { - res.push(parseInt(x)); - } else { - res.push(parseInt(x)); - } - return res; - } else if (!x.includes('-') && x.includes(',')) { - return listMap(x).map(x => parseInt(x)); - } else { - return [parseInt(x)]; - } -} - - -const propertiesDict = h.getPropertyRules(macroproperties); - -const dot = P.MonadicParser.string('.'); -const colon = P.MonadicParser.string(':'); -const star = P.MonadicParser.string('*'); -const commu = P.MonadicParser.string('['); -const tator = P.MonadicParser.string(']'); - -function orNull(rule: P.MonadicParser<any>) { - return rule.or(P.MonadicParser.of(null)); -} - -function atomSelectionQuery2(x: any) { - const tests: AtomGroupArgs = {}; - const props: { [k: string]: any[] } = {}; - - for (const k in x) { - const ps = macroproperties[k]; - if (!ps) { - throw new Error(`property '${k}' not supported, value '${x[k]}'`); - } - if (x[k] === null) continue; - if (!props[ps.level]) props[ps.level] = []; - props[ps.level].push(x[k]); - } - - for (const p in props) { - tests[p] = h.andExpr(props[p]); - } - - return B.struct.generator.atomGroups(tests); -} - -function atomExpressionQuery(x: any[]) { - const [resnorange, resno, inscode, chainname, atomname, altloc] = x[1]; - const tests: AtomGroupArgs = {}; - - if (chainname) { - // should be configurable, there is an option in Jmol to use auth or label - tests['chain-test'] = B.core.rel.eq([B.ammp('auth_asym_id'), chainname]); - } - - const resnoRangeProps: any = []; - if (resnorange) { - resnorange.forEach((x: number) =>{ - resnoRangeProps.push(B.core.rel.eq([B.ammp('auth_seq_id'), x])); - }); - }; - if (resnoRangeProps.length) tests['residue-test'] = h.orExpr(resnoRangeProps); - - const resProps: any = []; - if (resno) { - resProps.push(B.core.rel.eq([B.ammp('auth_seq_id'), resno])); - } - if (inscode) resProps.push(B.core.rel.eq([B.ammp('pdbx_PDB_ins_code'), inscode])); - if (resProps.length) tests['residue-test'] = h.andExpr(resProps); - - const atomProps = []; - if (atomname) atomProps.push(B.core.rel.eq([B.ammp('auth_atom_id'), atomname])); - if (altloc) atomProps.push(B.core.rel.eq([B.ammp('label_alt_id'), altloc])); - if (atomProps.length) tests['atom-test'] = h.andExpr(atomProps); - - return B.struct.generator.atomGroups(tests); -} - -function resnorangeExpressionQuery(x: any[]) { - const [resnorange, chainname] = x; - const tests: AtomGroupArgs = {}; - - if (chainname) { - // should be configurable, there is an option in Jmol to use auth or label - tests['chain-test'] = B.core.rel.eq([B.ammp('auth_asym_id'), chainname]); - } - - const resnoRangeProps: any = []; - if (resnorange) { - resnorange.forEach((x: number) =>{ - resnoRangeProps.push(B.core.rel.eq([B.ammp('auth_seq_id'), x])); - }); - }; - if (resnoRangeProps.length) tests['residue-test'] = h.orExpr(resnoRangeProps); - - return B.struct.generator.atomGroups(tests); -} - - -const lang = P.MonadicParser.createLanguage({ - - Integer: () => P.MonadicParser.regexp(/-?[0-9]+/).map(Number).desc('integer'), - - Parens: function (r: any) { - return P.MonadicParser.alt( - r.Parens, - r.Operator, - r.Expression - ).wrap(P.MonadicParser.regexp(/\(\s*/), P.MonadicParser.regexp(/\s*\)/)); - }, - - Expression: function (r: any) { - return P.MonadicParser.alt( - // order matters - r.Keywords, - r.NamedAtomProperties, - r.AtomSelectionMacro.map(atomSelectionQuery2), - r.AtomExpression.map(atomExpressionQuery), - r.Element.map((x: string) => B.struct.generator.atomGroups({ - 'atom-test': B.core.rel.eq([B.acp('elementSymbol'), B.struct.type.elementSymbol(x)]) - })), - r.Resname.map((x: string) => B.struct.generator.atomGroups({ - 'residue-test': B.core.rel.eq([B.ammp('label_comp_id'), x]) - })), - r.ResnoRangeExpression.map(resnorangeExpressionQuery), - r.Object, - r.Object2, - ); - }, - - // lys:a.ca -> resn lys and chain A and name ca - // lys*a.ca -> resn lys and chain A and name ca - // - // :a.ca -> chain A and name ca - // *a.ca -> chain A and name ca - // - // *.cg -> name ca - // :.cg -> name ca - AtomSelectionMacro: function (r: any) { - return P.MonadicParser.alt( - // :A.CA :.CA :A - colon.then(P.MonadicParser.alt( - P.MonadicParser.seq( - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { chain: x[0], name: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.name).skip(dot) - ).map(x => { return { name: x[0] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.chain) - ).map(x => { return { chain: x[0] }; }), - )), - // *A.CA *.CA - star.then(P.MonadicParser.alt( - P.MonadicParser.seq( - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { chain: x[0], name: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.name).skip(dot) - ).map(x => { return { name: x[0] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.chain) - ).map(x => { return { chain: x[0] }; }), - )), - // [lys]10:a.ca [lys]10:a [lys]10 [lys]10.ca - // [lys]:a.ca [lys]:a [lys] [lys].ca - commu.then(P.MonadicParser.alt( - P.MonadicParser.alt( - P.MonadicParser.alt( - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - orNull(propertiesDict.resi).skip(colon), - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { resn: x[0], resi: x[1], chain: x[2], name: x[3] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - orNull(propertiesDict.resi).skip(colon), - orNull(propertiesDict.chain) - ).map(x => { return { resn: x[0], resi: x[1], chain: x[2] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - orNull(propertiesDict.resi).skip(colon).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { resn: x[0], resi: x[1], name: x[2] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - orNull(propertiesDict.resi).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { resn: x[0], resi: x[1], name: x[2] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - orNull(propertiesDict.resi) - ).map(x => { return { resn: x[0], resi: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator).skip(colon), - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator).skip(star), - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) - ).map(x => { return { resn: x[0], chain: x[1], name: x[2] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator).skip(colon), - orNull(propertiesDict.chain), - ).map(x => { return { resn: x[0], chain: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator).skip(star), - orNull(propertiesDict.chain), - ).map(x => { return { resn: x[0], chain: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator).skip(dot), - orNull(propertiesDict.name), - ).map(x => { return { resn: x[0], name: x[1] }; }), - P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(tator), - ).map(x => { return { resn: x[0] }; }) - ) - ) - ) - ) - ); - }, - - ObjectProperty: () => { - const w = h.getReservedWords(macroproperties, keywords, operators) - .sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); - return P.MonadicParser.regexp(new RegExp(`(?!(${w}))[A-Z0-9_]+`, 'i')); - }, - - Object: (r: any) => { - return r.ObjectProperty - .map((x: any) => { throw new Error(`property 'object' not supported, value '${x}'`); }); - }, - - - ObjectProperty2: () => { - const w = h.getReservedWords(properties, keywords, operators) - .sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); - return P.MonadicParser.regexp(new RegExp(`(?!(${w}))[A-Z0-9_]+`, 'i')); - }, - - Object2: (r: any) => { - return r.ObjectProperty2 - .map((x: any) => { throw new Error(`property 'object' not supported, value '${x}'`); }); - }, - - NamedAtomProperties: function () { - return P.MonadicParser.alt(...h.getNamedPropertyRules(properties)); - }, - - Operator: function (r: any) { - return h.combineOperators(operators, P.MonadicParser.alt(r.Parens, r.Expression, r.Operator)); - }, - - AtomExpression: function (r: any) { - return P.MonadicParser.seq( - P.MonadicParser.lookahead(r.AtomPrefix), - P.MonadicParser.seq( - r.ResnoRange.or(P.MonadicParser.of(null)), - r.Resno.or(P.MonadicParser.of(null)), - r.Inscode.or(P.MonadicParser.of(null)), - r.Chainname.or(P.MonadicParser.of(null)), - r.Atomname.or(P.MonadicParser.of(null)), - r.Altloc.or(P.MonadicParser.of(null)), - r.Model.or(P.MonadicParser.of(null)) - ) - ); - }, - - ResnoRangeExpression: function (r: any) { - return P.MonadicParser.seq( - r.ResnoRange.or(P.MonadicParser.of(null)), - r.Chainname.or(P.MonadicParser.of(null)), - ); - }, - - AtomPrefix: () => P.MonadicParser.regexp(/[0-9:^%/.]/).desc('atom-prefix'), - Chainname: () => P.MonadicParser.regexp(/:([A-Z]{1,3})/, 1).desc('chainname'), - Model: () => P.MonadicParser.regexp(/\/([0-9]+)/, 1).map(Number).desc('model'), - Element: () => P.MonadicParser.regexp(/_([A-Za-z]{1,3})/, 1).desc('element'), - Atomname: () => P.MonadicParser.regexp(/\.([a-zA-Z0-9]{1,4})/, 1).map(B.atomName).desc('atomname'), - Resname: () => P.MonadicParser.regexp(/[A-Z0-9]{1,4}/).desc('resname'), - Resno: (r: any) => r.Integer.desc('resno'), - Altloc: () => P.MonadicParser.regexp(/%([a-zA-Z0-9])/, 1).desc('altloc'), - Inscode: () => P.MonadicParser.regexp(/\^([a-zA-Z0-9])/, 1).desc('inscode'), - - Number: function () { - return P.MonadicParser.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/) - .map(Number) - .desc('number'); - }, - - - ResnoRange: function (r: any) { - return P.MonadicParser.regex(/-?[0-9,-]+/).map(listOrRangeMap).desc('resnorange'); - // // 123-200 - // // -12--3 - }, - - Keywords: () => P.MonadicParser.alt(...h.getKeywordRules(keywords)), - - Query: function (r: any) { - return P.MonadicParser.alt( - r.Operator, - r.Parens, - r.Expression - ).trim(P.MonadicParser.optWhitespace); - } - -}); - -export const transpiler: Transpiler = str => lang.Query.tryParse(str); diff --git a/src/mol-script/transpilers/rasmol/properties.ts b/src/mol-script/transpilers/rasmol/properties.ts deleted file mode 100644 index 37ed627bc..000000000 --- a/src/mol-script/transpilers/rasmol/properties.ts +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> -*/ - -import { MolScriptBuilder } from '../../../mol-script/language/builder'; -const B = MolScriptBuilder; -import { PropertyDict } from '../types'; - -const reFloat = /[-+]?[0-9]*\.?[0-9]+/; -const rePosInt = /[0-9]+/; - -export function sstrucMap(x: string) { - return B.struct.type.secondaryStructureFlags( - [structureDict[x.toUpperCase()] || 'none'] - ); -} - - -export const structureDict: {[key: string]: string} = { - none: 'none', - turn: 'turn', - sheet: 'beta', - helix: 'helix', - dna: 'dna', - rna: 'rna', - - 0: 'none', - 1: 'turn', - 2: 'beta', - 3: 'helix', - 4: 'dna', - 5: 'rna', - 6: 'carbohydrate', - 7: '3-10', - 8: 'alpha', - 9: 'pi', -}; -export function structureMap(x: any) { - if (x.head && x.head === 'core.type.regex') x = x.args[0].replace(/^\^|\$$/g, ''); - x = structureDict[x.toString().toLowerCase()] || 'none'; - if (['dna', 'rna', 'carbohydrate'].indexOf(x) !== -1) { - throw new Error("values 'dna', 'rna', 'carbohydrate' not yet supported for 'structure' property"); - } else { - return B.struct.type.secondaryStructureFlags([x]); - } -} - -export const properties: PropertyDict = { - atomno: { - '@desc': 'sequential number; you can use "@" instead of "atomno=" -- for example, select @33 or Var x = @33 or @35', - '@examples': ['atomno = 10'], - isNumeric: true, - regex: rePosInt, map: x => parseInt(x), - level: 'atom-test', property: B.ammp('id') - }, - atomX: { - '@desc': 'Cartesian X coordinate (or just X)', - '@examples': ['x = 4.2'], - abbr: ['X'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.acp('x') - }, - atomY: { - '@desc': 'Cartesian Y coordinate (or just Y)', - '@examples': ['y < 42'], - abbr: ['Y'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.acp('y') - }, - atomZ: { - '@desc': 'Cartesian Z coordinate (or just Z)', - '@examples': ['Z > 10'], - abbr: ['Z'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.acp('z') - }, - elemno: { - '@desc': 'atomic element number', - '@examples': ['elemno=8'], - isNumeric: true, - regex: /[0-9\s{}-]+/, map: x => parseInt(x), - level: 'atom-test', property: B.acp('atomicNumber') - }, - formalCharge: { - '@desc': 'formal charge', - '@examples': ['formalCharge=1'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.ammp('pdbx_formal_charge') - }, - mass: { - '@desc': 'atomic mass -- especially useful with appended .max or .sum', - '@examples': ['mass > 13'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.acp('mass') - }, - occupancy: { - '@desc': 'CIF file site occupancy. In SELECT command comparisons ("select occupancy < 90"), an integer n implies measurement on a 0-100 scale; also, in the context %[occupancy] or %q for a label, the reported number is a percentage. In all other cases, such as when %Q is used in a label or when a decimal number is used in a comparison, the scale is 0.0 - 1.0.', - '@examples': ['occupancy < 1'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.ammp('occupancy') - }, - resno: { - '@desc': 'PDB residue number, not including insertion code (see also seqcode, below)', - '@examples': ['resno = 100'], - isNumeric: true, - regex: /-?[0-9]+/, map: x => parseInt(x), - level: 'residue-test', property: B.ammp('auth_seq_id') - }, - temperature: { - '@desc': 'yes yes temperature factor (B-factor)', - '@examples': ['temperature >= 20'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.ammp('B_iso_or_equiv') - }, - vanderwaals: { - '@desc': 'van der Waals radius', - '@examples': ['vanderwaals >2'], - isNumeric: true, - regex: reFloat, map: x => parseFloat(x), - level: 'atom-test', property: B.acp('vdw') - }, -}; diff --git a/src/mol-script/transpilers/rasmol/symbols.ts b/src/mol-script/transpilers/rasmol/symbols.ts deleted file mode 100644 index a13dbb288..000000000 --- a/src/mol-script/transpilers/rasmol/symbols.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Koya Sakuma <koya.sakuma.work@gmail.com> -*/ - -import { properties } from './properties'; -import { macroproperties } from './macroproperties'; -import { operators } from './operators'; -import { keywords } from './keywords'; - -export const Properties: string[] = []; -for (const name in properties) { - if (properties[name].isUnsupported) continue; - Properties.push(name); - if (properties[name].abbr) Properties.push(...properties[name].abbr!); -} -for (const name in macroproperties) { - if (macroproperties[name].isUnsupported) continue; - Properties.push(name); - if (macroproperties[name].abbr) Properties.push(...macroproperties[name].abbr!); -} - -export const Operators: string[] = []; -operators.forEach(o => { - if (o.isUnsupported) return; - Operators.push(o.name); - if (o.abbr) Operators.push(...o.abbr); -}); - -export const Keywords: string[] = []; -for (const name in keywords) { - if (!keywords[name].map) continue; - Keywords.push(name); - if (keywords[name].abbr) Keywords.push(...keywords[name].abbr!); -} - -export const _all = { Properties, Operators, Keywords }; -- GitLab