Skip to main content

Python package interface for RCSB.org API services

Project description

PyPi Release Build Status Documentation Status

rcsb-api

Python interface for RCSB PDB API services at RCSB.org.

This package requires Python 3.7 or later.

Installation

Get it from PyPI:

pip install rcsb-api

Or, download from GitHub

Getting Started

Full documentation available at readthedocs.

The RCSB PDB Data API supports requests using GraphQL, a language for API queries. This package simplifies generating queries in GraphQL syntax.

In GraphQL, you must begin your query at specific fields. These "input_types" are fields like entry, polymer_entity, and polymer_entity_instance . You request data through the "return_data_list" argument. Available data can be explored with the GraphiQL editor's documentation explorer.

Examples

This is a simple query requesting the experimental method of a structure with PDB ID 4HHB (Hemoglobin).

The query must be executed using the .exec() method, which will return the JSON response as well as store the response as an attribute of the Query object. From the object, you can access the Data API response, get an interactive editor link, or access the arguments used to create the query.

from rcsbapi.data import Query
query = Query(
    input_type="entry",
    input_ids={"entry_id": "4HHB"},
    return_data_list=["exptl.method"]
)
print(query.exec())

Data is returned in JSON format

{"data": {"entry": {"exptl": [{"method": "X-RAY DIFFRACTION"}]}}}

Here is a more complex query. Note that periods can be used to further specify requested data in return_data_list. Also note multiple return data items and ids can be requested in one query.

from rcsbapi.data import Query
query = Query(
    input_type="polymer_entities",
    input_ids=["2CPK_1", "3WHM_1", "2D5Z_1"],
    return_data_list=[
        "polymer_entities.rcsb_id",
        "rcsb_entity_source_organism.ncbi_taxonomy_id",
        "rcsb_entity_source_organism.ncbi_scientific_name",
        "cluster_id",
        "identity"
    ]
)
print(query.exec())

Jupyter Notebooks

A notebook briefly summarizing the readthedocs is available in notebooks/quickstart.ipynb or online through Google Colab Open In Colab

Another notebook using both Search and Data API packages for a COVID-19 related example is available in notebooks/search_data_workflow.ipynb or online through Google Colab Open In Colab.


Learn about more features and troubleshooting at the readthedocs page and walk through some examples using the Juptyer notebooks!

Project details


Download files

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

Source Distribution

rcsb_api-0.3.0.tar.gz (280.0 kB view details)

Uploaded Source

Built Distribution

rcsb_api-0.3.0-py2.py3-none-any.whl (293.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rcsb_api-0.3.0.tar.gz.

File metadata

  • Download URL: rcsb_api-0.3.0.tar.gz
  • Upload date:
  • Size: 280.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for rcsb_api-0.3.0.tar.gz
Algorithm Hash digest
SHA256 bf56ab08a0f1ae8224fe302aa1d1f78b6956e3377bf417aebf980f1a39cfa2df
MD5 f03f93e1415f83842986b63224224804
BLAKE2b-256 26f40c778c2ec297c57c6d41163cc43b784e63094d585397bb508ab4a7bbe963

See more details on using hashes here.

File details

Details for the file rcsb_api-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: rcsb_api-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 293.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for rcsb_api-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 80d65c0d2fe1b9e2a34e6837703a9879305ec434bd8662a31fffab6ea1221419
MD5 5f5cdb4dd12add151c97fa949679a80d
BLAKE2b-256 61013d9382b403fe98e704c88722c6a9f65df327639ef9e2065155d48c5cc972

See more details on using hashes here.

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