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

better jolecule import; tweak in dynamic interaction

parent 65e2240b
No related branches found
No related tags found
No related merge requests found
...@@ -59,20 +59,20 @@ function createTemplate(plugin: PluginContext, tree: StateTree, id: string) { ...@@ -59,20 +59,20 @@ function createTemplate(plugin: PluginContext, tree: StateTree, id: string) {
const b = new StateBuilder.Root(tree); const b = new StateBuilder.Root(tree);
const data = b.toRoot().apply(StateTransforms.Data.Download, { url: `https://www.ebi.ac.uk/pdbe/static/entry/${id}_updated.cif` }, { props: { isGhost: true }}); const data = b.toRoot().apply(StateTransforms.Data.Download, { url: `https://www.ebi.ac.uk/pdbe/static/entry/${id}_updated.cif` }, { props: { isGhost: true }});
const model = createModelTree(data, 'cif'); const model = createModelTree(data, 'cif');
const structure = model.apply(StateTransforms.Model.StructureFromModel, {}, { ref: 'structure' }); const structure = model.apply(StateTransforms.Model.StructureFromModel, {});
complexRepresentation(plugin, structure, { hideWater: true }); complexRepresentation(plugin, structure, { hideWater: true });
return b.getTree(); return { tree: b.getTree(), structure: structure.ref };
} }
const labelOptions = { const labelOptions: ParamDefinition.Values<Text.Params> = {
...ParamDefinition.getDefaultValues(Text.Params), ...ParamDefinition.getDefaultValues(Text.Params),
sizeFactor: 1.5, tether: true,
offsetX: 1, sizeFactor: 1.3,
offsetY: 1, attachment: 'bottom-right',
offsetZ: 10, offsetZ: 10,
background: true, background: true,
backgroundMargin: 0.2, backgroundMargin: 0.2,
backgroundColor: ColorNames.snow, backgroundColor: ColorNames.skyblue,
backgroundOpacity: 0.9 backgroundOpacity: 0.9
} }
...@@ -88,20 +88,29 @@ const labelOptions = { ...@@ -88,20 +88,29 @@ const labelOptions = {
// backgroundOpacity: 0.9 // backgroundOpacity: 0.9
// } // }
function buildSnapshot(plugin: PluginContext, template: StateTree, params: { e: JoleculeSnapshot, idx: number, len: number }): PluginStateSnapshotManager.Entry { function buildSnapshot(plugin: PluginContext, template: { tree: StateTree, structure: string }, params: { e: JoleculeSnapshot, idx: number, len: number }): PluginStateSnapshotManager.Entry {
const b = new StateBuilder.Root(template); const b = new StateBuilder.Root(template.tree);
let i = 0; let i = 0;
for (const l of params.e.labels) { for (const l of params.e.labels) {
b.to('structure') const query = createQuery([l.i_atom]);
.apply(StateTransforms.Model.StructureSelection, { query: createQuery([l.i_atom]), label: `Label ${++i}` }) const group = b.to(template.structure)
.group(StateTransforms.Misc.CreateGroup, { label: `Label ${++i}` });
group
.apply(StateTransforms.Model.StructureSelection, { query, label: 'Atom' })
.apply(StateTransforms.Representation.StructureLabels3D, { .apply(StateTransforms.Representation.StructureLabels3D, {
target: { name: 'static-text', params: { value: l.text || '' } }, target: { name: 'static-text', params: { value: l.text || '' } },
options: labelOptions options: labelOptions
}); });
group
.apply(StateTransforms.Model.StructureSelection, { query: MS.struct.modifier.wholeResidues([query]), label: 'Residue' })
.apply(StateTransforms.Representation.StructureRepresentation3D,
StructureRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'ball-and-stick', { }));
} }
if (params.e.selected && params.e.selected.length > 0) { if (params.e.selected && params.e.selected.length > 0) {
b.to('structure') b.to(template.structure)
.apply(StateTransforms.Model.StructureSelection, { query: createQuery(params.e.selected), label: `Selected` }) .apply(StateTransforms.Model.StructureSelection, { query: createQuery(params.e.selected), label: `Selected` })
.apply(StateTransforms.Representation.StructureRepresentation3D, .apply(StateTransforms.Representation.StructureRepresentation3D,
StructureRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'ball-and-stick')); StructureRepresentation3DHelpers.getDefaultParamsStatic(plugin, 'ball-and-stick'));
......
...@@ -149,15 +149,21 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W ...@@ -149,15 +149,21 @@ export class StructureRepresentationInteractionBehavior extends PluginBehavior.W
StructureElement.Loci.toScriptExpression(current.loci) StructureElement.Loci.toScriptExpression(current.loci)
]); ]);
const surroundings = MS.struct.modifier.exceptBy({ const surroundings = MS.struct.modifier.includeSurroundings({
0: MS.struct.modifier.includeSurroundings({ 0: core,
0: core, radius: 5,
radius: 5, 'as-whole-residues': true
'as-whole-residues': true
}),
by: core
}); });
// const surroundings = MS.struct.modifier.exceptBy({
// 0: MS.struct.modifier.includeSurroundings({
// 0: core,
// radius: 5,
// 'as-whole-residues': true
// }),
// by: core
// });
const { state, builder, refs } = this.ensureShape(parent); const { state, builder, refs } = this.ensureShape(parent);
builder.to(refs[Tags.ResidueSel]!).update(StateTransforms.Model.StructureSelection, old => ({ ...old, query: core })); builder.to(refs[Tags.ResidueSel]!).update(StateTransforms.Model.StructureSelection, old => ({ ...old, query: core }));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment