Macs in Chemistry

Insanely great science



Using Flot and Chemical Identifier Resolver

I recently wrote a couple of Applescripts that use the Chemical Identifier Resolver (CIR) a web service that performs various chemical name to structure conversions and it occurred to me that is should be possible to use this service to generate images for use as popups on a graph in the same way that I’ve previously described using Flot and ChemSpider. This works well but relies on the structure already being in the ChemSpider database, for novel structures we need a service for generating the image from a chemical identifier. CIR provides a simple web service for doing exactly this, for example submit a SMILES string and it can return a 2D image.

The format for the URL to generate an image from a SMILES string is shown below

http://cactus.nci.nih.gov/chemical/structure/c1ccccc1/image

and you can use the same format to generate an image from a name

http://cactus.nci.nih.gov/chemical/structure/Ritonavir/image


The data for the red dots is encoded as SMILES strings

var redDots = [[3.4771212547196624,.0086001717619176,'C1=CC=CC=C1N2C(C(=C(N2C)C)N(C)C)=O'],[3.3891660843645325,1.9604707775342989,'C1=CC(=CC2=NC=CC(=C12)NC3=CC=C(C(=C3)CN(CC)CC)O)Cl'],

Whilst the green and blue uses compound names


var greenDots = [[3.6020599913279624,.9242792860618817,'Acetaminophen',1906],[1.9030899869919436,2.3205616801952366,'Atorvastatin',54810],

The popup window is now constructed thus, using the Chemical Identifier Resolver.

// Takes a datapoint and constructs the popup window
function showPopup(x, y, dataPoint) {
$('< div id="popup">< img src="http://cactus.nci.nih.gov/chemical/structure/'+dataPoint[2]+'/image'+'" />< br/>'+dataPoint[2]+'< /div>').css( {
top: y + 5,
left: x + 5
}).appendTo("body").fadeIn(200);

If you mouseover the points in the plot below you should be able to see that the red points are SMILES whilst the others are named. Thus we have a means to include known and novel chemical structures on an interactive plot. For proprietary structures it is probably better to use ChemDoodle to generate the structures.

To see the full code just view source to the page.



Log Covalent Binding
Log Dose


There are more tutorials, scripts and reviews here

Updated 4 April 2012