Skip to main content

BioSieve

PyPI PyVersions Tests License

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:

  • minhash for approximate Jaccard-based deduplication (minhash_jaccard strategy)
  • faiss for GPU-accelerated embedding similarity search (embedding_cosine strategy)
pip install 'biosieve[minhash]'
pip install 'biosieve[faiss]'

The mmseqs2 reducer and homology_aware splitter require the MMseqs2 binary to be available in PATH.

[!TIP] You can install MMSeqs2 easily with pixi: pixi global install -c bioconda -c conda-forge mmseqs2.

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 \
  --params params.yaml
# params.yaml
kmer_jaccard:
  threshold: 0.8
  k: 5

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 \
  --params params.yaml
# params.yaml
homology_aware:
  mode: precomputed
  clusters_path: clusters.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 CSVs
  • Mapping CSV (removed_id, representative_id, cluster_id, score) for reduction runs
  • JSON report with strategy name, effective parameters, and reduction/split statistics

Learn More

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biosieve-0.1.1.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

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

biosieve-0.1.1-py3-none-any.whl (93.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biosieve-0.1.1.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for biosieve-0.1.1.tar.gz
Algorithm Hash digest
SHA256 13547e9c7372eafaa00c366cf27687cd1c3c6e1b8e3413eaa48ad1036159c630
MD5 a97ca08e06a84af86a7548f5c11f847e
BLAKE2b-256 921b3bd9bf8eebca64fe02f4a7fed5996f1ac2934c0de6eea01886d896c11dc4

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on kren-ai-lab/biosieve

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

File details

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

File metadata

  • Download URL: biosieve-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 93.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for biosieve-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfb4553ecf5c571c521626a4d5e6ca7cb0bc6730e32d61916a7f478afd9a0751
MD5 3b8189ae6c0cfc934f6fa51d3714816a
BLAKE2b-256 55ba6cb5dc3740703d9f4dbafa42c64fe71d8b1e48e0907b81d0affebe6cfca0

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.yml on kren-ai-lab/biosieve

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

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page