Skip to content
Snippets Groups Projects
Commit 190c1f96 authored by yakomaxa's avatar yakomaxa
Browse files

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

parent 2ccfdb12
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
*/ */
import { transpileMolScript } from './script/mol-script/symbols';
import { parseMolScript } from './language/parser';
import { parse } from './transpile'; import { parse } from './transpile';
import { Expression } from './language/expression'; import { Expression } from './language/expression';
import { StructureElement, QueryContext, StructureSelection, Structure, QueryFn, QueryContextOptions } from '../mol-model/structure'; import { StructureElement, QueryContext, StructureSelection, Structure, QueryFn, QueryContextOptions } from '../mol-model/structure';
...@@ -19,7 +21,7 @@ function Script(expression: string, language: Script.Language): Script { ...@@ -19,7 +21,7 @@ function Script(expression: string, language: Script.Language): Script {
} }
namespace Script { namespace Script {
export type Language = 'pymol' export type Language = 'mol-script' | 'pymol' | 'vmd' | 'jmol'
export function is(x: any): x is Script { export function is(x: any): x is Script {
return !!x && typeof (x as Script).expression === 'string' && !!(x as Script).language; return !!x && typeof (x as Script).expression === 'string' && !!(x as Script).language;
...@@ -31,10 +33,18 @@ namespace Script { ...@@ -31,10 +33,18 @@ namespace Script {
export function toExpression(script: Script): Expression { export function toExpression(script: Script): Expression {
switch (script.language) { switch (script.language) {
case 'pymol': case 'mol-script':
const parsed = parse("pymol",script.expression); const parsed = parseMolScript(script.expression);
return parsed as 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'); throw new Error('unsupported script language');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment