A gate for biological inputs: validate identifiers and inputs the same way in R and Python.
Project description
biobouncer 
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.
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
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 biobouncer-0.1.2.tar.gz.
File metadata
- Download URL: biobouncer-0.1.2.tar.gz
- Upload date:
- Size: 532.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492b83c4cec8b9b54ab71c3fe09d9d5d66c057681f9269c9b37cc1847abcc302
|
|
| MD5 |
5a658d35d9c1a65f79ec6ecc28123258
|
|
| BLAKE2b-256 |
acc516db85a0771491aa3617106bfa0cfb9c5ab4f98fe181afb9a7e747e7a4b4
|
Provenance
The following attestation bundles were made for biobouncer-0.1.2.tar.gz:
Publisher:
release-py.yml on samuelbharti/biobouncer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biobouncer-0.1.2.tar.gz -
Subject digest:
492b83c4cec8b9b54ab71c3fe09d9d5d66c057681f9269c9b37cc1847abcc302 - Sigstore transparency entry: 2189772942
- Sigstore integration time:
-
Permalink:
samuelbharti/biobouncer@9e792b02c3ec34939f959c1a079bfce7d47e82a3 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/samuelbharti
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-py.yml@9e792b02c3ec34939f959c1a079bfce7d47e82a3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file biobouncer-0.1.2-py3-none-any.whl.
File metadata
- Download URL: biobouncer-0.1.2-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.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9409a1dcf325a08481619e85528d5233991737d6c1c838ee3c17419e5e89f504
|
|
| MD5 |
e8410f1f114aba92c0cb5cb9f9f1dde0
|
|
| BLAKE2b-256 |
82365777466b257dfa7cbd31838dac5e84874801dbd381793e21408316977f8c
|
Provenance
The following attestation bundles were made for biobouncer-0.1.2-py3-none-any.whl:
Publisher:
release-py.yml on samuelbharti/biobouncer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
biobouncer-0.1.2-py3-none-any.whl -
Subject digest:
9409a1dcf325a08481619e85528d5233991737d6c1c838ee3c17419e5e89f504 - Sigstore transparency entry: 2189772953
- Sigstore integration time:
-
Permalink:
samuelbharti/biobouncer@9e792b02c3ec34939f959c1a079bfce7d47e82a3 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/samuelbharti
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-py.yml@9e792b02c3ec34939f959c1a079bfce7d47e82a3 -
Trigger Event:
release
-
Statement type: