This scientific clickbait title introduces our promised blog post about the integration of UniChem into our ChEMBL python client. UniChem is a very important resource, as it contains information about 134 million (and counting) unique compound structures and cross references between various chemistry resources. Since UniChem is developed in-house and provides its own web services, we thought it would make sense to integrate it with our python client library. Before we present a systematic translation between raw HTTP calls described in the UniChem API documentation and client calls, let us provide some preliminary information:
In order to install the client, you should use pip:
pip install -U chembl_webresource_client
Once you have it installed, you can import the unichem module:
from chembl_webresource_client.unichem import unichem_client as unichem
OK, so how to resolve an InChI Key to InChI string? It's very simple:
Of course in order to resolve InChI Key to InChI, the client connects to the UniChem database via REST, retrieves the results and gives them to you. This is done in a very efficient way and abstracts away all network-related issues, such as setting the HTTP session, handling retries, caching results etc. From the user point of view, it looks like a standard function call, that is executed locally but in fact working internet connection is required to successfully fetch results (unless they are already cached). We've just heard that there is another InChi resolver written entirely in CSS3, click here to find out.
OK, we admit that resolving InChI key to InChI may not be the most important UniChem use case so we invite you to take a look at the Jupyter notebook providing examples of using all available methods: