Plotting RDKit mols

link to gist

Most modelling tasks in comp/med chem are inherently 3D, but I find it much easier to develop in 2D. The main reason for this is that plotting in 3D is unfortunately difficult in a jupyter shell. On the other hand, plotting in 2D is easy with matplotlib, and with numpy a lot of the code will look the same in 2D vs 3D if it's been vectorized.

Still, when interacting with the RDKit, it's not obvious how to 'plot' a structure in matplotlib. So here's an example of how to plot an RDKit image of a 2D conformer onto a matplotlib figure.

This example also shows why this is useful - in this case, it samples scattered points on a vDW surface, then expands the vDW surface to the solvent-accessible surface, and then calculates the 'SASA' in 2D. With a little bit of tinkering, this code would work in 3D, too, which will be the topic of the next, more detailed, blog post.