diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5028921..0851778 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Run tests +name: Tests on: push: @@ -13,6 +13,7 @@ concurrency: jobs: test: + name: test (py${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false diff --git a/.vscode/settings.json b/.vscode/settings.json index d08ec58..96c38a0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, "files.trimFinalNewlines": true, - "python.defaultInterpreterPath": "./venv/bin/python", + "python.defaultInterpreterPath": "./.venv/bin/python", "[python]": { "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [88] diff --git a/README.md b/README.md index 0e13c3a..9e9b088 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,11 @@ [![PyPI Version](https://img.shields.io/pypi/v/PubChemPy.svg?style=flat)](https://pypi.python.org/pypi/PubChemPy) [![License](https://img.shields.io/pypi/l/PubChemPy.svg?style=flat)](https://github.com/mcs07/PubChemPy/blob/main/LICENSE) +[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.541438.svg)](https://doi.org/10.5281/zenodo.593126) +[![Tests](https://github.com/mcs07/PubChemPy/actions/workflows/test.yml/badge.svg)](https://github.com/mcs07/PubChemPy/actions/workflows/test.yml) PubChemPy provides a way to interact with PubChem in Python. It allows chemical searches by name, substructure and similarity, chemical standardization, conversion between chemical file formats, depiction and retrieval of chemical properties. -```pycon ->>> from pubchempy import get_compounds, Compound ->>> comp = Compound.from_cid(1423) ->>> print(comp.smiles) -CCCCCCCNC1CCCC1CCCCCCC(=O)O ->>> comps = get_compounds('Aspirin', 'name') ->>> print(comps[0].xlogp) -1.2 -``` - ## Installation Install PubChemPy using: @@ -25,11 +17,36 @@ pip install pubchempy Alternatively, try one of the other [installation options](https://docs.pubchempy.org/en/latest/guide/install.html). +## Example usage + +Retrieve a compound by its PubChem Compound Identifier (CID) and print its SMILES and IUPAC name: + +```pycon +>>> import pubchempy as pcp +>>> comp = pcp.Compound.from_cid(1423) +>>> print(comp.smiles) +CCCCCCCNC1CCCC1CCCCCCC(=O)O +>>> print(comp.iupac_name) +7-[2-(heptylamino)cyclopentyl]heptanoic acid +``` + +Search compounds by name and print the SMILES and molecular weight of the first result: + +```pycon +>>> results = pcp.get_compounds("Aspirin", "name") +>>> print(results[0].smiles) +CC(=O)OC1=CC=CC=C1C(=O)O +>>> print(results[0].molecular_weight) +180.16 +``` + ## Documentation Full documentation is available at https://docs.pubchempy.org. -## Contribute +This includes a [step-by-step guide on how to use PubChemPy](https://docs.pubchempy.org/en/latest/guide/gettingstarted.html), as well as a [complete API reference](https://docs.pubchempy.org/en/latest/api.html). + +## Contributing - Feature ideas and bug reports are welcome on the [Issue Tracker](https://github.com/mcs07/PubChemPy/issues). - Fork the [source code](https://github.com/mcs07/PubChemPy) on GitHub, make changes and file a pull request. diff --git a/tests/test_download.py b/tests/test_download.py index 0e4c949..b96c3b7 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -1,7 +1,6 @@ """Test downloading.""" import csv -import os import pytest