What do chemicals look like?
sdftosvg is an NPM package for rendering chemical structures
If you look at the structures of chemicals within a family, you can see striking similarities. Take PCBs, which are industrial chemicals that were banned in the 1970s, as an example:
![PCB 11](/devblog/assets/posts/2016-10-26-what-do-chemicals-look-like/PCB11.png)
![PCB 105](/devblog/assets/posts/2016-10-26-what-do-chemicals-look-like/PCB105.png)
![PCB 201](/devblog/assets/posts/2016-10-26-what-do-chemicals-look-like/PCB201.png)
We wanted a way to generate beautiful chemical structure visualizations, like the ones you see above, for use in our materials. We developed a lightweight tool called sdftosvg
that does just that: it takes as input SDF files, downloadable from repositories like PubChem, and outputs SVG renderings.
Installation
sdftosvg
is available as an NPM package.
$ npm install -g sdftosvg
Example
The chemical triclosan is used as an anti-microbial in soaps, oral care products, and other consumer products. The PubChem page for triclosan has an SDF file available that defines triclosan’s structure. We can convert the SDF to an svg using sdftosvg
:
$ sdftosvg triclosan.sdf triclosan.svg
Full documentation for the project is available on the project’s Github page.