Python client for the PIC-SURE API
Project description
picsure
Python client for the PIC-SURE API. Search the data dictionary, build cohort queries with nested AND/OR filters, and export participant-level data — all from a Jupyter notebook.
Installation
pip install picsure
For PFB export support:
pip install picsure[pfb]
Quickstart
import picsure
from picsure import PhenotypicFilterType, GroupOperator
# Connect to PIC-SURE
session = picsure.connect(platform=picsure.Platform.BDC_AUTHORIZED, token="your-token")
# Search the data dictionary
results = session.searchDictionary("blood pressure")
# Build a query
sex = picsure.buildClause("\\phs1\\sex\\", type=PhenotypicFilterType.FILTER, categories="Male")
age = picsure.buildClause("\\phs1\\age\\", type=PhenotypicFilterType.FILTER, min=40)
query = picsure.buildClauseGroup([sex, age], operator=GroupOperator.AND)
# Run and export
count_result = session.runQuery(query, type="count")
count = count_result.value # None if suppressed; check count_result.cap
df = session.runQuery(query, type="participant")
session.exportCSV(df, "cohort.csv")
Genomic Filtering
On genomic-capable platforms (BDC_AUTHORIZED, NHANES_AUTHORIZED), you can filter by gene, consequence, and variant frequency, and discover valid values for any genomic key:
import picsure
gene_filter = picsure.buildGenomicFilter(
key=picsure.GenomicFilterKey.GENE_WITH_VARIANT, values="BRCA2"
)
freq_filter = picsure.buildGenomicFilter(
key=picsure.GenomicFilterKey.VARIANT_FREQUENCY_AS_TEXT,
values=picsure.VariantFrequency.RARE,
)
# Variant severity is a virtual key -> expands to Variant_consequence_calculated
severe_filter = picsure.buildGenomicFilter(
key=picsure.GenomicFilterKey.VARIANT_SEVERITY,
values=picsure.VariantSeverity.HIGH,
)
# Genomic-only query
genomic_query = picsure.buildQuery(genomicFilters=[gene_filter, freq_filter])
count_result = session.runQuery(genomic_query, type="count")
# Discover valid values for a genomic key
df = session.searchGenomicValues("Gene_with_variant", query="BRCA")
# Offline list of all variant consequences with severity
consequences = picsure.genomicConsequences()
Documentation
- Getting Started — connect and run your first query
- Search & Facets — search the dictionary with facet filters
- Building Queries - nested AND/OR clause groups, genomic filters
- Running & Exporting — counts, DataFrames, CSV/TSV/PFB
- API Reference — complete function documentation
- Migration Guide — upgrading from PicSureHpdsLib
- Changelog — release history and notable changes
License
Apache 2.0 — see LICENSE for details.
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
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 picsure-2.0.0.tar.gz.
File metadata
- Download URL: picsure-2.0.0.tar.gz
- Upload date:
- Size: 378.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363929b8bccbc32affce37082e0319fc6480015957e6733df63bbb609a59ecf2
|
|
| MD5 |
185d314078ef5069c10d971ce9a3657e
|
|
| BLAKE2b-256 |
91fe2e9ccdb081ea992464594dfadc0cdead5af1c6a95d918446048bd817796e
|
Provenance
The following attestation bundles were made for picsure-2.0.0.tar.gz:
Publisher:
release.yml on hms-dbmi/pic-sure-python-adapter-hpds
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
picsure-2.0.0.tar.gz -
Subject digest:
363929b8bccbc32affce37082e0319fc6480015957e6733df63bbb609a59ecf2 - Sigstore transparency entry: 2168656013
- Sigstore integration time:
-
Permalink:
hms-dbmi/pic-sure-python-adapter-hpds@b074098f92f590edb938ddb9768d07c3a1b8f359 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/hms-dbmi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b074098f92f590edb938ddb9768d07c3a1b8f359 -
Trigger Event:
push
-
Statement type:
File details
Details for the file picsure-2.0.0-py3-none-any.whl.
File metadata
- Download URL: picsure-2.0.0-py3-none-any.whl
- Upload date:
- Size: 71.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e12cb08fbef7bb458a2becf309fa21710816674a54f69baad064192f2fc5f7b
|
|
| MD5 |
c2c649764ac6593544ccf4be0fe47da3
|
|
| BLAKE2b-256 |
ecc3f2f2d2c8c0686efbd43214d8aedeaf5a9be3e4f898b19f6ebd4bbde601d7
|
Provenance
The following attestation bundles were made for picsure-2.0.0-py3-none-any.whl:
Publisher:
release.yml on hms-dbmi/pic-sure-python-adapter-hpds
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
picsure-2.0.0-py3-none-any.whl -
Subject digest:
0e12cb08fbef7bb458a2becf309fa21710816674a54f69baad064192f2fc5f7b - Sigstore transparency entry: 2168656171
- Sigstore integration time:
-
Permalink:
hms-dbmi/pic-sure-python-adapter-hpds@b074098f92f590edb938ddb9768d07c3a1b8f359 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/hms-dbmi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b074098f92f590edb938ddb9768d07c3a1b8f359 -
Trigger Event:
push
-
Statement type: