From b508da5cccb0ff3b2efdff7784c0d6a69a42cd92 Mon Sep 17 00:00:00 2001 From: yakomaxa <47655565+yakomaxa@users.noreply.github.com> Date: Sun, 14 Aug 2022 11:06:24 +0900 Subject: [PATCH] cleaning by lint --- .../transpilers/pymol/properties.ts | 26 +++--- src/mol-script/transpilers/rasmol/keywords.ts | 10 +-- src/mol-script/transpilers/rasmol/parser.ts | 89 ++++++++++--------- .../transpilers/rasmol/properties.ts | 2 +- .../transpilers/rasmol/special_properties.ts | 48 +++++----- 5 files changed, 88 insertions(+), 87 deletions(-) diff --git a/src/mol-script/transpilers/pymol/properties.ts b/src/mol-script/transpilers/pymol/properties.ts index f47175871..715abe478 100644 --- a/src/mol-script/transpilers/pymol/properties.ts +++ b/src/mol-script/transpilers/pymol/properties.ts @@ -19,26 +19,26 @@ function rangeMap(x: string) { 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('-')){ + 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 (var i = min; i <= max; i++){ + for (let i = min; i <= max; i++) { res.push(i); } - }else{ + } 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 listMap(x).map(x => parseInt(x)) + } else if (x.includes('-') && !x.includes('+')) { + return rangeMap(x); + } else if (!x.includes('-') && x.includes('+')) { + return listMap(x).map(x => parseInt(x)); + } else { + return listMap(x).map(x => parseInt(x)); } } diff --git a/src/mol-script/transpilers/rasmol/keywords.ts b/src/mol-script/transpilers/rasmol/keywords.ts index f56341c44..e0c79de31 100644 --- a/src/mol-script/transpilers/rasmol/keywords.ts +++ b/src/mol-script/transpilers/rasmol/keywords.ts @@ -20,7 +20,7 @@ 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.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') ]) }), @@ -29,11 +29,11 @@ function nucleicExpr() { 'group-by': B.ammp('residueKey') }), test: B.core.logic.and([ - B.core.set.isSubset([ + B.core.set.isSubset([ // B.core.type.set([ 'P', 'O1P', 'O2P' ]), - h.atomNameSet(['P']), - B.ammpSet('label_atom_id') - ]), + h.atomNameSet(['P']), + B.ammpSet('label_atom_id') + ]), ]) }), B.struct.filter.pick({ diff --git a/src/mol-script/transpilers/rasmol/parser.ts b/src/mol-script/transpilers/rasmol/parser.ts index deaa15ebd..dfa12686e 100644 --- a/src/mol-script/transpilers/rasmol/parser.ts +++ b/src/mol-script/transpilers/rasmol/parser.ts @@ -19,7 +19,7 @@ import { operators } from './operators'; import { keywords } from './keywords'; import { AtomGroupArgs } from '../types'; import { Transpiler } from '../transpiler'; -//import { OperatorList } from '../types'; +// import { OperatorList } from '../types'; // const propertiesDict = h.getPropertyRules(properties); @@ -27,10 +27,10 @@ import { Transpiler } from '../transpiler'; const propertiesDict = h.getPropertyRules(special_properties); -//const slash = P.MonadicParser.string('/'); +// const slash = P.MonadicParser.string('/'); const dot = P.MonadicParser.string('.'); const colon = P.MonadicParser.string(':'); -//const comma = P.MonadicParser.string(','); +// const comma = P.MonadicParser.string(','); const star = P.MonadicParser.string('*'); const bra = P.MonadicParser.string('('); const ket = P.MonadicParser.string(')'); @@ -97,87 +97,88 @@ const lang = P.MonadicParser.createLanguage({ return P.MonadicParser.alt( // :A.CA :.CA :A colon.then(P.MonadicParser.alt( - P.MonadicParser.seq( + P.MonadicParser.seq( orNull(propertiesDict.chain).skip(dot), orNull(propertiesDict.name) - ).map(x => { return { chain: x[0], name: x[1]}; }), + ).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( + ).map(x => { return { name: x[0] }; }), + P.MonadicParser.seq( orNull(propertiesDict.chain) - ).map(x => { return {chain: x[0] }; }), + ).map(x => { return { chain: x[0] }; }), )), // *A.CA *.CA star.then(P.MonadicParser.alt( - P.MonadicParser.seq( + P.MonadicParser.seq( orNull(propertiesDict.chain).skip(dot), orNull(propertiesDict.name) - ).map(x => { return { chain: x[0], name: x[1]}; }), + ).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( + ).map(x => { return { name: x[0] }; }), + P.MonadicParser.seq( orNull(propertiesDict.chain) - ).map(x => { return {chain: x[0] }; }), + ).map(x => { return { chain: x[0] }; }), )), // 1-100,201 bra.then(P.MonadicParser.alt( - P.MonadicParser.alt( + P.MonadicParser.alt( P.MonadicParser.seq( - propertiesDict.resi.skip(ket), + propertiesDict.resi.skip(ket), ).map(x => { - return { resi: x[0] } - ;}) - ) + return { resi: x[0] } + ; + }) + ) )), // lys:a.ca lys:a lys lys.ca P.MonadicParser.alt( - P.MonadicParser.alt( + P.MonadicParser.alt( P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(colon), - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) + orNull(propertiesDict.resn).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(star), - orNull(propertiesDict.chain).skip(dot), - orNull(propertiesDict.name) + orNull(propertiesDict.resn).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(colon), - orNull(propertiesDict.chain), + orNull(propertiesDict.resn).skip(colon), + orNull(propertiesDict.chain), ).map(x => { return { resn: x[0], chain: x[1] }; }), P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(star), - orNull(propertiesDict.chain), + orNull(propertiesDict.resn).skip(star), + orNull(propertiesDict.chain), ).map(x => { return { resn: x[0], chain: x[1] }; }), P.MonadicParser.seq( - orNull(propertiesDict.resn).skip(dot), - orNull(propertiesDict.name), + orNull(propertiesDict.resn).skip(dot), + orNull(propertiesDict.name), ).map(x => { return { resn: x[0], name: x[1] }; }), P.MonadicParser.seq( - orNull(propertiesDict.resn), - ).map(x => { return { resn: x[0] };}), - ) - ) - - ) - + orNull(propertiesDict.resn), + ).map(x => { return { resn: x[0] }; }), + ) + ) + + ); + }, ObjectProperty: () => { - const w = h.getReservedWords(special_properties, special_keywords, special_operators) - .sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); + const w = h.getReservedWords(special_properties, special_keywords, special_operators) + .sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); return P.MonadicParser.regexp(new RegExp(`(?!(${w}))[A-Z0-9_]+`, 'i')); }, ObjectProperty2: () => { - const w = h.getReservedWords(properties, keywords, operators) - .sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); + 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')); }, - + Object: (r: any) => { return r.ObjectProperty2 .map((x: any) => { throw new Error(`property 'object' not supported, value '${x}'`); }); @@ -201,7 +202,7 @@ const lang = P.MonadicParser.createLanguage({ 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 index d152c3a6b..71543e4ee 100644 --- a/src/mol-script/transpilers/rasmol/properties.ts +++ b/src/mol-script/transpilers/rasmol/properties.ts @@ -456,7 +456,7 @@ export const properties: PropertyDict = { hoge: { '@desc': 'PDB residue number, not including insertion code (see also seqcode, below)', '@examples': ['resno = 100'], -// isNumeric: true, + // isNumeric: true, regex: /-?[0-9]+/, map: x => parseInt(x), level: 'residue-test', property: B.ammp('auth_seq_id') diff --git a/src/mol-script/transpilers/rasmol/special_properties.ts b/src/mol-script/transpilers/rasmol/special_properties.ts index 84dcd04b4..b577218b2 100644 --- a/src/mol-script/transpilers/rasmol/special_properties.ts +++ b/src/mol-script/transpilers/rasmol/special_properties.ts @@ -9,7 +9,7 @@ import { MolScriptBuilder } from '../../../mol-script/language/builder'; const B = MolScriptBuilder; import { PropertyDict } from '../types'; -//const reFloat = /[-+]?[0-9]*\.?[0-9]+/; +// const reFloat = /[-+]?[0-9]*\.?[0-9]+/; // const rePosInt = /[0-9]+/; function atomNameListMap(x: string) { return x.split(',').map(B.atomName); } @@ -19,45 +19,45 @@ function rangeMap(x: string) { return { min, max }; } function listOrRangeMap(x: string) { - if (x.includes('-') && x.includes(',')){ - const pSplit = x.split(',').map(x => x.replace(/^["']|["']$/g, '')); - console.log(pSplit) - const res : number[] =[]; - pSplit.forEach( x => { - if (x.includes('-')){ - const [min, max] = x.split('-').map(x=>parseInt(x)); - for (var i = min; i <= max; i++){ + if (x.includes('-') && x.includes(',')) { + const pSplit = x.split(',').map(x => x.replace(/^["']|["']$/g, '')); + console.log(pSplit); + 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)); + } + } 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); + }); + 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); } -//const sstrucDict: { [k: string]: string } = { +// const sstrucDict: { [k: string]: string } = { // H: 'helix', // S: 'beta', // L: 'none' -//}; -//function sstrucListMap(x: string) { +// }; +// function sstrucListMap(x: string) { // return { // flags: B.struct.type.secondaryStructureFlags( // x.toUpperCase().split('+').map(ss => sstrucDict[ss] || 'none') // ) // }; -//} +// } export const special_properties: PropertyDict = { symbol: { -- GitLab