{"id":8287,"date":"2022-06-13T08:01:05","date_gmt":"2022-06-13T07:01:05","guid":{"rendered":"https:\/\/www.blopig.com\/blog\/?p=8287"},"modified":"2023-03-03T14:53:28","modified_gmt":"2023-03-03T14:53:28","slug":"viewing-fragment-elaborations-in-rdkit","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2022\/06\/viewing-fragment-elaborations-in-rdkit\/","title":{"rendered":"Viewing fragment elaborations in RDKit"},"content":{"rendered":"\n<p>As a reasonably new RDKit user, I was relieved to find that using its built-in functionality for generating basic images from molecules is quite easy to use. However, over time I have picked up some additional tricks to make the images generated slightly more pleasing on the eye!<\/p>\n\n\n\n<p>The first of these (which I definitely stole from another blog post at some point&#8230;) is to ask it to produce SVG images rather than png:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#ensure the molecule visualisation uses svg rather than png format\nIPythonConsole.ipython_useSVG=True<\/pre>\n\n\n\n<p>Now for something slightly more interesting: as a fragment elaborator, I often need to look at a long list of elaborations that have been made to a starting fragment. As these have usually been docked, these don&#8217;t look particularly nice when loaded straight into RDKit and drawn:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#load several mols from a single sdf file using SDMolSupplier\n#add these to a list\nelabs = [mol for mol in Chem.SDMolSupplier('frag2\/elabsTestNoRefine_Docked_0.sdf')]\n\n#get list of ligand efficiencies so these can be displayed alongside the molecules\nLEs = [(float(mol.GetProp('Gold.PLP.Fitness'))\/mol.GetNumHeavyAtoms()) for mol in elabs]\n\nDraw.MolsToGridImage(elabs, legends = [str(LE) for LE in LEs])<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"625\" height=\"388\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=625%2C388&#038;ssl=1\" alt=\"\" class=\"wp-image-8288\" srcset=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=1024%2C635&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=300%2C186&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=768%2C476&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=1536%2C952&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?resize=624%2C387&amp;ssl=1 624w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?w=1604&amp;ssl=1 1604w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image.png?w=1250&amp;ssl=1 1250w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><figcaption>Fig. 1: Images generated without doing any tinkering<\/figcaption><\/figure>\n\n\n\n<p>Two quick changes that will immediately make this image more useful are aligning the elaborations by a supplied substructure (here I supplied the original fragment so that it&#8217;s always in the same place) and calculating the 2D coordinates of the molecules so we don&#8217;t see the twisty business happening in the bottom right of Fig. 1:<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for elab in elabs:  \n    #view 2D visualisation instead\n    AllChem.Compute2DCoords(elab)\n    #keep fragment section in the same place\n    _=AllChem.GenerateDepictionMatching2DStructure(elab,frag_to_elaborate)  \n\n        \nDraw.MolsToGridImage(elabs,  legends=[str(LE) for LE in LEs])<\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"625\" height=\"350\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=625%2C350&#038;ssl=1\" alt=\"\" class=\"wp-image-8289\" srcset=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=1024%2C574&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=300%2C168&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=768%2C431&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=1536%2C861&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?resize=624%2C350&amp;ssl=1 624w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?w=1548&amp;ssl=1 1548w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/06\/image-1.png?w=1250&amp;ssl=1 1250w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><\/a><figcaption>Fig. 2. Now aren&#8217;t they easier to compare!<\/figcaption><\/figure>\n\n\n\n<p>Now you can scroll through visualizations of your elaborations without even having to touch Pymol. <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a reasonably new RDKit user, I was relieved to find that using its built-in functionality for generating basic images from molecules is quite easy to use. However, over time I have picked up some additional tricks to make the images generated slightly more pleasing on the eye! The first of these (which I definitely [&hellip;]<\/p>\n","protected":false},"author":94,"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,201],"tags":[87,477,129,134],"ppma_author":[559],"class_list":["post-8287","post","type-post","status-publish","format-standard","hentry","category-cheminformatics","category-code","category-small-molecules","tag-code-2","tag-fragment-based-drug-discovery","tag-rdkit","tag-small-molecules"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":559,"user_id":94,"is_guest":0,"slug":"lucy_vost","display_name":"Lucy Vost","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/410b510f70dab77a9fa285069d544f6f8069c1743e6050067edc992e470b551e?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\/8287","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\/94"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=8287"}],"version-history":[{"count":4,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/8287\/revisions"}],"predecessor-version":[{"id":8318,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/8287\/revisions\/8318"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=8287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=8287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=8287"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=8287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}