CBBIO/BioData

Python

1

22 commits

updated Sep 30, 2026

See the code

README

BioData

Utilities for working with a PostgreSQL BioData database, protein language model embeddings (pgvector), residue-level probing tasks, and GO/Taxonomy analysis.

What Is In This Repo

PathDescription
CBBIO/BioData.pyPostgreSQL client (BioDataClient) for proteins, embeddings, neighbor search, and GO annotations
CBBIO/embeddings/Model-agnostic embedding generation: adapters, batching, pooling, I/O
CBBIO/probing/Supervised probing tasks, dataset catalog, residue/protein-level benchmarks
CBBIO/search/Search backend routing (pgvector, FAISS, cuVS, Torch GPU)
CBBIO/GO.pyGO ontology utilities (GOOntology) built on goatools
CBBIO/Taxonomy.pyTaxonomy utilities (TaxonomyOntology) for NCBI taxdump
CBBIO/similarity.pyPairwise sequence alignment via parasail
sql/schema.sqlDatabase schema
config.yaml.exampleDatabase and search configuration template
docs/Full documentation for all modules
notebooks/data/Small notebook input assets tracked with the repo
tests/assets/Test configuration templates and fixtures

Quick Start

from CBBIO import connect, Generator, FastaBatcher, EmbeddingWriter, run_embedding_generation

# Connect to the database
client = connect()
client.health_check()

# Generate embeddings from a FASTA file
generator = Generator(model_class="esm2", device="cuda:0")
batcher   = FastaBatcher("proteins.fasta", max_batch_tokens=32_768)
writer    = EmbeddingWriter(format="h5", path="embeddings.h5")
run_embedding_generation(generator, batcher, writer, layer_index=33)

# Nearest-neighbor search
neighbors = client.find_nearest_neighbors(query_emb, embedding_type_id=1, layer_index=33, k=20)

See docs/GettingStarted.md for a full tutorial covering all modules.


Installation

From GitHub

pip install "biodata @ git+ssh://[email protected]/cbbio/BioData.git@main"

Optional extras:

pip install "biodata[notebooks] @ git+ssh://[email protected]/cbbio/BioData.git@main"
pip install "biodata[dev] @ git+ssh://[email protected]/cbbio/BioData.git@main"

From a local clone

pip install .           # runtime only
pip install ".[dev]"    # with dev tools

Database Setup

1. Start PostgreSQL + pgvector

docker run -d --name pgvectorsql \
  -e POSTGRES_USER=biodata \
  -e POSTGRES_PASSWORD=secret \
  -e POSTGRES_DB=biodata \
  -p 5432:5432 \
  pgvector/pgvector:pg16

2. Create the extension and schema

PGPASSWORD=secret psql -h localhost -U biodata -d biodata \
  -c "CREATE EXTENSION IF NOT EXISTS vector;"

PGPASSWORD=secret psql -h localhost -U biodata -d biodata -f sql/schema.sql

3. Restore a dataset (optional)

PGPASSWORD=secret pg_restore -h localhost -U biodata -d biodata /path/to/BioData.backup

Configuration

Copy the untracked template to config.yaml (or pass config_path= to connect()):

cp config.yaml.example config.yaml
database:
  host: localhost
  port: 5432
  user: biodata
  password: ""
  name: biodata

search:
  default_metric: cosine    # l2 | cosine | inner_product
  default_k: 10

Environment variable overrides (highest precedence):

VariableOverrides
BIODATA_DB_HOSTdatabase.host
BIODATA_DB_PORTdatabase.port
BIODATA_DB_USERdatabase.user
BIODATA_DB_PASSWORDdatabase.password
BIODATA_DB_NAMEdatabase.database
BIODATA_AUTOCOMMITclient.autocommit
BIODATA_SEARCH_METRICsearch.default_metric
BIODATA_SEARCH_Ksearch.default_k

Documentation

Browse the published API reference on Read the Docs.

TopicDocument
Agent quick startdocs/AgentQuickStart.md
Agent workflow recipesdocs/AgentWorkflows.md
Agent public API mapdocs/AgentApiMap.md
Agent example promptsdocs/AgentExamplePrompts.md
Agent code examplesdocs/examples/README.md
Getting started tutorialdocs/GettingStarted.md
Search benchmarksdocs/Benchmarks.md
Embedding generationdocs/Embeddings.md
Probing tasks and benchmarksdocs/Probing.md
Database client and searchdocs/BioData.md
GO ontology and similaritydocs/GO.md
Taxonomydocs/Taxonomy.md
Sequence alignmentdocs/Similarity.md
Coding style guidedocs/STYLE.md
Documentation style guidedocs/STYLE_DOCS.md
Test style guidedocs/STYLE_TESTS.md
Versioning and branching guidedocs/STYLE_VERSIONING.md

Running Tests

poetry run pytest -q

Integration tests (real DB required)

cp tests/assets/config_test.yaml.example config_test.yaml
# edit with your test DB credentials
poetry run pytest -q tests/test_biodata_integration.py

Override config path: BIODATA_TEST_CONFIG=/path/to/config_test.yaml.

Coverage

poetry run pytest --cov=CBBIO --cov-report=term-missing -q

Type checking

poetry run pyright

