Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added NGL protein viewer example #1

Closed
wants to merge 1 commit into from
Closed

Added NGL protein viewer example #1

wants to merge 1 commit into from

Conversation

Jhsmit
Copy link

@Jhsmit Jhsmit commented Sep 24, 2020

This PR adds a protein viewer example using the NGL molecular graphics library as discussed on Discourse 583.

Currently this is implemented with a panel HTML view, where changes in protein or its representation trigger a new generation of HTML, which then redraws the entire figure.
Possible improvement could be (as a Bokeh extension) direct interaction with the NGL stage javascript object such that, for example, the color of the protein can be changed without redrawing the whole figure and thereby resetting the orientation.

There is also a IPywidgets variant available for the NGL viewer: https://github.com/nglviewer/nglview. This might be easier to get the desired result and full control in python, however this direct javascript/HTML approach feels more 'native'. Currently I could not get the ipywidgets approach to work (see bokeh/ipywidgets_bokeh#8)

I wasnt sure if this should be in /examples or maybe it should be in /pane because its based on an HTML pane?

@MarcSkovMadsen
Copy link
Collaborator

I'm so sorry @Jhsmit . I forgot all about this contribution. I will take a look this weekend.

Thanks

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Dec 12, 2020

@Jhsmit . After looking at it, my plan is to add it as widget and showcase an example at awesome-panel.org.

I would be nice for potential users if you could provide a small description of

pdb_string = param.String()
rcsb_id = param.String()
representation
spin

that I could use as doc string.

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Dec 12, 2020

The NGLViewer is now in the awesome-panel-extensions package and in live at awesome-panel.org.

https://awesome-panel.org/ngl-molecule-viewer

image

image

I've copied the file around and not merged this PR hope it's ok. The widget could be improved with doc values, a link from the awesome-panel-extensions guide and a Notebook reference guide. But this was what I had time for.

I will close this one.

@Jhsmit
Copy link
Author

Jhsmit commented Dec 13, 2020

Totally fine to copy the file. Authorship is clearly attributed which is very nice but also not extremely critical for me for these kinds of things.

The NGL viewer can visualize any kind of molecule and has more functionality than exposed here but since I'm only looking at proteins the example here is a only a subset of the functionality.

Here are some docstrings:

    pdb_string = param.String(
        doc="""Raw string of PDB file representing molecular structure to visualize.
        """
    )
    rcsb_id = param.String(
        doc="""ID of PDB structure to fetch from the RCSB Protein Data Bank and visualize.
        """
    )
    representation = param.Selector(
        default="ribbon",
        objects=REPRESENTATIONS,
        doc="""The type of representation used to visualize the molecular structure.
        
        """
    )
    color_scheme = param.Selector(default="chainid", objects=COLOR_SCHEMES, 
                                  doc="""Which color scheme to use in the visualization.
                                  
    """)
    spin = param.Boolean(default=False,
                         doc="""Toggle spinning of the molecular structure.""")

I can also make a PR if you prefer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants