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

proteopedia-wrapper: better HET group focusing

parent 175e0091
No related branches found
No related tags found
No related merge requests found
== v3.2 ==
* Fixed assembly loading.
* Better HET group focus.
== v3.0 == == v3.0 ==
* Fixed initial camera zoom. * Fixed initial camera zoom.
......
...@@ -115,5 +115,6 @@ export enum StateElements { ...@@ -115,5 +115,6 @@ export enum StateElements {
Water = 'water', Water = 'water',
WaterVisual = 'water-visual', WaterVisual = 'water-visual',
HetGroupFocus = 'het-group-focus' HetGroupFocus = 'het-group-focus',
HetGroupFocusGroup = 'het-group-focus-group'
} }
\ No newline at end of file
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
var l = document.createElement('button'); var l = document.createElement('button');
l.innerText = r.name; l.innerText = r.name;
l.onclick = function () { l.onclick = function () {
PluginWrapper.hetGroups.focusFirst(r.name); PluginWrapper.hetGroups.focusFirst(r.name, r.indices[0]);
}; };
div.appendChild(l); div.appendChild(l);
}); });
......
...@@ -29,6 +29,7 @@ import { BuiltInSizeThemes } from '../../mol-theme/size'; ...@@ -29,6 +29,7 @@ import { BuiltInSizeThemes } from '../../mol-theme/size';
import { ColorNames } from '../../mol-util/color/tables'; import { ColorNames } from '../../mol-util/color/tables';
import { InitVolumeStreaming, CreateVolumeStreamingInfo } from '../../mol-plugin/behavior/dynamic/volume-streaming/transformers'; import { InitVolumeStreaming, CreateVolumeStreamingInfo } from '../../mol-plugin/behavior/dynamic/volume-streaming/transformers';
import { ParamDefinition } from '../../mol-util/param-definition'; import { ParamDefinition } from '../../mol-util/param-definition';
import { ResidueIndex } from '../../mol-model/structure';
// import { Vec3 } from 'mol-math/linear-algebra'; // import { Vec3 } from 'mol-math/linear-algebra';
// import { ParamDefinition } from 'mol-util/param-definition'; // import { ParamDefinition } from 'mol-util/param-definition';
// import { Text } from 'mol-geo/geometry/text/text'; // import { Text } from 'mol-geo/geometry/text/text';
...@@ -36,7 +37,7 @@ require('../../mol-plugin/skin/light.scss') ...@@ -36,7 +37,7 @@ require('../../mol-plugin/skin/light.scss')
class MolStarProteopediaWrapper { class MolStarProteopediaWrapper {
static VERSION_MAJOR = 3; static VERSION_MAJOR = 3;
static VERSION_MINOR = 1; static VERSION_MINOR = 2;
private _ev = RxEventHelper.create(); private _ev = RxEventHelper.create();
...@@ -298,30 +299,34 @@ class MolStarProteopediaWrapper { ...@@ -298,30 +299,34 @@ class MolStarProteopediaWrapper {
PluginCommands.State.Update.dispatch(this.plugin, { state: this.state, tree: update }); PluginCommands.State.Update.dispatch(this.plugin, { state: this.state, tree: update });
PluginCommands.Camera.Reset.dispatch(this.plugin, { }); PluginCommands.Camera.Reset.dispatch(this.plugin, { });
}, },
focusFirst: async (resn: string) => { focusFirst: async (resn: string, resIdx: ResidueIndex) => {
if (!this.state.transforms.has(StateElements.Assembly)) return; if (!this.state.transforms.has(StateElements.Assembly)) return;
await PluginCommands.Camera.Reset.dispatch(this.plugin, { });
// const asm = (this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure).data; // const asm = (this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure).data;
const update = this.state.build(); const update = this.state.build();
update.delete(StateElements.HetGroupFocus); update.delete(StateElements.HetGroupFocusGroup);
const surroundings = MS.struct.modifier.includeSurroundings({ const core = MS.struct.filter.first([
0: MS.struct.filter.first([ MS.struct.generator.atomGroups({
MS.struct.generator.atomGroups({ 'residue-test': MS.core.logic.and([
'residue-test': MS.core.rel.eq([MS.struct.atomProperty.macromolecular.label_comp_id(), resn]), MS.core.rel.eq([MS.struct.atomProperty.macromolecular.label_comp_id(), resn]),
'group-by': MS.struct.atomProperty.macromolecular.residueKey() // the resIdx isn't very clear solution and is based on current implementation of residueKey()
}) MS.core.rel.eq([MS.struct.atomProperty.macromolecular.residueKey(), resIdx])
]), ]),
radius: 5, 'group-by': MS.core.str.concat([MS.struct.atomProperty.core.operatorName(), MS.struct.atomProperty.macromolecular.residueKey()])
'as-whole-residues': true })
}); ]);
const surroundings = MS.struct.modifier.includeSurroundings({ 0: core, radius: 5, 'as-whole-residues': true });
const sel = update.to(StateElements.Assembly)
.apply(StateTransforms.Model.StructureSelection, { label: resn, query: surroundings }, { ref: StateElements.HetGroupFocus }); const group = update.to(StateElements.Assembly).group(StateTransforms.Misc.CreateGroup, { label: resn }, { ref: StateElements.HetGroupFocusGroup });
sel.apply(StateTransforms.Representation.StructureRepresentation3D, this.createSurVisualParams()); group.apply(StateTransforms.Model.StructureSelection, { label: 'Core', query: core }, { ref: StateElements.HetGroupFocus })
.apply(StateTransforms.Representation.StructureRepresentation3D, this.createCoreVisualParams());
group.apply(StateTransforms.Model.StructureSelection, { label: 'Surroundings', query: surroundings })
.apply(StateTransforms.Representation.StructureRepresentation3D, this.createSurVisualParams());
// sel.apply(StateTransforms.Representation.StructureLabels3D, { // sel.apply(StateTransforms.Representation.StructureLabels3D, {
// target: { name: 'residues', params: { } }, // target: { name: 'residues', params: { } },
// options: { // options: {
...@@ -341,7 +346,7 @@ class MolStarProteopediaWrapper { ...@@ -341,7 +346,7 @@ class MolStarProteopediaWrapper {
// const position = Vec3.sub(Vec3.zero(), sphere.center, asmCenter); // const position = Vec3.sub(Vec3.zero(), sphere.center, asmCenter);
// Vec3.normalize(position, position); // Vec3.normalize(position, position);
// Vec3.scaleAndAdd(position, sphere.center, position, sphere.radius); // Vec3.scaleAndAdd(position, sphere.center, position, sphere.radius);
const snapshot = this.plugin.canvas3d.camera.getFocus(sphere.center, 0.75 * sphere.radius); const snapshot = this.plugin.canvas3d.camera.getFocus(sphere.center, Math.max(sphere.radius, 5));
PluginCommands.Camera.SetSnapshot.dispatch(this.plugin, { snapshot, durationMs: 250 }); PluginCommands.Camera.SetSnapshot.dispatch(this.plugin, { snapshot, durationMs: 250 });
} }
} }
...@@ -355,6 +360,15 @@ class MolStarProteopediaWrapper { ...@@ -355,6 +360,15 @@ class MolStarProteopediaWrapper {
}); });
} }
private createCoreVisualParams() {
const asm = this.state.select(StateElements.Assembly)[0].obj as PluginStateObject.Molecule.Structure;
return StructureRepresentation3DHelpers.createParams(this.plugin, asm.data, {
repr: BuiltInStructureRepresentations['ball-and-stick'],
// color: [BuiltInColorThemes.uniform, () => ({ value: ColorNames.gray })],
// size: [BuiltInSizeThemes.uniform, () => ({ value: 0.33 } )]
});
}
snapshot = { snapshot = {
get: () => { get: () => {
return this.plugin.state.getSnapshot(); return this.plugin.state.getSnapshot();
......
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