Explorar o código

Added pymol, jmol and vmd alongside mol-script: pymol is now enabled

yakomaxa %!s(int64=2) %!d(string=hai) anos
pai
achega
190c1f9620
Modificáronse 1 ficheiros con 14 adicións e 4 borrados
  1. 14 4
      src/mol-script/script.ts

+ 14 - 4
src/mol-script/script.ts

@@ -4,6 +4,8 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
+import { transpileMolScript } from './script/mol-script/symbols';
+import { parseMolScript } from './language/parser';
 import { parse } from './transpile';
 import { Expression } from './language/expression';
 import { StructureElement, QueryContext, StructureSelection, Structure, QueryFn, QueryContextOptions } from '../mol-model/structure';
@@ -19,7 +21,7 @@ function Script(expression: string, language: Script.Language): Script {
 }
 
 namespace Script {
-    export type Language = 'pymol'
+    export type Language = 'mol-script' | 'pymol' | 'vmd' | 'jmol' 
 
     export function is(x: any): x is Script {
         return !!x && typeof (x as Script).expression === 'string' && !!(x as Script).language;
@@ -31,10 +33,18 @@ namespace Script {
 
     export function toExpression(script: Script): Expression {
         switch (script.language) {
-	case 'pymol':
-	    const parsed = parse("pymol",script.expression);
-	    return parsed as Expression;	   
+	case 'mol-script':
+	    const parsed = parseMolScript(script.expression);
+	    if (parsed.length === 0) throw new Error('No query');
+	    return transpileMolScript(parsed[0]);
+	case 'pymol':	    
+	    return parse("pymol",script.expression) as Expression;	           
+	case 'jmol':
+	    return parse("jmol",script.expression) as Expression;
+	case 'vmd':
+	    return parse("vmd",script.expression) as Expression;	   
         }
+ 
         throw new Error('unsupported script language');
     }