Skip to main content

A gate for biological inputs: validate identifiers and inputs the same way in R and Python.

Project description

biobouncer biobouncer logo

A gate for biological inputs. Validate gene symbols, ontology terms, variant formats, and database identifiers, the same way, with the same answer, in both R and Python.

DOI License: MIT

This is the Python package. A companion R package is built alongside it, and the two are held to the same verdict for the same input by a shared conformance corpus.

Status: pre-1.0. The public API is in use and documented. It may still change before the 1.0 release.

Install

pip install biobouncer

The framework adapters are optional extras:

pip install "biobouncer[adapters]"   # pandera and pydantic
pip install "biobouncer[gx]"         # Great Expectations
pip install "biobouncer[narwhals]"   # column checks over pandas, polars, or pyarrow

Usage

import biobouncer

# List what can be checked.
biobouncer.sources()

# pattern mode: is the string well-formed?
biobouncer.check_id(["MONDO:0005148", "mondo:5148"], source_db="mondo")

# cache mode: does the id exist in a pinned snapshot, offline?
biobouncer.check_id("MONDO:0005148", source_db="mondo", how="cache", version="sample")

check_id() returns a list of Result records, one per input, in the order given. A missing input stays missing rather than turning into a quiet False.

To validate and clean a whole column in one call:

r = biobouncer.report(["MONDO:0005148", "mondo:5148", "NOTANID", None], source_db="mondo")

r.summary
# {'total': 4, 'valid': 1, 'invalid': 2, 'repairable': 1, 'missing': 1, 'indeterminate': 0}

r.repair()  # substitute the repairable values, leave everything else alone
# ['MONDO:0005148', 'MONDO:0005148', 'NOTANID', None]

r.to_frame()  # a verdict table (pandas, polars, or pyarrow via narwhals)
#            input  valid     normalized     suggestion error
# 0  MONDO:0005148   True  MONDO:0005148            NaN  None
# 1     mondo:5148  False            NaN  MONDO:0005148  None
# 2        NOTANID  False            NaN            NaN  None
# 3            NaN   None            NaN            NaN  None

Checks run in four modes: pattern (offline shape), cache (offline existence against a pinned snapshot), remote (live existence against the source API), and existence (snapshot first, then remote). Snapshots ship with the package, so the offline modes work with no setup and no network. biobouncer.pull() refreshes one to a newer dated release when you want it.

There is also a biobouncer command line tool that exits non-zero on any invalid input, for use in a pipeline or in CI.

Documentation

Full documentation is at samuelbharti.com/biobouncer/py, including the source list, the caching and snapshot guide, and the adapter reference.

Contributing

The package is developed in the biobouncer monorepo alongside the R package and the shared spec. See CONTRIBUTING.md to get set up, and open an issue for a bug or a source request.

Citation

If you use biobouncer in your work, please cite it. The DOI above always resolves to the latest release; see CITATION.cff for the current version and a per-version DOI. A preprint is in preparation.

License

MIT. See LICENSE.

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

biobouncer-0.1.1.tar.gz (530.0 kB view details)

Uploaded Source

Built Distribution

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

biobouncer-0.1.1-py3-none-any.whl (624.8 kB view details)

Uploaded Python 3

File details

Details for the file biobouncer-0.1.1.tar.gz.

File metadata

  • Download URL: biobouncer-0.1.1.tar.gz
  • Upload date:
  • Size: 530.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for biobouncer-0.1.1.tar.gz
Algorithm Hash digest
SHA256 46215db9a924dbb1aa8515f803ec611ee8644eb9f1e4b8e7a6bdef94ae20554e
MD5 dd5e17f5fb03b0c75ed92523c404997b
BLAKE2b-256 0966b9650200c31c2a4370225269d68f0f5ceae20fc79cc6b4b6031f67dc1610

See more details on using hashes here.

Provenance

The following attestation bundles were made for biobouncer-0.1.1.tar.gz:

Publisher: release-py.yml on samuelbharti/biobouncer

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

File details

Details for the file biobouncer-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: biobouncer-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 624.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for biobouncer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ef715b26c0cd397ca6d6a9888c8020b2460d5f4773dc19ded53e84e033e1bf2
MD5 8ef445e41ac4611bea82828012df0a1e
BLAKE2b-256 eb68cbe7a1202d368ef2349121bc1bafeb75c0689d622bf32773352b92873cb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for biobouncer-0.1.1-py3-none-any.whl:

Publisher: release-py.yml on samuelbharti/biobouncer

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