pdbe-molstar icon indicating copy to clipboard operation
pdbe-molstar copied to clipboard

Colouring each residue

Open rsakai opened this issue 2 years ago • 3 comments

Is it possible to loop through each residue and colour them? I am loading a PDB file and would like to colour each residue based on experimental value I get for each residue.

rsakai avatar Jul 25 '23 20:07 rsakai

Probably this could be of help for you.

I usually create a list of dicts with the necessary color and residue information and then pass it to the color function. Here you can find a snippet: https://github.com/bayer-science-for-a-better-life/topefind-public/blob/73a40c4f0ef38a21d49e46e7987f69ac02baffd4/topefind/dashboard/dashboard.py#L578

CrisSherban avatar Nov 08 '23 12:11 CrisSherban

Probably this could be of help for you.

I usually create a list of dicts with the necessary color and residue information and then pass it to the color function. Here you can find a snippet: https://github.com/bayer-science-for-a-better-life/topefind-public/blob/73a40c4f0ef38a21d49e46e7987f69ac02baffd4/topefind/dashboard/dashboard.py#L578

I believe the user wants to color the residues within the viewer directly.

KeaunAmani avatar Jan 08 '24 20:01 KeaunAmani

You can use the .visual.select helper method (basically what CrisSherban suggested, thank you). The call will look something like this:

viewerInstance.visual.select({
    data: [
        { struct_asym_id: 'A', residue_number: 1, color: '#ff0000' }, 
        { struct_asym_id: 'A', residue_number: 2, color: '#ff8800' }, 
        { struct_asym_id: 'A', start_residue_number: 3, end_residue_number: 6, color: '#ffff00' }, 
        { struct_asym_id: 'A', start_residue_number: 15, end_residue_number: 20, color: '#88ff00' },
    ],
    nonSelectedColor: '#ffffff',
});

midlik avatar Aug 29 '24 10:08 midlik