{"id":7478,"date":"2021-10-16T15:45:40","date_gmt":"2021-10-16T14:45:40","guid":{"rendered":"https:\/\/www.blopig.com\/blog\/?p=7478"},"modified":"2021-10-16T15:45:45","modified_gmt":"2021-10-16T14:45:45","slug":"how-to-interact-with-small-molecules-in-jupyter-notebooks","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2021\/10\/how-to-interact-with-small-molecules-in-jupyter-notebooks\/","title":{"rendered":"How to interact with small molecules in Jupyter Notebooks"},"content":{"rendered":"\n<p>The combination of Python and the cheminformatics toolkit RDKit has opened up so many ways to explore chemistry on a computer. <a href=\"https:\/\/jupyter.org\">Jupyter<\/a> \u2014 named for the three languages, Julia, Python, and R \u2014 ties interactivity and visualization together, creating wonderful environments (<a href=\"https:\/\/mybinder.org\/v2\/gh\/ipython\/ipython-in-depth\/master?urlpath=tree\/binder\/Index.ipynb\">Notebooks<\/a> and <a href=\"https:\/\/mybinder.org\/v2\/gh\/jupyterlab\/jupyterlab-demo\/master?urlpath=lab\/tree\/demo\">JupyterLab<\/a>) to carry out, share and reproduce research, including:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-text-align-right is-layout-flow wp-block-quote-is-layout-flow\"><p>&#8220;data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.&#8221;<\/p><cite>\u2014https:\/\/jupyter.org<\/cite><\/blockquote>\n\n\n\n<p>At this year&#8217;s annual <a href=\"https:\/\/github.com\/cbouy\/UGM_2021\">RDKit UGM<\/a> (User Group Meeting), <a href=\"https:\/\/github.com\/cbouy\">C\u00e9dric Bouysset<\/a> shared a tutorial explaining <a href=\"https:\/\/github.com\/cbouy\/UGM_2021\/blob\/main\/Notebooks\/Bouysset_mols2grid.ipynb\">how to create a grid of molecules that you can interact with<\/a>, using his &#8220;<a href=\"https:\/\/github.com\/cbouy\/mols2grid\">mols2grid<\/a>&#8220;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/raw.githubusercontent.com\/cbouy\/mols2grid\/master\/demo.png?w=625&#038;ssl=1\" alt=\"\"\/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>It&#8217;s easy to filter the molecules interactively using the &#8220;Search&#8221; box in the bottom right corner either by &#8220;Text&#8221; or &#8220;SMARTS&#8221; (options hidden by the magnifying glass icon); and to sort them by Pandas data frame fields. Tooltips can also be shown just by hovering your cursor over a molecule in the grid. It&#8217;s even possible to use callbacks to trigger actions, like showing the 3D conformer of a molecule using py3Dmol, or calling arbitrary JavaScript. By checking individual molecules, the selection can be accessed in subsequent cells, or copied to the clipboard (but not in Colab notebooks as Google blocks this).<\/p>\n\n\n\n<p>It&#8217;s easy to install using <a href=\"https:\/\/docs.conda.io\/en\/latest\/\">conda<\/a> (or <a href=\"https:\/\/github.com\/mamba-org\/mamba\">mamba<\/a>, a faster conda included in <a href=\"https:\/\/github.com\/conda-incubator\/condacolab\">CondaColab<\/a>)\u2014and highly recommended.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># How to install mols2grid using conda\nconda install -c conda-forge mols2grid\n# How to install mols2grid using mamba\nmamba install -c conda-forge mols2grid<\/pre>\n\n\n\n<p>Pat Walters shows <a href=\"https:\/\/practicalcheminformatics.blogspot.com\/2021\/07\/viewing-clustered-chemical-structures.html\">how to use mols2grid to cluster chemical structures<\/a> <a href=\"https:\/\/github.com\/PatWalters\/clusterama\">using RDKit&#8217;s implementation of the Butina clustering algorithm<\/a> and <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.DataFrame.groupby.html\">Panda&#8217;s groupby<\/a> function.<\/p>\n\n\n\n<p>Also check out Justin Chavez&#8217;s &#8220;<a href=\"https:\/\/blog.reverielabs.com\/building-web-applications-from-python-scripts-with-streamlit\/\">Building Web Applications From Python Scripts with Streamlit<\/a>&#8220;, and <a href=\"https:\/\/www.youtube.com\/c\/DataProfessor\/about\">Chanin Nantasenamat<\/a>&#8216;s YouTube video, &#8220;How to build a web app for Drug Discovery in Python&#8221;:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How to build a web app for Drug Discovery in Python | Streamlit #26\" width=\"625\" height=\"469\" src=\"https:\/\/www.youtube.com\/embed\/0rqIwSeUImo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The combination of Python and the cheminformatics toolkit RDKit has opened up so many ways to explore chemistry on a computer. Jupyter \u2014 named for the three languages, Julia, Python, and R \u2014 ties interactivity and visualization together, creating wonderful environments (Notebooks and JupyterLab) to carry out, share and reproduce research, including: &#8220;data cleaning and [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","wikipediapreview_detectlinks":true,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[187,29,361,296,14,189,227,201],"tags":[430,158,129,429],"ppma_author":[488],"class_list":["post-7478","post","type-post","status-publish","format-standard","hentry","category-cheminformatics","category-code","category-data-science","category-hints-and-tips","category-howto","category-machine-learning","category-python-code","category-small-molecules","tag-clustering","tag-py3dmol","tag-rdkit","tag-smarts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":488,"user_id":35,"is_guest":0,"slug":"garrett","display_name":"Garrett","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/df625261419c37dd5c5937e37f17a732626acd6eea1e6fabd03d935c25b453bf?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=7478"}],"version-history":[{"count":1,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7478\/revisions"}],"predecessor-version":[{"id":7479,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7478\/revisions\/7479"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=7478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=7478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=7478"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}