From 4bccb7ab84b4290fe22ecdc11946338eb0968821 Mon Sep 17 00:00:00 2001 From: yakomaxa <47655565+yakomaxa@users.noreply.github.com> Date: Thu, 11 Aug 2022 09:46:15 +0900 Subject: [PATCH] VMD jmol rasmol parser debugged --- src/mol-script/transpilers/jmol/parser.ts | 20 ++++++++++++-------- src/mol-script/transpilers/rasmol/parser.ts | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/mol-script/transpilers/jmol/parser.ts b/src/mol-script/transpilers/jmol/parser.ts index 9d723754d..31e524f73 100644 --- a/src/mol-script/transpilers/jmol/parser.ts +++ b/src/mol-script/transpilers/jmol/parser.ts @@ -35,16 +35,20 @@ const valueOperators: OperatorList = [ map: (op, e1, e2) => { console.log(op, e1, e2) let expr; - if (e1 === 'structure') { + if (e1 === 'structure') { expr = B.core.flags.hasAny([B.ammp('secondaryStructureFlags'), structureMap(e2)]); } else if (e2 === 'structure') { expr = B.core.flags.hasAny([B.ammp('secondaryStructureFlags'), structureMap(e1)]); - } else if (e1.head.name === 'core.type.regex') { - expr = B.core.str.match([e1, B.core.type.str([e2])]); - } else if (e2.head.name === 'core.type.regex') { - expr = B.core.str.match([e2, B.core.type.str([e1])]); + } else if (e1.head !== undefined){ + if (e1.head.name === 'core.type.regex') { + expr = B.core.str.match([e1, B.core.type.str([e2])]); + } + } else if (e2.head !== undefined){ + if (e2.head.name === 'core.type.regex') { + expr = B.core.str.match([e2, B.core.type.str([e1])]); + } } else if (op.toUpperCase() === 'LIKE') { - if (e1.head.name) { + if (e1.head) { expr = B.core.str.match([ B.core.type.regex([`^${e2}$`, 'i']), B.core.type.str([e1]) @@ -57,8 +61,8 @@ const valueOperators: OperatorList = [ } } if (!expr) { - if (e1.head.name) e2 = h.wrapValue(e1, e2); - if (e2.head.name) e1 = h.wrapValue(e2, e1); + if (e1.head) e2 = h.wrapValue(e1, e2); + if (e2.head) e1 = h.wrapValue(e2, e1); switch (op) { case '=': expr = B.core.rel.eq([e1, e2]); diff --git a/src/mol-script/transpilers/rasmol/parser.ts b/src/mol-script/transpilers/rasmol/parser.ts index eb0271d03..ba3ff595d 100644 --- a/src/mol-script/transpilers/rasmol/parser.ts +++ b/src/mol-script/transpilers/rasmol/parser.ts @@ -35,16 +35,20 @@ const valueOperators: OperatorList = [ map: (op, e1, e2) => { // console.log(op, e1, e2) let expr; - if (e1 === 'structure') { + if (e1 === 'structure') { expr = B.core.flags.hasAny([B.ammp('secondaryStructureFlags'), structureMap(e2)]); } else if (e2 === 'structure') { expr = B.core.flags.hasAny([B.ammp('secondaryStructureFlags'), structureMap(e1)]); - } else if (e1.head.name === 'core.type.regex') { - expr = B.core.str.match([e1, B.core.type.str([e2])]); - } else if (e2.head.name === 'core.type.regex') { - expr = B.core.str.match([e2, B.core.type.str([e1])]); + } else if (e1.head !== undefined){ + if (e1.head.name === 'core.type.regex') { + expr = B.core.str.match([e1, B.core.type.str([e2])]); + } + } else if (e2.head !== undefined){ + if (e2.head.name === 'core.type.regex') { + expr = B.core.str.match([e2, B.core.type.str([e1])]); + } } else if (op.toUpperCase() === 'LIKE') { - if (e1.head.name) { + if (e1.head) { expr = B.core.str.match([ B.core.type.regex([`^${e2}$`, 'i']), B.core.type.str([e1]) @@ -57,8 +61,8 @@ const valueOperators: OperatorList = [ } } if (!expr) { - if (e1.head.name) e2 = h.wrapValue(e1, e2); - if (e2.head.name) e1 = h.wrapValue(e2, e1); + if (e1.head) e2 = h.wrapValue(e1, e2); + if (e2.head) e1 = h.wrapValue(e2, e1); switch (op) { case '=': expr = B.core.rel.eq([e1, e2]); -- GitLab