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.3.tar.gz (532.3 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.3-py3-none-any.whl (626.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for biobouncer-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b5e0ae54eb40b08ad9039488feb5153d2f0137a838a1c965dfa3879567ba0ca2
MD5 18e57ebf8c554a4b250280ca94695d42
BLAKE2b-256 7eaea158dd0a9b4f32fb682acf56f7e7bfe99cf86dac0e89658c40ff0d0a683d

See more details on using hashes here.

Provenance

The following attestation bundles were made for biobouncer-0.1.3.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.3-py3-none-any.whl.

File metadata

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

File hashes

Hashes for biobouncer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1571c75a0b12a8bd34a30d7c62cc5bf1ffacbe50d01e0a41a6d2806175ce306b
MD5 7752cf887a00628c7c576427e61c8dce
BLAKE2b-256 c775d73d1fcb702a2cbe319af65633c23868239c494a74e0919f0004ad58bddc

See more details on using hashes here.

Provenance

The following attestation bundles were made for biobouncer-0.1.3-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