How to use PubChem in Python

Introduction

PubChem is a typical compound database. Here, we will explain how to search PubChem data in Python.

Search for compound ID and compound name

If you want to search by compound name and get the CID or IUPAC name of the record obtained as a search result, you can use the get_compounds method.

import pubchempy as pcp


glycine_pubchem = pcp.get_compounds('glycine', 'name')
result = {}

for record in glycine_pubchem:
    result[record.cid] = record.iupac_name

print(result)

In the above example, the CID is stored in the key of the dictionary result and the IUPA name is stored as the value.

Acquire physical property values and structural information

If you want to get information such as molecular weight and Canonical SMILES, you can use the get_properties method.

import pubchempy as pcp


target_properties = ['MolecularFormula', 'MolecularWeight', 'CanonicalSMILES']
result = pcp.get_prpperties(target_properties, 'glycine', 'name')

print(result)

In the above example, the physical property information you want to get is passed to the get_properties method as a list.

Summary

Here's how to access PubChem data in Python. With PubChemPy, you can easily use the information stored in PubChem. It's an essential tool for chemoinformatics, so make sure you have it ready for use.

Reference materials / links

How can chemoinformatics help pharmaceutical companies? What kind of knowledge do you need?

Recommended Posts

How to use PubChem in Python
How to use SQLite in Python
How to use Mysql in python
How to use ChemSpider in Python
[Introduction to Python] How to use class in Python?
How to use regular expressions in Python
How to use is and == in Python
python3: How to use bottle (2)
[Python] How to use list 1
How to use Python argparse
Python: How to use pydub
[Python] How to use checkio
How to develop in Python
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
How to use Python Image Library in python3 series
Summary of how to use MNIST in Python
How to use tkinter with python in pyenv
[For beginners] How to use say command in python!
[Python] How to do PCA in Python
Python: How to use async with
How to use classes in Theano
[Python] How to use Pandas Series
How to collect images in Python
How to use Requests (Python Library)
[Python] How to use list 3 Added
How to use OpenPose's Python API
How to use FTP with Python
Python: How to use pydub (playback)
I tried to summarize how to use pandas in python
How to use the model learned in Lobe in Python
How to use python zip function
How to handle Japanese in Python
[Python] How to use Typetalk API
How to use the __call__ method in a Python class
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
Comparison of how to use higher-order functions in Python 2 and 3
[Python] Summary of how to use pandas
How to access environment variables in Python
How to dynamically define variables in Python
How to install and use pandas_datareader [Python]
[Itertools.permutations] How to put permutations in Python
How to use Google Test in C
[python] How to use __command__, function explanation
How to work with BigQuery in Python
[Python] How to use import sys sys.argv
How to get a stacktrace in python
Easy way to use Wikipedia in Python
How to extract polygon area in Python
[Python] Organizing how to use for statements
How to check opencv version in python
How to use Anaconda interpreter in PyCharm
python: How to use locals () and globals ()
How to adjust image contrast in Python
How to dynamically zero pad in Python
How to use "deque" for Python data
How to use Python zip and enumerate