molstar / VSCoding-Sequence

VSCode Extension for interactively visualising protein structure data in the editor
MIT License
96 stars 8 forks source link

Adjust coloring values #5

Closed dangthatsright closed 2 years ago

dangthatsright commented 2 years ago

I was wondering if there was a way to adjust color values based on a specific field in an sdf or xyz. I see options for occupancy which is potentially promising because I can script something to write to that field but I'm not sure which field that corresponds to in my file. Is this possible / is there any documentation that could help me with this? Thanks!

a-r-j commented 2 years ago

Hi @dangthatsright that's a great question!

I just dug into it a little. It seems there are fields that you can write to in SDF files: http://www.nonlinear.com/progenesis/sdf-studio/v0.9/faq/sdf-file-format-guidance.aspx

I don't think this is the case for .xyz

However, the sticking point is that I don't see a way to access these fields as colouring options in Mol. You could reach out the [Mol](https://github.com/molstar/molstar) devs for their take on the problem.

There is a glimmer of hope - while not ideal, one possible workaround is converting your xyz/sdf files to .pdbs. I believe occupancy is a PDB-specific field (and is often used for this sort of thing).

Do let me know how you get on if you decide to try this approach.

dangthatsright commented 2 years ago

@a-r-j I was able to parse my xyz file, and create the relevant pdb file using rdkit. I gotta say, it was not the cleanest implementation. Perhaps openbabel would've been better or something. Regardless, I got what I want to be displayed on Protein Viewer. The issue is that I would like some defaults to be set (3D representation, colors, color domain). Is there any way to save the defaults or override these defaults so I don't have change the values every time I open something new up?

a-r-j commented 2 years ago

Hey @dangthatsright glad the colouring worked out for you! Sorry that’s a little clunky but that’s the only thing I could think of..

that’s a great suggestion & something I thought would be nice to have.

VSCode extensions can be configured via the VSCode settings file (https://code.visualstudio.com/api/references/contribution-points#contributes.configuration)

The extension doesn’t support this atm but it would be great to do so in the future. If you’d like to try I’d be more than happy to support. Otherwise, it’s unclear to me when I’d have bandwidth to implement it myself.