rcsb-api 0.3.0

Creator: railscoderz

Last updated:

Add to Cart

Description:

rcsbapi 0.3.0

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
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 .

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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.