|
@@ -93,136 +93,46 @@ export class TmViewerStandalone extends Viewer {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- async setChainColorOLD(labelAsymId: string) {
|
|
|
|
-
|
|
|
|
- const state = this.plugin.state.data;
|
|
|
|
-
|
|
|
|
- const selected = state.selectQ(q => q.ofTransformer(StateTransforms.Model.StructureFromModel));
|
|
|
|
- //const str = this.plugin.managers.structure.hierarchy.current.structures[0];
|
|
|
|
- if (selected.length == 0) {
|
|
|
|
- console.log('Structure not found');
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- let structure = selected[0];
|
|
|
|
- console.log('STRUCT1', structure);
|
|
|
|
- structure = this.plugin.managers.structure.hierarchy.current.models[0].structures[0].cell;
|
|
|
|
- console.log('STRUCT2', structure);
|
|
|
|
-
|
|
|
|
- // const update = this.plugin.build().to(structure); //state.build().to(structure);
|
|
|
|
- const query: Expression =
|
|
|
|
- MolScriptBuilder.struct.generator.atomGroups({
|
|
|
|
- 'chain-test': MolScriptBuilder.core.rel.eq([labelAsymId, MolScriptBuilder.ammp('label_asym_id')])
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- const s = await this.plugin.build()
|
|
|
|
- .to(this.plugin.managers.structure.hierarchy.current.structures[0].cell)
|
|
|
|
- .apply(StateTransforms.Model.StructureSelectionFromExpression, { expression: query }).commit();
|
|
|
|
- // const rangeSel = Script.getStructureSelection(Q => Q.struct.modifier.union([
|
|
|
|
- // Q.struct.generator.atomGroups({
|
|
|
|
- // // I am not sure this test will be enough, or uses the correct property, but something along these lines should do it
|
|
|
|
- // 'chain-test': Q.core.rel.eq([Q.struct.atomProperty.macromolecular.label_asym_id(), 'A']),
|
|
|
|
- // })
|
|
|
|
- // ]), );
|
|
|
|
- const compiledQuery = compile<StructureSelection>(query);
|
|
|
|
- const xs = this.plugin.managers.structure.hierarchy.current.structures;
|
|
|
|
- const selections = xs.map(s => StructureSelection.toLociWithCurrentUnits(compiledQuery(new QueryContext(s.cell.obj!.data))));
|
|
|
|
-
|
|
|
|
- console.log(selections);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- const component = await this.plugin.builders.structure.tryCreateComponentFromExpression(structure, query, 'hello', { label: 'CHAIN-A' });
|
|
|
|
- console.log(component);
|
|
|
|
- // const update = this.plugin.build().to(component!.cell!);
|
|
|
|
- // update //.apply(StateTransforms.Model.StructureSelectionFromExpression, { label: 'CHAIN-A', expression: query })
|
|
|
|
- // .apply(StateTransforms.Representation.StructureRepresentation3D, createStructureRepresentationParams(this.plugin, update.selector.data,
|
|
|
|
- // { type: 'cartoon', typeParams: { alpha: 1 },
|
|
|
|
- // color: 'uniform', colorParams: { value: Color.fromArray([255,0,0], 0) } }))
|
|
|
|
- // const result = await update.commit();
|
|
|
|
- // console.log('Result:', result);
|
|
|
|
-
|
|
|
|
- console.log('Component Group:', this.plugin.managers.structure.hierarchy.currentComponentGroups);
|
|
|
|
- // await this.plugin.builders.structure.representation.addRepresentation(structure, {
|
|
|
|
- // type: 'cartoon',
|
|
|
|
- // color: 'uniform',
|
|
|
|
- // colorParams: {value: 0xd3d3d3}, // gray80
|
|
|
|
- // typeParams: {detail: 1}
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
- // TODO: const structureData = component!.cell!.obj!.data;
|
|
|
|
-
|
|
|
|
- //setStructureOverpaint(this.plugin, [ structure!.obj!.data ], Color.fromRgb(255, 0, 0), this.lociGetter, undefined);
|
|
|
|
- // console.log(component);
|
|
|
|
- console.log('component cell', component!.cell!);
|
|
|
|
- const structRef = this.plugin.managers.structure.hierarchy.current.refs;
|
|
|
|
- let comps: any[] = [];
|
|
|
|
-
|
|
|
|
- // const bundle = StructureElement.Bundle.fromLoci(selections[0]);
|
|
|
|
- // await this.plugin.build().to(component!.cell!)
|
|
|
|
- // .apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript,
|
|
|
|
- // {
|
|
|
|
- // layers: [{
|
|
|
|
- // script: query,
|
|
|
|
- // color: Color.fromRgb(255, 0, 0),
|
|
|
|
- // clear: false
|
|
|
|
- // }]
|
|
|
|
- // })
|
|
|
|
- // .commit();
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- this.plugin.managers.structure.component.currentStructures.forEach(val => comps = comps.concat(...val.components));
|
|
|
|
-setStructureOverpaint(this.plugin, comps, Color.fromRgb(255, 0, 0), this.lociGetter, undefined);
|
|
|
|
- console.log('Components', comps);
|
|
|
|
- // console.log('component ref', this.plugin.managers.structure.component.;
|
|
|
|
|
|
+ setChainColor(labelAsymIds: string[], hexRgb: string|false = false) {
|
|
|
|
+ this.overPaint(labelAsymIds, hexRgb, false);
|
|
}
|
|
}
|
|
|
|
|
|
- async setChainColor(labelAsymId: string) {
|
|
|
|
|
|
+ resetChainColor(labelAsymIds: string[]) {
|
|
|
|
+ this.overPaint(labelAsymIds, false, true);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Util function to handle overpaint logic.
|
|
|
|
+ * @param labelAsymId
|
|
|
|
+ * @param hexRgb default color grey, when it is false
|
|
|
|
+ * @param clear if true, it clears the overpaint color
|
|
|
|
+ */
|
|
|
|
+ protected overPaint(labelAsymIds: string[], hexRgb: string|false = false, clear: boolean = false) {
|
|
const state = this.plugin.state.data;
|
|
const state = this.plugin.state.data;
|
|
|
|
|
|
- const selected = state.selectQ(q => q.ofTransformer(StateTransforms.Model.StructureFromModel));
|
|
|
|
- //const str = this.plugin.managers.structure.hierarchy.current.structures[0];
|
|
|
|
|
|
+ const selected = state.selectQ(q => q.ofTransformer(StateTransforms.Representation.StructureRepresentation3D));
|
|
if (selected.length == 0) {
|
|
if (selected.length == 0) {
|
|
- console.log('Structure not found');
|
|
|
|
|
|
+ console.log('Representation not found');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- const query: Expression =
|
|
|
|
- MolScriptBuilder.struct.generator.atomGroups({
|
|
|
|
- 'chain-test': MolScriptBuilder.core.rel.eq([labelAsymId, MolScriptBuilder.ammp('label_asym_id')])
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // const update = this.plugin.build().to(structure)
|
|
|
|
- const update = this.plugin.build().to(Array.from(state.cells.values())[13]);
|
|
|
|
- update //.apply(StateTransforms.Model.StructureSelectionFromExpression, { label: 'CHAIN-A', expression: query })
|
|
|
|
- // .apply(StateTransforms.Representation.StructureRepresentation3D, createStructureRepresentationParams(this.plugin, update.selector.data,
|
|
|
|
- // { type: 'cartoon', typeParams: { alpha: 1 },
|
|
|
|
- // color: 'uniform', colorParams: { value: Color.fromArray([255,0,0], 0) } }))
|
|
|
|
- .apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript, {
|
|
|
|
|
|
+ const chainList = labelAsymIds.join(' ');
|
|
|
|
+ selected.forEach(async (representation) => {
|
|
|
|
+ const update = this.plugin.build().to(representation);
|
|
|
|
+ update.apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript, {
|
|
layers: [
|
|
layers: [
|
|
{
|
|
{
|
|
script: Script(
|
|
script: Script(
|
|
- `(sel.atom.res (in-range atom.resno 10 100))`,
|
|
|
|
|
|
+ `(sel.atom.atom-groups :chain-test (set.has (set ${chainList}) atom.label_asym_id))`,
|
|
'mol-script'
|
|
'mol-script'
|
|
),
|
|
),
|
|
- color: ColorNames.red,
|
|
|
|
- clear: false
|
|
|
|
-
|
|
|
|
|
|
+ color: hexRgb !== false ? Color.fromHexString(hexRgb) : ColorNames.grey,
|
|
|
|
+ clear: clear
|
|
}
|
|
}
|
|
]
|
|
]
|
|
});
|
|
});
|
|
- const result = await update.commit();
|
|
|
|
- console.log('Result:', result);
|
|
|
|
-
|
|
|
|
- // await this.plugin.build().to(component!.cell!)
|
|
|
|
- // .apply(StateTransforms.Representation.OverpaintStructureRepresentation3DFromScript,
|
|
|
|
- // {
|
|
|
|
- // layers: [{
|
|
|
|
- // script: query,
|
|
|
|
- // color: Color.fromRgb(255, 0, 0),
|
|
|
|
- // clear: false
|
|
|
|
- // }]
|
|
|
|
- // })
|
|
|
|
- // .commit();
|
|
|
|
|
|
+ await update.commit();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
async loadWithUNITMPMembraneRepresentation(params: any) {
|
|
async loadWithUNITMPMembraneRepresentation(params: any) {
|