Open ap-jain opened 9 months ago
Hi. There is no option to achieve this directly. But you can add this code which changes the color theme for polymer component once the structure is loaded:
function colorPolymerBySecStr() {
const cells = Array.from(viewerInstance.plugin.state.data.cells.values());
const polymerComponents = cells.filter(c => c.transform.tags?.includes('structure-component-static-polymer'));
for (const component of polymerComponents) {
const polymerRepresentations = viewerInstance.plugin.state.data.tree.children.get(component.transform.ref);
for (const repr of polymerRepresentations) {
viewerInstance.plugin.build().to(repr).update({ colorTheme: { name: 'secondary-structure', params: {} } }).commit();
}
}
}
viewerInstance.events.loadComplete.subscribe(colorPolymerBySecStr);
You could also apply the color theme to all representations:
const representations = cells.filter(c => c.transform.transformer.id === 'ms-plugin.structure-representation-3d');
but I think it wouldn't make sense for non-polymers
Update:
With PDBe Molstar 3.3.0, this is now much easier. Follow the solution described here https://github.com/molstar/pdbe-molstar/issues/110
But instead of
polymer: { type: 'cartoon', color: 'sequence-id' },
use
polymer: { type: 'cartoon', color: 'secondary-structure' },
how can i set secondary structure as default coloring on rendering it in code
this is my code
any help is appreciated.