PubChemQuery


NamePubChemQuery JSON
Version 1.5.0 PyPI version JSON
download
home_pageNone
SummaryA Python Package for Accessing Chemical Information from PubChem (https://pubchem.ncbi.nlm.nih.gov/).
upload_time2024-07-31 01:50:04
maintainerNone
docs_urlNone
authorSina Gilassi
requires_python>=3.6
licenseMIT
keywords python pubchem pubchemapi pubchemquery pubchemquery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# PubChemQuery



![Downloads](https://img.shields.io/pypi/dm/PubChemQuery) ![PyPI](https://img.shields.io/pypi/v/PubChemQuery) ![Python Version](https://img.shields.io/pypi/pyversions/PubChemQuery.svg) ![License](https://img.shields.io/pypi/l/PubChemQuery) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hKrOe6K1L_fpd6_izhpVXaA1Zmq6Z8Fo?usp=sharing)



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



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 functions that perform all of the above-mentioned tasks, making it easy to integrate PubChem data into your projects:



* `get_cid_by_inchi(inchi)`: Get a CID by InChI

* `get_cids_by_formula(formula)`: Get CIDs by formula

* `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_image_by_inchi(inchi)`: Get 2D image by InChI

* `get_structure_by_cid(cid)`: Get SDF by CID

* `get_structure_by_name(name)`: Get SDF by name

* `get_similar_structures_cids_by_compound_id(cid/SMILES/InChI)`: Get similar structures CIDs by cid, SMILES, InChI



**Compound Object:**

The package also includes a `Compound` object that encapsulates the retrieved data, providing a convenient way

to access and manipulate the data.



* `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



```python

  pip install PubChemQuery

```



## Examples



Import package as:



```python

import pubchemquery as pcq

```



Use the functions to retrieve data:



```python

# get a cid by formula

cid = pcq.get_cids_by_formula('C6H6')

print(type(cid), len(cid))

```



```python

# get a cid by inchi

cid = pcq.get_cid_by_inchi(

    'InChI=1S/C6H5NO3/c8-6-3-1-5(2-4-6)7(9)10/h1-4,8H')

print(cid)

```



```python

# get a cid by name

cid = pcq.get_cid_by_name('benzene')

print(cid)

```



```python

# get all cids by name

cids = pcq.get_cids_by_name('benzene')

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

```



```python

# get 2d image

# by cid

image = pcq.get_image_by_cid('241')

image



# by name

image = pcq.get_image_by_name('benzene')

image



# by inchi

image = pcq.get_image_by_inchi(

    'InChI=1S/C6H5NO3/c8-6-3-1-5(2-4-6)7(9)10/h1-4,8H')

print(image)

```



```python

# get sdf by cid

sdf = pcq.get_structure_by_cid('241')

print(sdf)

```



```python

# get sdf by name

sdf = pcq.get_structure_by_name('benzene')

print(sdf)

```



```python

# get similar structure cids by cid

# cids = pcq.get_similar_structures_cids_by_compound_id('241')

# cids = pcq.get_similar_structures_cids_by_compound_id(

#     'C1=CC=CC=C1', compound_id='SMILES')

cids = pcq.get_similar_structures_cids_by_compound_id(

    'InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H', compound_id='InChI')

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

```



Make a compound and then get its properties:



```python

# make a compound

cid = 2244

# compound = pcq.compound(cid)

# name

name = '2-acetyloxybenzoic acid'

compound = pcq.compound(name)

print(compound)

# properties

# InChI

print(compound.InChI)

# InChIKey

print(compound.InChIKey)

# IUPACName

print(compound.IUPACName)

# similar structure cids

print(len(compound.similar_structure_cids))

# image

compound.image

# dataframe

compound.prop_df()

```



## FAQ



For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) 





## Authors



- [@sinagilassi](https://www.github.com/sinagilassi)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PubChemQuery",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "python, PubChem, PubChemAPI, PubChemQuery, pubchemquery",
    "author": "Sina Gilassi",
    "author_email": "<sina.gilassi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6c/06/5bc4a35d28a3d6d597fde7ad6a14cff72c838e87330210157405e46d74a9/pubchemquery-1.5.0.tar.gz",
    "platform": null,
    "description": "\r\n# PubChemQuery\r\n\r\n\r\n\r\n![Downloads](https://img.shields.io/pypi/dm/PubChemQuery) ![PyPI](https://img.shields.io/pypi/v/PubChemQuery) ![Python Version](https://img.shields.io/pypi/pyversions/PubChemQuery.svg) ![License](https://img.shields.io/pypi/l/PubChemQuery) [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hKrOe6K1L_fpd6_izhpVXaA1Zmq6Z8Fo?usp=sharing)\r\n\r\n\r\n\r\n**PubChemQuery:** A Python Package for Accessing Chemical Information from [PubChem](https://pubchem.ncbi.nlm.nih.gov/).\r\n\r\n\r\n\r\nPubChemQuery 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:\r\n\r\n\r\n\r\n* CID (Compound ID) by name\r\n\r\n* All CIDs by name\r\n\r\n* 2D images by CID or name\r\n\r\n* SDF (Structure Data File) by CID or name\r\n\r\n* Compound properties, including:\r\n\r\n    - Molecular formula and weight\r\n\r\n    - SMILES and InChI representations\r\n\r\n    - IUPAC name and title\r\n\r\n    - Physicochemical properties (e.g., XLogP, exact mass, TPSA)\r\n\r\n    - Structural features (e.g., bond and atom counts, stereochemistry)\r\n\r\n    - 3D properties (e.g., volume, steric quadrupole moments, feature counts)\r\n\r\n    - Fingerprint and conformer information\r\n\r\n\r\n\r\nThe 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.\r\n\r\n\r\n\r\n**Key Features:**\r\n\r\n\r\n\r\nRetrieve chemical data by name or CID\r\n\r\nAccess 2D images and SDF files\r\n\r\nGet compound properties, including physicochemical, structural, and 3D features\r\n\r\nEasy-to-use API with minimal code required\r\n\r\n\r\n\r\n**Simple and Concise API:**\r\n\r\n\r\n\r\nThere are functions that perform all of the above-mentioned tasks, making it easy to integrate PubChem data into your projects:\r\n\r\n\r\n\r\n* `get_cid_by_inchi(inchi)`: Get a CID by InChI\r\n\r\n* `get_cids_by_formula(formula)`: Get CIDs by formula\r\n\r\n* `get_cid_by_name(name)`: Get CID by name\r\n\r\n* `get_cids_by_name(name)`: Get all CIDs by name\r\n\r\n* `get_image_by_cid(cid)`: Get 2D image by CID\r\n\r\n* `get_image_by_name(name)`: Get 2D image by name\r\n\r\n* `get_image_by_inchi(inchi)`: Get 2D image by InChI\r\n\r\n* `get_structure_by_cid(cid)`: Get SDF by CID\r\n\r\n* `get_structure_by_name(name)`: Get SDF by name\r\n\r\n* `get_similar_structures_cids_by_compound_id(cid/SMILES/InChI)`: Get similar structures CIDs by cid, SMILES, InChI\r\n\r\n\r\n\r\n**Compound Object:**\r\n\r\nThe package also includes a `Compound` object that encapsulates the retrieved data, providing a convenient way\r\n\r\nto access and manipulate the data.\r\n\r\n\r\n\r\n* `compound(cid_or_name)`: Create a compound object with properties and methods\r\n\r\n\r\n\r\n**Getting Started:**\r\n\r\n\r\n\r\nTo use PubChemQuery, simply install the package and import it into your Python script. Refer to the example code snippets above for a quick start.\r\n\r\n\r\n\r\n## Installation\r\n\r\n\r\n\r\nInstall PubChemQuery with pip\r\n\r\n\r\n\r\n```python\r\n\r\n  pip install PubChemQuery\r\n\r\n```\r\n\r\n\r\n\r\n## Examples\r\n\r\n\r\n\r\nImport package as:\r\n\r\n\r\n\r\n```python\r\n\r\nimport pubchemquery as pcq\r\n\r\n```\r\n\r\n\r\n\r\nUse the functions to retrieve data:\r\n\r\n\r\n\r\n```python\r\n\r\n# get a cid by formula\r\n\r\ncid = pcq.get_cids_by_formula('C6H6')\r\n\r\nprint(type(cid), len(cid))\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get a cid by inchi\r\n\r\ncid = pcq.get_cid_by_inchi(\r\n\r\n    'InChI=1S/C6H5NO3/c8-6-3-1-5(2-4-6)7(9)10/h1-4,8H')\r\n\r\nprint(cid)\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get a cid by name\r\n\r\ncid = pcq.get_cid_by_name('benzene')\r\n\r\nprint(cid)\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get all cids by name\r\n\r\ncids = pcq.get_cids_by_name('benzene')\r\n\r\nprint(type(cids), len(cids))\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get 2d image\r\n\r\n# by cid\r\n\r\nimage = pcq.get_image_by_cid('241')\r\n\r\nimage\r\n\r\n\r\n\r\n# by name\r\n\r\nimage = pcq.get_image_by_name('benzene')\r\n\r\nimage\r\n\r\n\r\n\r\n# by inchi\r\n\r\nimage = pcq.get_image_by_inchi(\r\n\r\n    'InChI=1S/C6H5NO3/c8-6-3-1-5(2-4-6)7(9)10/h1-4,8H')\r\n\r\nprint(image)\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get sdf by cid\r\n\r\nsdf = pcq.get_structure_by_cid('241')\r\n\r\nprint(sdf)\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get sdf by name\r\n\r\nsdf = pcq.get_structure_by_name('benzene')\r\n\r\nprint(sdf)\r\n\r\n```\r\n\r\n\r\n\r\n```python\r\n\r\n# get similar structure cids by cid\r\n\r\n# cids = pcq.get_similar_structures_cids_by_compound_id('241')\r\n\r\n# cids = pcq.get_similar_structures_cids_by_compound_id(\r\n\r\n#     'C1=CC=CC=C1', compound_id='SMILES')\r\n\r\ncids = pcq.get_similar_structures_cids_by_compound_id(\r\n\r\n    'InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H', compound_id='InChI')\r\n\r\nprint(type(cids), len(cids))\r\n\r\n```\r\n\r\n\r\n\r\nMake a compound and then get its properties:\r\n\r\n\r\n\r\n```python\r\n\r\n# make a compound\r\n\r\ncid = 2244\r\n\r\n# compound = pcq.compound(cid)\r\n\r\n# name\r\n\r\nname = '2-acetyloxybenzoic acid'\r\n\r\ncompound = pcq.compound(name)\r\n\r\nprint(compound)\r\n\r\n# properties\r\n\r\n# InChI\r\n\r\nprint(compound.InChI)\r\n\r\n# InChIKey\r\n\r\nprint(compound.InChIKey)\r\n\r\n# IUPACName\r\n\r\nprint(compound.IUPACName)\r\n\r\n# similar structure cids\r\n\r\nprint(len(compound.similar_structure_cids))\r\n\r\n# image\r\n\r\ncompound.image\r\n\r\n# dataframe\r\n\r\ncompound.prop_df()\r\n\r\n```\r\n\r\n\r\n\r\n## FAQ\r\n\r\n\r\n\r\nFor any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) \r\n\r\n\r\n\r\n\r\n\r\n## Authors\r\n\r\n\r\n\r\n- [@sinagilassi](https://www.github.com/sinagilassi)\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python Package for Accessing Chemical Information from PubChem (https://pubchem.ncbi.nlm.nih.gov/).",
    "version": "1.5.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        " pubchem",
        " pubchemapi",
        " pubchemquery",
        " pubchemquery"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "16ba531ce538a715e96a8cfad7d425aceddbc90e33a0f17f03b428768885255d",
                "md5": "615eb7b0ea82bcd36498574bb234bf79",
                "sha256": "f9ea581da6d7307ac4ce1e5dabeba6d74b01c214622a9e4842539fd1c409b870"
            },
            "downloads": -1,
            "filename": "PubChemQuery-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "615eb7b0ea82bcd36498574bb234bf79",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15288,
            "upload_time": "2024-07-31T01:50:02",
            "upload_time_iso_8601": "2024-07-31T01:50:02.626089Z",
            "url": "https://files.pythonhosted.org/packages/16/ba/531ce538a715e96a8cfad7d425aceddbc90e33a0f17f03b428768885255d/PubChemQuery-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c065bc4a35d28a3d6d597fde7ad6a14cff72c838e87330210157405e46d74a9",
                "md5": "7393a74db4a0fce9afce4fdc65d1f531",
                "sha256": "dd71d568f525c8b8a74d4ac4d7357f06822bee0cdf7ffe943a0d834d5c615e07"
            },
            "downloads": -1,
            "filename": "pubchemquery-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7393a74db4a0fce9afce4fdc65d1f531",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 14429,
            "upload_time": "2024-07-31T01:50:04",
            "upload_time_iso_8601": "2024-07-31T01:50:04.409493Z",
            "url": "https://files.pythonhosted.org/packages/6c/06/5bc4a35d28a3d6d597fde7ad6a14cff72c838e87330210157405e46d74a9/pubchemquery-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-31 01:50:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pubchemquery"
}
        
Elapsed time: 0.42042s