Skip to main content

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

License

Apache 2.0 — see LICENSE for details.

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

picsure-2.0.0.tar.gz (378.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

picsure-2.0.0-py3-none-any.whl (71.3 kB view details)

Uploaded Python 3

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

Hashes for picsure-2.0.0.tar.gz
Algorithm Hash digest
SHA256 363929b8bccbc32affce37082e0319fc6480015957e6733df63bbb609a59ecf2
MD5 185d314078ef5069c10d971ce9a3657e
BLAKE2b-256 91fe2e9ccdb081ea992464594dfadc0cdead5af1c6a95d918446048bd817796e

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for picsure-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e12cb08fbef7bb458a2becf309fa21710816674a54f69baad064192f2fc5f7b
MD5 c2c649764ac6593544ccf4be0fe47da3
BLAKE2b-256 ecc3f2f2d2c8c0686efbd43214d8aedeaf5a9be3e4f898b19f6ebd4bbde601d7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page