CBBIO/BioData

Python

1

22 commits

updated Sep 30, 2026

See the code

README

BioData

Utilities for working with a PostgreSQL BioData database, protein language model embeddings (pgvector), residue-level probing tasks, and GO/Taxonomy analysis.

What Is In This Repo

PathDescription
CBBIO/BioData.pyPostgreSQL client (BioDataClient) for proteins, embeddings, neighbor search, and GO annotations
CBBIO/embeddings/Model-agnostic embedding generation: adapters, batching, pooling, I/O
CBBIO/probing/Supervised probing tasks, dataset catalog, residue/protein-level benchmarks
CBBIO/search/Search backend routing (pgvector, FAISS, cuVS, Torch GPU)
CBBIO/GO.pyGO ontology utilities (GOOntology) built on goatools
CBBIO/Taxonomy.pyTaxonomy utilities (TaxonomyOntology) for NCBI taxdump
CBBIO/similarity.pyPairwise sequence alignment via parasail
sql/schema.sqlDatabase schema
config.yaml.exampleDatabase and search configuration template
docs/Full documentation for all modules
notebooks/data/Small notebook input assets tracked with the repo
tests/assets/Test configuration templates and fixtures

Quick Start

from CBBIO import connect, Generator, FastaBatcher, EmbeddingWriter, run_embedding_generation

# Connect to the database
client = connect()
client.health_check()

# Generate embeddings from a FASTA file
generator = Generator(model_class="esm2", device="cuda:0")
batcher   = FastaBatcher("proteins.fasta", max_batch_tokens=32_768)
writer    = EmbeddingWriter(format="h5", path="embeddings.h5")
run_embedding_generation(generator, batcher, writer, layer_index=33)

# Nearest-neighbor search
neighbors = client.find_nearest_neighbors(query_emb, embedding_type_id=1, layer_index=33, k=20)

See docs/GettingStarted.md for a full tutorial covering all modules.


Installation

From GitHub

pip install "biodata @ git+ssh://[email protected]/cbbio/BioData.git@main"

Optional extras:

pip install "biodata[notebooks] @ git+ssh://[email protected]/cbbio/BioData.git@main"
pip install "biodata[dev] @ git+ssh://[email protected]/cbbio/BioData.git@main"

From a local clone

pip install .           # runtime only
pip install ".[dev]"    # with dev tools

Database Setup

1. Start PostgreSQL + pgvector

docker run -d --name pgvectorsql \
  -e POSTGRES_USER=biodata \
  -e POSTGRES_PASSWORD=secret \
  -e POSTGRES_DB=biodata \
  -p 5432:5432 \
  pgvector/pgvector:pg16

2. Create the extension and schema

PGPASSWORD=secret psql -h localhost -U biodata -d biodata \
  -c "CREATE EXTENSION IF NOT EXISTS vector;"

PGPASSWORD=secret psql -h localhost -U biodata -d biodata -f sql/schema.sql

3. Restore a dataset (optional)

PGPASSWORD=secret pg_restore -h localhost -U biodata -d biodata /path/to/BioData.backup

Configuration

Copy the untracked template to config.yaml (or pass config_path= to connect()):

cp config.yaml.example config.yaml
database:
  host: localhost
  port: 5432
  user: biodata
  password: ""
  name: biodata

search:
  default_metric: cosine    # l2 | cosine | inner_product
  default_k: 10

Environment variable overrides (highest precedence):

VariableOverrides
BIODATA_DB_HOSTdatabase.host
BIODATA_DB_PORTdatabase.port
BIODATA_DB_USERdatabase.user
BIODATA_DB_PASSWORDdatabase.password
BIODATA_DB_NAMEdatabase.database
BIODATA_AUTOCOMMITclient.autocommit
BIODATA_SEARCH_METRICsearch.default_metric
BIODATA_SEARCH_Ksearch.default_k

Documentation

Browse the published API reference on Read the Docs.

TopicDocument
Agent quick startdocs/AgentQuickStart.md
Agent workflow recipesdocs/AgentWorkflows.md
Agent public API mapdocs/AgentApiMap.md
Agent example promptsdocs/AgentExamplePrompts.md
Agent code examplesdocs/examples/README.md
Getting started tutorialdocs/GettingStarted.md
Search benchmarksdocs/Benchmarks.md
Embedding generationdocs/Embeddings.md
Probing tasks and benchmarksdocs/Probing.md
Database client and searchdocs/BioData.md
GO ontology and similaritydocs/GO.md
Taxonomydocs/Taxonomy.md
Sequence alignmentdocs/Similarity.md
Coding style guidedocs/STYLE.md
Documentation style guidedocs/STYLE_DOCS.md
Test style guidedocs/STYLE_TESTS.md
Versioning and branching guidedocs/STYLE_VERSIONING.md

Running Tests

poetry run pytest -q

Integration tests (real DB required)

cp tests/assets/config_test.yaml.example config_test.yaml
# edit with your test DB credentials
poetry run pytest -q tests/test_biodata_integration.py

Override config path: BIODATA_TEST_CONFIG=/path/to/config_test.yaml.

Coverage

poetry run pytest --cov=CBBIO --cov-report=term-missing -q

Type checking

poetry run pyright