|
@@ -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 {
|
|
}
|
|
}
|
|
|
|
|
|
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 {
|
|
|
|
|
|
export function toExpression(script: Script): Expression {
|
|
export function toExpression(script: Script): Expression {
|
|
switch (script.language) {
|
|
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');
|
|
throw new Error('unsupported script language');
|
|
}
|
|
}
|
|
|
|
|