فهرست منبع

VMD jmol and rasmol parser updated

yakomaxa 2 سال پیش
والد
کامیت
9943e0317d

+ 1 - 1
src/mol-plugin-state/transforms/model.ts

@@ -786,7 +786,7 @@ const StructureSelectionFromScript = PluginStateTransform.BuiltIn({
     from: SO.Molecule.Structure,
     to: SO.Molecule.Structure,
     params: () => ({
-        script: PD.Script({ language: 'rasmol', expression: 'all' }),
+        script: PD.Script({ language: 'vmd', expression: 'all' }),
         label: PD.Optional(PD.Text(''))
     })
 })({

+ 8 - 8
src/mol-script/transpilers/jmol/parser.ts

@@ -33,18 +33,18 @@ const valueOperators: OperatorList = [
         type: h.binaryLeft,
         rule: P.MonadicParser.regexp(/\s*(LIKE|>=|<=|=|!=|>|<)\s*/i, 1),
         map: (op, e1, e2) => {
-            // console.log(op, e1, e2)
+            console.log(op, e1, e2)
             let expr;
             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 === 'core.type.regex') {
+            } else if (e1.head.name === 'core.type.regex') {
                 expr = B.core.str.match([e1, B.core.type.str([e2])]);
-            } else if (e2.head === 'core.type.regex') {
+            } else 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) {
+                if (e1.head.name) {
                     expr = B.core.str.match([
                         B.core.type.regex([`^${e2}$`, 'i']),
                         B.core.type.str([e1])
@@ -57,8 +57,8 @@ const valueOperators: OperatorList = [
                 }
             }
             if (!expr) {
-                if (e1.head) e2 = h.wrapValue(e1, e2);
-                if (e2.head) e1 = h.wrapValue(e2, e1);
+                if (e1.head.name) e2 = h.wrapValue(e1, e2);
+                if (e2.head.name) e1 = h.wrapValue(e2, e1);
                 switch (op) {
                     case '=':
                         expr = B.core.rel.eq([e1, e2]);
@@ -237,8 +237,8 @@ const lang = P.MonadicParser.createLanguage({
     ValueQuery: function (r: any) {
         return P.MonadicParser.alt(
             r.ValueOperator.map((x: any) => {
-                if (x.head) {
-                    if (x.head.startsWith('structure-query.generator')) return x;
+                if (x.head.name) {
+                    if (x.head.name.startsWith('structure-query.generator')) return x;
                 } else {
                     if (typeof x === 'string' && x.length <= 4) {
                         return B.struct.generator.atomGroups({

+ 7 - 7
src/mol-script/transpilers/rasmol/parser.ts

@@ -39,12 +39,12 @@ const valueOperators: OperatorList = [
                 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 === 'core.type.regex') {
+            } else if (e1.head.name === 'core.type.regex') {
                 expr = B.core.str.match([e1, B.core.type.str([e2])]);
-            } else if (e2.head === 'core.type.regex') {
+            } else 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) {
+                if (e1.head.name) {
                     expr = B.core.str.match([
                         B.core.type.regex([`^${e2}$`, 'i']),
                         B.core.type.str([e1])
@@ -57,8 +57,8 @@ const valueOperators: OperatorList = [
                 }
             }
             if (!expr) {
-                if (e1.head) e2 = h.wrapValue(e1, e2);
-                if (e2.head) e1 = h.wrapValue(e2, e1);
+                if (e1.head.name) e2 = h.wrapValue(e1, e2);
+                if (e2.head.name) e1 = h.wrapValue(e2, e1);
                 switch (op) {
                     case '=':
                         expr = B.core.rel.eq([e1, e2]);
@@ -245,8 +245,8 @@ const lang = P.MonadicParser.createLanguage({
     ValueQuery: function (r: any) {
         return P.MonadicParser.alt(
             r.ValueOperator.map((x: any) => {
-                if (x.head) {
-                    if (x.head.startsWith('structure-query.generator')) return x;
+                if (x.head.name) {
+                    if (x.head.name.startsWith('structure-query.generator')) return x;
                 } else {
                     if (typeof x === 'string' && x.length <= 4) {
                         return B.struct.generator.atomGroups({

+ 8 - 8
src/mol-script/transpilers/vmd/parser.ts

@@ -59,16 +59,16 @@ const valueOperators: OperatorList = [
         map: (op, e1, e2) => {
             // console.log(op, e1, e2)
             let expr;
-            if (e1.head === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
+            if (e1.head.name === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
                 expr = B.core.flags.hasAny([e1, sstrucMap(e2)]);
-            } else if (e2.head === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
+            } else if (e2.head.name === 'structure-query.atom-property.macromolecular.secondary-structure-flags') {
                 expr = B.core.flags.hasAny([e2, sstrucMap(e1)]);
-            } else if (e1.head === 'core.type.regex') {
+            } else if (e1.head.name === 'core.type.regex') {
                 expr = B.core.str.match([e1, B.core.type.str([e2])]);
-            } else if (e2.head === 'core.type.regex') {
+            } else if (e2.head.name === 'core.type.regex') {
                 expr = B.core.str.match([e2, B.core.type.str([e1])]);
             } else if (op === '=~') {
-                if (e1.head) {
+                if (e1.head.name) {
                     expr = B.core.str.match([
                         B.core.type.regex([`^${e2}$`, 'i']),
                         B.core.type.str([e1])
@@ -81,8 +81,8 @@ const valueOperators: OperatorList = [
                 }
             }
             if (!expr) {
-                if (e1.head) e2 = h.wrapValue(e1, e2);
-                if (e2.head) e1 = h.wrapValue(e2, e1);
+                if (e1.head.name) e2 = h.wrapValue(e1, e2);
+                if (e2.head.name) e1 = h.wrapValue(e2, e1);
                 switch (op) {
                     case '=':
                     case '==':
@@ -247,7 +247,7 @@ const lang = P.MonadicParser.createLanguage({
         return P.MonadicParser.alt(
             r.ValueOperator.map((x: any) => {
                 // if (!x.head || x.head.startsWith('core.math') || x.head.startsWith('structure-query.atom-property')) {
-                if (!x.head || !x.head.startsWith('structure-query.generator')) {
+                if (!x.head.name || !x.head.name.startsWith('structure-query.generator')) {
                     throw new Error(`values must be part of an comparison, value '${x}'`);
                 } else {
                     return x as any;