Skip to content
Snippets Groups Projects
Commit ca66e334 authored by David Sehnal's avatar David Sehnal
Browse files

mol-model: added StructureQuery.runExpr

parent 54bba4c9
No related branches found
No related tags found
No related merge requests found
...@@ -15,14 +15,11 @@ import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin/st ...@@ -15,14 +15,11 @@ import { PluginStateObject as PSO, PluginStateObject } from '../../mol-plugin/st
import { AnimateModelIndex } from '../../mol-plugin/state/animation/built-in'; import { AnimateModelIndex } from '../../mol-plugin/state/animation/built-in';
import { StateBuilder, StateTransform } from '../../mol-state'; import { StateBuilder, StateTransform } from '../../mol-state';
import { StripedResidues } from './coloring'; import { StripedResidues } from './coloring';
import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
// import { BasicWrapperControls } from './controls';
import { StaticSuperpositionTestData, buildStaticSuperposition, dynamicSuperpositionTest } from './superposition'; import { StaticSuperpositionTestData, buildStaticSuperposition, dynamicSuperpositionTest } from './superposition';
import { PDBeStructureQualityReport } from '../../mol-plugin/behavior/dynamic/custom-props'; import { PDBeStructureQualityReport } from '../../mol-plugin/behavior/dynamic/custom-props';
import { CustomToastMessage } from './controls'; import { CustomToastMessage } from './controls';
import { EmptyLoci } from '../../mol-model/loci'; import { EmptyLoci } from '../../mol-model/loci';
import { compile } from '../../mol-script/runtime/query/compiler'; import { StructureSelection, StructureQuery } from '../../mol-model/structure';
import { StructureSelection, QueryContext } from '../../mol-model/structure';
require('mol-plugin/skin/light.scss') require('mol-plugin/skin/light.scss')
type SupportedFormats = 'cif' | 'pdb' type SupportedFormats = 'cif' | 'pdb'
...@@ -151,13 +148,11 @@ class BasicWrapper { ...@@ -151,13 +148,11 @@ class BasicWrapper {
interactivity = { interactivity = {
highlightOn: () => { highlightOn: () => {
const seq_id = 7; const seq_id = 7;
const query = compile<StructureSelection>(
MS.struct.generator.atomGroups({
'residue-test': MS.core.rel.eq([MS.struct.atomProperty.macromolecular.label_seq_id(), seq_id]),
'group-by': MS.struct.atomProperty.macromolecular.residueKey()
}));
const data = (this.plugin.state.dataState.select('asm')[0].obj as PluginStateObject.Molecule.Structure).data; const data = (this.plugin.state.dataState.select('asm')[0].obj as PluginStateObject.Molecule.Structure).data;
const sel = query(new QueryContext(data)); const sel = StructureQuery.runExpr(Q => Q.struct.generator.atomGroups({
'residue-test': Q.core.rel.eq([Q.struct.atomProperty.macromolecular.label_seq_id(), seq_id]),
'group-by': Q.struct.atomProperty.macromolecular.residueKey()
}), data);
const loci = StructureSelection.toLociWithSourceUnits(sel); const loci = StructureSelection.toLociWithSourceUnits(sel);
this.plugin.interactivity.lociHighlights.highlightOnly({ loci }); this.plugin.interactivity.lociHighlights.highlightOnly({ loci });
}, },
......
...@@ -7,12 +7,21 @@ ...@@ -7,12 +7,21 @@
import { Structure } from '../structure' import { Structure } from '../structure'
import { StructureSelection } from './selection' import { StructureSelection } from './selection'
import { QueryContext, QueryFn, QueryContextOptions } from './context'; import { QueryContext, QueryFn, QueryContextOptions } from './context';
import Expression from '../../../mol-script/language/expression';
import { compile } from '../../../mol-script/runtime/query/compiler';
import { MolScriptBuilder } from '../../../mol-script/language/builder';
interface StructureQuery extends QueryFn<StructureSelection> { } interface StructureQuery extends QueryFn<StructureSelection> { }
namespace StructureQuery { namespace StructureQuery {
export function run(query: StructureQuery, structure: Structure, options?: QueryContextOptions) { export function run(query: StructureQuery, structure: Structure, options?: QueryContextOptions) {
return query(new QueryContext(structure, options)); return query(new QueryContext(structure, options));
} }
export function runExpr(expr: Expression | ((builder: typeof MolScriptBuilder) => Expression), structure: Structure, options?: QueryContextOptions) {
const e = typeof expr === 'function' ? expr(MolScriptBuilder) : expr;
const query = compile<StructureSelection>(e);
return query(new QueryContext(structure, options));
}
} }
export { StructureQuery } export { StructureQuery }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment