BioSieve
BioSieve is a Python toolkit for preparing biological sequence datasets for machine learning.
It covers two main workflows:
- Redundancy reduction — remove near-duplicate sequences before training using sequence, embedding, descriptor, or structural similarity
- Leakage-aware splitting — partition datasets into train/val/test (or k-folds) with strategies that respect biological structure (homology clusters, sequence distance, groups, time)
Installation
BioSieve supports Python 3.11+.
pip install biosieve
Install optional extras as needed:
minhashfor approximate Jaccard-based deduplication (minhash_jaccardstrategy)faissfor GPU-accelerated embedding similarity search (embedding_cosinestrategy)
pip install 'biosieve[minhash]'
pip install 'biosieve[faiss]'
The mmseqs2 reducer and homology_aware splitter require the MMseqs2 binary
to be available in PATH.
Quick Start
Redundancy reduction
Remove near-duplicate sequences using k-mer Jaccard similarity:
biosieve reduce \
-i dataset.csv \
-o dataset_nr.csv \
--strategy kmer_jaccard \
--mapping-output mapping.csv \
--report-output report.json
Pass parameters via a YAML file:
biosieve reduce \
-i dataset.csv \
-o dataset_nr.csv \
--strategy kmer_jaccard \
--config params.yaml
# params.yaml
kmer_jaccard:
threshold: 0.8
k: 5
Check a params file without reading any data (exit 0 if valid, 2 if not; --json prints the problems as JSON):
biosieve validate-config params.yaml --strategy kmer_jaccard
Validate a config from Python (a mapping or a YAML/JSON path; returns a list of ConfigIssue(path, message), empty when valid):
from biosieve import validate_config
issues = validate_config("params.yaml", strategy="kmer_jaccard", kind="reduce")
Strategies that need input files take them as options: --embeddings (.npy or .npz) and --embedding-ids for embedding_cosine, --edges for structural_distance.
The ids file is <stem>.ids.txt (one id per line), a .npz with an ids array, or a CSV with an id column; when omitted, the .npz's own ids or the sibling <stem>.ids.txt are used.
Override a single parameter inline without a file:
biosieve reduce -i dataset.csv -o out.csv --strategy kmer_jaccard --set kmer_jaccard.threshold=0.9
Dataset splitting
Split with a leakage-aware strategy:
biosieve split \
-i dataset_nr.csv \
-o splits/ \
--strategy homology_aware \
--clusters clusters.csv \
--config params.yaml
# params.yaml
homology_aware:
mode: precomputed
clusters_format: csv
member_col: id
cluster_col: cluster_id
test_size: 0.2
Strategies
Redundancy reduction
| Strategy | Description | Extra needed |
|---|---|---|
exact |
Remove exact sequence duplicates | — |
identity_greedy |
Greedy reduction by sequence identity | — |
kmer_jaccard |
Greedy reduction by k-mer Jaccard similarity | — |
minhash_jaccard |
Approximate k-mer Jaccard via MinHash LSH (fast) | biosieve[minhash] |
embedding_cosine |
Cosine similarity on precomputed embeddings | biosieve[faiss] (optional) |
descriptor_euclidean |
Euclidean distance on numeric descriptor columns | — |
structural_distance |
Graph-based reduction on precomputed structural edges | — |
mmseqs2 |
Homology clustering via MMseqs2 | mmseqs binary |
Splitting
| Strategy | Description |
|---|---|
random |
Random train/val/test split |
stratified |
Stratified by a categorical label column |
stratified_numeric |
Stratified by a numeric label column (binned) |
group |
No group appears in more than one split |
time |
Chronological split by a time column |
cluster_aware |
Group split using a precomputed cluster column |
distance_aware |
Test set selected as farthest points in embedding/descriptor space |
homology_aware |
Group split derived from MMseqs2 clusters or precomputed clusters |
All strategies also support k-fold variants (random_kfold, stratified_kfold, group_kfold,
stratified_numeric_kfold, distance_aware_kfold).
Outputs
Every run produces consistent artefacts:
- Reduced or split tables, CSV or Parquet (by the output extension for
reduce, by the input format forsplit), with the id column first - Mapping CSV (
removed_id,representative_id,cluster_id,score) for reduction runs - JSON report with the tool version, strategy name, effective parameters, and reduction/split statistics
- Provenance sidecar following the shared ecosystem CLI contract:
<output>.provenance.jsonforreduceand<outdir>.provenance.jsonforsplit
Exit codes: 0 success, 2 invalid config or usage (also validate-inputs failures), 3 runtime or data failure, 4 internal error.
homology_aware runs MMseqs2 in a temporary directory unless work_dir is set; keep_work: true keeps it.
Learn More
- examples/README.md for runnable scripts and config files
Citation
If you use BioSieve in your research, please cite:
Fernández Villegas, D.; Álvarez Saravia, D.; Medina-Ortiz, D. BioSieve: Redundancy Reduction and Leakage-Aware Dataset Partitioning for Biological ML. Version 0.1.2, 2026. Zenodo. https://doi.org/10.5281/zenodo.21930919
@software{biosieve2026,
author = {Fernández Villegas, Diego and Álvarez Saravia, Diego and Medina-Ortiz, David},
title = {{BioSieve}: Redundancy Reduction and Leakage-Aware Dataset Partitioning for Biological ML},
year = {2026},
version = {0.1.2},
publisher = {Zenodo},
doi = {10.5281/zenodo.21930919},
url = {https://doi.org/10.5281/zenodo.21930919}
}
To cite this exact release, use the version DOI 10.5281/zenodo.21930920. Machine-readable metadata lives in CITATION.cff.
License
MIT. See LICENSE.
Acknowledgements
Built on top of scikit-learn, polars, NumPy, and optionally datasketch, FAISS, and MMseqs2.
Developed by KREN AI Lab at Universidad de Magallanes, Chile.
Metadata
Release files for biosieve 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| biosieve-0.2.0.tar.gz | 61.9 kB | With provenance | Details for biosieve-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| biosieve-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for biosieve-0.2.0-py3-none-any.whl |
Total release size: 164.0 kB
Release files / biosieve-0.2.0.tar.gz
| Download URL | biosieve-0.2.0.tar.gz |
|---|---|
| Size | 61.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a16f340a48affbfeaa2790124f3bb31d9b770e83a243a624c5b64c534edcdcbc
|
|
BLAKE2b-256 checksum How to use checksums |
ddd778f41d252e3675333bec938a305133e426401dab535eccb78d000241e57e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logRelease files / biosieve-0.2.0-py3-none-any.whl
| Download URL | biosieve-0.2.0-py3-none-any.whl |
|---|---|
| Size | 102.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4acffe6ead59abbf05341725a7fedc63d376330e111ab556cd54cbc295bcecf6
|
|
BLAKE2b-256 checksum How to use checksums |
6d79eb2e4375beef39e239fada0e3597d73ab8553487821ad05c99920dba86f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logSecurity for biosieve 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for biosieve-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.