mcs07 / PubChemPy

Python wrapper for the PubChem PUG REST API.
http://pubchempy.readthedocs.io
MIT License
379 stars 106 forks source link

API down for SMILES Search? #64

Closed jannisborn closed 2 years ago

jannisborn commented 2 years ago

Previously functioning code using get_compounds with the smiles argument is currently disfunctional.

For example:

get_compounds('C1=CC2=C(C3=C(C=CC=N3)C=C2)N=C1', 'smiles')

raises an pubchempy.BadRequestError. This does not happen when searching for name and also not for substructure searches.

Possible reason: A bug on pubchem side: The UI seems to have trouble standardizing SMILES atm: https://pubchem.ncbi.nlm.nih.gov/#query=C1=CC2=C(C3=C(C=CC=N3)C=C2)N=C1

What's going on here?

nbehrnd commented 2 years ago

A couple of minutes ago, I went through the Jupyter-notebooks of this project. Book "2-getting-started.ipynb" includes a SMILES-based search, which is working (even in Python 3). Can you replicate this on a computer accessible to you?

From the CLI in Linux Debian 12/bookworm:


Python 3.9.9 (main, Dec 16 2021, 23:13:29) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pubchempy as pcp
>>> pcp.get_compounds('C1=CC2=C(C3=C(C=CC=N3)C=C2)N=C1', 'smiles')
[Compound(1318)]
>>> 
``
jannisborn commented 2 years ago

The same code that was raising the error before (executed in the same env) now works fine again and gives the same result that you report. Seems like this was an API outage on pubchem side. Thanks for looking into this and building this useful library :)