mcs07 / PubChemPy

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

Search by CAS #? #37

Closed theman0605 closed 5 years ago

theman0605 commented 5 years ago

Hello. I am wondering if there is a way to use the PubChemPy to search by CAS #?

Thanks,

Stan

mcs07 commented 5 years ago

I don't believe CAS registry numbers are officially supported by PubChem (possibly for legal reasons) but many depositors include them as a synonym. Therefore you can just search by name and often it will work:

>>> import pubchempy as pcp
>>> results = pcp.get_compounds('50-78-2', 'name')
>>> print(results)
[Compound(2244)]
>>> print(results[0].canonical_smiles)
CC(=O)OC1=CC=CC=C1C(=O)O
theman0605 commented 5 years ago

Thanks for the quick response Matt. I'll give it a shot.

Stan

On Tue, Jan 15, 2019 at 10:12 AM Matt Swain notifications@github.com wrote:

Closed #37 https://github.com/mcs07/PubChemPy/issues/37.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mcs07/PubChemPy/issues/37#event-2074847387, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ-TXxZvqhKkQi7ODBUwXwmov5P5r3Aeks5vDe_kgaJpZM4aBHJX .