logo
AboutBlogProjects

CIRpy: A Python Interface for the NCI Chemical Identifier Resolver

In the past I have used the ChemSpider API (through ChemSpiPy) to resolve chemical names to structures. Unfortunately this doesn’t work that well for IUPAC names and I found myself wondering whether it was worth setting up a system that would try a number of different resolvers. More specifically, I wanted a system that would first try using OPSIN to match IUPAC names, and if that failed, try a ChemSpider lookup. Just as I was about to start doing this myself, I came across the Chemical Identifier Resolver (CIR) that does exactly that (and much more).

CIR is a web service created by by the CADD Group at the NCI that performs various chemical name to structure conversions. In short, it will (attempt to) resolve the structure of any chemical identifier that you throw at it. Under the hood it uses a combination of OPSIN, ChemSpider and CIR’s own database.

To simplify interacting with CIR through Python, I wrote a simple wrapper called CIRpy that handles constructing url requests and parsing XML responses. It’s available on github here.

Installing it is a simple case of running pip install cirpy. Here’s an example using the resolve function:

import cirpy
smiles_string = cirpy.resolve('Aspirin','smiles')

There are full details of all available options in the CIRpy documentation.