This blog post is more of a request for comments/assistance than the usual is.
I've been doing some experimentation with Jupyter widgets and have managed to put together an initial proof of concept widget for displaying molecules where you can select atoms and find out which atoms are selected.
This is one where the notebook by itself really isn't worth much, so I'll just link to it:
https://github.com/greglandrum/rdkit_blog/blob/master/notebooks/Jupyter_widget.ipynb
This animation shows how the widget works. It constructs a widget displaying an SVG and demonstrates atom selection/deselection in the widget propagating to Python:
And here's a demonstration that shows changing the SVG that's being displayed from Python:
This is basic, but I think it's a decent start towards something that could be really useful. Interested? Have suggestions (ideally accompanied by code!) on how to improve it? If it looks like this is actually likely to be used, I will figure out how to create a standalone nbwidget out of this and create a separate github repo for it.
I've been doing some experimentation with Jupyter widgets and have managed to put together an initial proof of concept widget for displaying molecules where you can select atoms and find out which atoms are selected.
This is one where the notebook by itself really isn't worth much, so I'll just link to it:
https://github.com/greglandrum/rdkit_blog/blob/master/notebooks/Jupyter_widget.ipynb
This animation shows how the widget works. It constructs a widget displaying an SVG and demonstrates atom selection/deselection in the widget propagating to Python:
And here's a demonstration that shows changing the SVG that's being displayed from Python:
This is basic, but I think it's a decent start towards something that could be really useful. Interested? Have suggestions (ideally accompanied by code!) on how to improve it? If it looks like this is actually likely to be used, I will figure out how to create a standalone nbwidget out of this and create a separate github repo for it.
2 comments:
This seems to be a very promising start. If we can interact and click on bonds in an rdkit molecule it will open up for a lot of interesting applications. It could be interesting to see if I could make some edit capabilities like in rdEditor, which is hopelessly outdated by being a desktop application in PyQt.
Is there a smarter way to catch/call/watch signal the atom clicked event on the Python side?
from IPython.display import display
output = widgets.Output()
def on_atom_clicked(b):
with output:
print(b["new"])
w.observe(on_atom_clicked, names="selected_atoms")
display(output)
Post a Comment