nglview_struct¶
Utilities for nglview structures.
-
pdb_prot_align.nglview_struct.
colorscheme_by_site
(colorscheme_name, sites_df, color_by)[source]¶ Add a color scheme to the color registry.
The scheme can then be added to a ngview.widget.NGLWidget as described here. For instance:
view.add_cartoon(color=colorscheme_name)
- Parameters
colorscheme_name (str) – Name of the color scheme.
sites_df (pandas.DataFrame or str) – Information on how to color sites. Can either be data frame or name of CSV file with data frame. Must have columns named ‘pdb_chain’ and ‘pdb_site’ as well as the column specified by color_by.
color_by (str or 2-tuple) – How to color the sites. Can either specify as a str the name of a column in sites_df that has the name of a color for each site, or can be the 2-tuple (val_col, color_map). In this case, val_col is name of column with numerical values, and color_map is a
pdb_prot_align.colorschemes.ValueToColorMap
that maps the numbers in this column to colors. If colors are specified as str and are hex, then they need to be like this ‘#25828e’.
-
pdb_prot_align.nglview_struct.
render_html
(view, *, html_file=None, orientation=None, remove_widget_view=False, returnval='display')[source]¶ Render widget to HTML.
- Parameters
view (ngview.widget.NGLWidget) – The structure widget to render.
html_file (None or str) – If you want to also save to permanent HTML file, provide name here.
orientation (list) – Set to this camera orientation (list of 16 numbers), fixing this bug: https://github.com/dwhswenson/contact_map/pull/62#issuecomment-583788933 You can get the desired orientation by manually manipulating the widget in a Jupyter notebook and then calling view._camera_orientation.
remove_widget_view (bool) – Remove the widget view lines, so the HTML just gives the widget state. Helpful if you want to embed widgets in HTML rendering without showing another time.
returnval ({'display', 'HTML', 'none'}) – Return value (see Returns_).
- Returns
A handle for a Jupyter notebook, or None depending on value of returnval.
- Return type
IPython.display.DisplayHandle or IPython.display.HTML or None.