Access the RCSB Search API
Project description
rcsbsearch
Python interface for the RCSB search API.
Currently the 'text search' part of the API has been implemented.
This package requires python 3.7 or later.
Usage
Searches are built up from a series of Terminal
nodes. For example:
from rcsbsearch import Terminal
q1 = Terminal("rcsb_struct_symmetry.symbol", "exact_match", "C2")
q2 = Terminal("rcsb_struct_symmetry.kind", "exact_match", "Global Symmetry")
q3 = Terminal(value='"heat-shock transcription factor"')
q4 = Terminal("rcsb_entry_info.polymer_entity_count_DNA", "greater_or_equal", 1)
These are combined using python's bitwise operators as if they were set
s of results:
q = q1 & q2 & q3 & q4 # AND of all queries
AND (&
), OR (|
), and terminal negation (~
) are implemented directly by the API,
but the python package also implements set difference (-
), symmetric difference (^
),
and general negation by transforming the query.
Queries are executed by calling them as functions. They return an iterator of result identifiers. Paging is handled transparently by the query.
results = set(q())
By default PDB IDs are returned, but other result types are also supported:
results = set(q("assembly"))
More control is available by executing the query using a Session object. For
instance, the Session.iquery()
returns a list of all results. It uses the optional
tqdm
package to track the progress of the query interactively.
from rcsbsearch import Session
session = Session(q)
results = session.iquery()
Tests are run using tox and/or pytest.
tox -e py37
or directly:
pytest
Code Style
Code conforms to the black
and PEP8 style guides. Before checking in code, please run the linters:
black .
flake8
mypy rcsbsearch
These are tested by the 'lint' tox environment:
tox -e lint
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file rcsbsearch-0.1.0.tar.gz
.
File metadata
- Download URL: rcsbsearch-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1.post20200515 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4423bd0c8c9780f8fb611eee2a701b7ff2ef554d78184d70c3b0cc2f43ebcb11 |
|
MD5 | 7a4b4ee39de6bca2cd45aa046a6b9820 |
|
BLAKE2b-256 | 78547f5d7cde6e4aeaacce4400a52695da16af91ece863b834537a492b9d9e80 |
File details
Details for the file rcsbsearch-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: rcsbsearch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.3.1.post20200515 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 474cf556a2fee61948a8dabbfe6b662650f83530defe70a915eab40eabd024cd |
|
MD5 | d30793998e3e8b81a26ae76a755416cf |
|
BLAKE2b-256 | e10a3606600b71ccaf3e215c4e03c5a706a11b8c3ccdabdc49a461b992ba8aa2 |