Skip to main content

A Python Package for Accessing Chemical Information from PubChem (https://pubchem.ncbi.nlm.nih.gov/).

Project description

PubChemQuery

PubChemQuery: A Python Package for Accessing Chemical Information from PubChem

PubChemQuery is a Python package that provides a simple and intuitive API for retrieving chemical information from the PubChem database. With this package, you can easily fetch chemical data, including:

  • CID (Compound ID) by name

  • All CIDs by name

  • 2D images by CID or name

  • SDF (Structure Data File) by CID or name

  • Compound properties, including:

    • Molecular formula and weight

    • SMILES and InChI representations

    • IUPAC name and title

    • Physicochemical properties (e.g., XLogP, exact mass, TPSA)

    • Structural features (e.g., bond and atom counts, stereochemistry)

    • 3D properties (e.g., volume, steric quadrupole moments, feature counts)

    • Fingerprint and conformer information

The package offers a straightforward interface, allowing users to access PubChem data with minimal code. Whether you're a chemist, researcher, or developer, PubChemQuery simplifies the process of integrating chemical information into your projects.

Key Features:

Retrieve chemical data by name or CID

Access 2D images and SDF files

Get compound properties, including physicochemical, structural, and 3D features

Easy-to-use API with minimal code required

Simple and Concise API:

There are only 7 functions that perform all of the above-mentioned tasks, making it easy to integrate PubChem data into your projects:

  • get_cid_by_name(name): Get CID by name

  • get_cids_by_name(name): Get all CIDs by name

  • get_image_by_cid(cid): Get 2D image by CID

  • get_image_by_name(name): Get 2D image by name

  • get_structure_by_cid(cid): Get SDF by CID

  • get_structure_by_name(name): Get SDF by name

  • compound(cid_or_name): Create a compound object with properties and methods

Getting Started:

To use PubChemQuery, simply install the package and import it into your Python script. Refer to the example code snippets above for a quick start.

Installation

Install PubChemQuery with pip

  pip install pubchemquery

Documentation

import pubchemquery as pcq



# get a cid by name

cid = pcq.get_cid_by_name('benzene')

print(cid)



# get all cids by name

cids = pcq.get_cids_by_name('benzene')

print(type(cids), len(cids))



# get 2d image

image = pcq.get_image_by_cid('241')

print(image)



image = pcq.get_image_by_name('benzene')

print(image)



# get sdf by cid

sdf = pcq.get_structure_by_cid('241')

print(sdf)



# get sdf by name

sdf = pcq.get_structure_by_name('benzene')

print(sdf)



# make a compound by cid

cid = 2244

compound = pcq.compound(cid)

# name

name = '2-acetyloxybenzoic acid'

compound = pcq.compound(name)

print(compound)

# properties

print(compound.InChI)

print(compound.InChIKey)

print(compound.IUPACName)

print(compound.image)

FAQ

For any question, contact me on LinkedIn

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

PubChemQuery-1.0.0-py3-none-any.whl (13.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page