PyPDB
A Python 3 toolkit for performing searches with the RCSB Protein Data Bank (PDB). This can be used to perform advanced searches for PDB IDs matching various criteria, as well as to look up information associated with specific PDB IDs. This tool allows standard operations that can be perfomed from within the PDB website (BLAST, PFAM lookup, etc.) to be performed from within Python scripts.
If you use this module for any published work, please consider citing the accompanying paper
Gilpin, W. "PyPDB: A Python API for the Protein Data Bank."
Bioinformatics, Oxford Journals, 2016.
Installation
Install using pip:
$ pip install pypdb
To install the development version, which contains the latest features and fixes, install directly from GitHub using
$ pip install git+https://github.com/williamgilpin/pypdb
To install from a local checkout,
$ pip install .
For development and test dependencies,
$ pip install -e ".[dev]"
Test the installation, and check that the code successfully connects to the PDB, navigate to the root directory and run
$ python -m pytest
This code has been designed and tested for Python 3.
Usage
PDB Text Search
This package can be used to get lists of PDB IDs associated with specific search terms, experiment types, structures, and other common criteria. To use the simple API, see the examples in demos/demos.ipynb. For advanced search and query logic, see the examples in search/EXAMPLES.md.
PDB Data Fetch
Given a list of PDBs, this package can be used to fetch data associated with those PDBs, including their dates of deposition, lists of authors and associated publications, their sequences or structures, their top BLAST matches, and other query-specific attributes like lists of a ligands or chemical structure. Integrated PubMed, UniProt, and structural interface data can be fetched as well. To use the simple API, see the examples in demos/demos.ipynb. For advanced search and query logic, see the examples in data/EXAMPLES.md.
Counting and paginating results
Searches return every matching entry by default, which can be slow for broad queries. To retrieve just a tally or the highest-scoring hits:
from pypdb import count_results, get_top_results
print(count_results("ribosome")) # 9560
print(get_top_results("crispr", max_results=5))
Searches can also be restricted to a page of results, scored with a particular strategy, or extended to include computed structure models (such as AlphaFold predictions) via RequestOptions. See search/EXAMPLES.md.
Releasing a new version
The git tag is the only place the version is written. To publish a release to PyPI, tag and push:
git tag v2.9 && git push origin v2.9
That's the whole process — there is no version file to edit. setuptools-scm derives the package version from the tag at build time and writes it into pypdb/_version.py, which is generated rather than checked in (it is listed in .gitignore).
Pushing a v* tag runs the tests, builds the distributions, and uploads them to PyPI. This uses PyPI Trusted Publishing, so no API token is stored in the repository — it requires a one-time publisher registration on PyPI pointing at the python-publish.yml workflow and the pypi environment.
Between releases, pypdb.__version__ reports a development version derived from the most recent tag (e.g. 2.9.dev1+g1a2b3c4).
Issues and Feature Requests
If you run into an issue, or if you find a workaround for an existing issue, please post your question or code as a GitHub issue.
If posting a feature request, please check that your request is possible using the current GUI on current RCSB website. If so, please perform your search, and then click the link that says JSON in the upper right hand corner of the Advanced Search box. Please post that JSON code with your feature request.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypdb-2.10.tar.gz.
File metadata
- Download URL: pypdb-2.10.tar.gz
- Upload date:
- Size: 225.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216536f0a919cd2841ead11cb1f553563a169871c0568b7e899c303c4b005d65
|
|
| MD5 |
b53906f94d21eafab4165c055bfe91e6
|
|
| BLAKE2b-256 |
f0e000b88210bc6984cb8145eab11b6598450a21b48ba1d083ba5f4676359034
|
Provenance
The following attestation bundles were made for pypdb-2.10.tar.gz:
Publisher:
python-publish.yml on williamgilpin/pypdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypdb-2.10.tar.gz -
Subject digest:
216536f0a919cd2841ead11cb1f553563a169871c0568b7e899c303c4b005d65 - Sigstore transparency entry: 2254558193
- Sigstore integration time:
-
Permalink:
williamgilpin/pypdb@858cc2f240d7f2f177016f20de1947d4c28865b4 -
Branch / Tag:
refs/tags/v2.10 - Owner: https://github.com/williamgilpin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@858cc2f240d7f2f177016f20de1947d4c28865b4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pypdb-2.10-py3-none-any.whl.
File metadata
- Download URL: pypdb-2.10-py3-none-any.whl
- Upload date:
- Size: 54.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
074ac1a1c8b1b9fe8cf5fd464c1eab362dbd46df87970296ad777adf9561ac16
|
|
| MD5 |
90d9d3f749f2486b4e63636396c60d06
|
|
| BLAKE2b-256 |
f59851f442c70b734f9e16090a3825cea7065f983451ff2c7b844e43283db9a0
|
Provenance
The following attestation bundles were made for pypdb-2.10-py3-none-any.whl:
Publisher:
python-publish.yml on williamgilpin/pypdb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pypdb-2.10-py3-none-any.whl -
Subject digest:
074ac1a1c8b1b9fe8cf5fd464c1eab362dbd46df87970296ad777adf9561ac16 - Sigstore transparency entry: 2254558439
- Sigstore integration time:
-
Permalink:
williamgilpin/pypdb@858cc2f240d7f2f177016f20de1947d4c28865b4 -
Branch / Tag:
refs/tags/v2.10 - Owner: https://github.com/williamgilpin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@858cc2f240d7f2f177016f20de1947d4c28865b4 -
Trigger Event:
push
-
Statement type: