Skip to main content

Python package interface for the RCSB PDB search API service

Project description

PyPi Release Build Status Documentation Status Code style: black Binder

rcsbsearchapi

Python interface for the RCSB PDB Search API.

Currently the 'text search' part of the API has been implemented. See 'Supported features' below.

This package requires python 3.7 or later.

Example

Here is a quick example of how the package is used. Two syntaxes are available for constructing queries: an "operator" API using python's comparators, and a "fluent" syntax where terms are chained together. Which to use is a matter of preference.

A runnable jupyter notebook with this example is available in notebooks/quickstart.ipynb, or can be run online using binder: Binder

An additional example including a Covid-19 related example is in notebooks/covid.ipynb: Binder

Operator example

Here is an example from the RCSB PDB Search API page, using the operator syntax. This query finds symmetric dimers having a twofold rotation with the DNA-binding domain of a heat-shock transcription factor.

from rcsbsearchapi import TextQuery
from rcsbsearchapi import rcsb_attributes as attrs

# Create terminals for each query
q1 = TextQuery('"heat-shock transcription factor"')
q2 = attrs.rcsb_struct_symmetry.symbol == "C2"
q3 = attrs.rcsb_struct_symmetry.kind == "Global Symmetry"
q4 = attrs.rcsb_entry_info.polymer_entity_count_DNA >= 1

# combined using bitwise operators (&, |, ~, etc)
query = q1 & q2 & q3 & q4  # AND of all queries

# Call the query to execute it
for assemblyid in query("assembly"):
    print(assemblyid)

For a full list of attributes, please refer to the RCSB PDB schema.

Fluent Example

Here is the same example using the fluent syntax.

from rcsbsearchapi import TextQuery

# Start with a Attr or TextQuery, then add terms
results = TextQuery('"heat-shock transcription factor"') \
    .and_("rcsb_struct_symmetry.symbol").exact_match("C2") \
    .and_("rcsb_struct_symmetry.kind").exact_match("Global Symmetry") \
    .and_("rcsb_entry_info.polymer_entity_count_DNA").greater_or_equal(1) \
    .exec("assembly")

# Exec produces an iterator of IDs
for assemblyid in results:
    print(assemblyid)

Supported Features

The following table lists the status of current and planned features.

  • Attribute Comparison operations
  • Query set operations
  • Attribute contains, in_ (fluent only)
  • Sequence search
  • Sequence motif search
  • Structural search
  • Structural motif search
  • Chemical search
  • Rich results using the Data API

Contributions are welcome for unchecked items!

Installation

Get it from pypi:

pip install rcsbsearchapi

Or, download from github

Documentation

Detailed documentation is at rcsbsearchapi.readthedocs.io

License

Code is licensed under the BSD 3-clause license. See LICENSE for details.

Citing rcsbsearchapi

Please cite the rcsbsearchapi package by URL:

https://rcsbsearchapi.readthedocs.io

You should also cite the RCSB PDB service this package utilizes:

Yana Rose, Jose M. Duarte, Robert Lowe, Joan Segura, Chunxiao Bi, Charmi Bhikadiya, Li Chen, Alexander S. Rose, Sebastian Bittrich, Stephen K. Burley, John D. Westbrook. RCSB Protein Data Bank: Architectural Advances Towards Integrated Searching and Efficient Access to Macromolecular Structure Data from the PDB Archive, Journal of Molecular Biology, 2020. DOI: 10.1016/j.jmb.2020.11.003

Attributions

The source code for this project was originally written by Spencer Bliven and forked from https://github.com/sbliven/rcsbsearch. We would like to express our tremendous gratitude for his generous efforts in designing such a comprehensive public utility Python package for interacting with the RCSB PDB search API, rcsbsearch.

Developers

For information about building and developing rcsbsearchapi, see CONTRIBUTING.md

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

rcsbsearchapi-1.0.0.tar.gz (138.3 kB view details)

Uploaded Source

File details

Details for the file rcsbsearchapi-1.0.0.tar.gz.

File metadata

  • Download URL: rcsbsearchapi-1.0.0.tar.gz
  • Upload date:
  • Size: 138.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for rcsbsearchapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e0a868c1ecc39d804c328a0637d3ff58818c365fe8d355e2bf27027f4f714b12
MD5 f0ee0d53ca3d4adae513f8d448f93c07
BLAKE2b-256 d4f895dceeb225f0de04ea75b538bc3c670e4302ffe8b59a81304370a03739e0

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