pg_bio is a native PostgreSQL extension written in highly optimized Rust (pgrx).
It is engineered for a single purpose: to completely eradicate the data bottlenecks in modern biology by pushing complex multiomics mathematics directly into the database engine. By unifying Genomics, Proteomics, and Transcriptomics into a shared computational space, pg_bio allows scientists to execute entire drug discovery pipelines and synthetic biology designs in milliseconds natively in SQL.
π The
pg_bioSynthetic Biology & Multiomics Ecosystem:
- Core Database Engine (Rust
pgrx+ PostgreSQL 18):jonatas/pg_bio(this repository β 3D Morton Octrees, PRISM + InlineBioVecInt8G128Vector Homology, RangeFinder 10 Γ Pocket GiST, Cheminformatics, and RK4 Solvers)- Declarative Bioprocess Compiler, Autonomous Protein Correlation Swarm & Unified Web UI:
jonatas/bio-pipelinesβ Multi-feedstock 4-Module ($M_1 \rightarrow M_2 \rightarrow M_3 \rightarrow M_4$ ) bioprocess compiler, autonomous dark-proteome discovery swarm (base/swarm_discovery.py), and live 3D Kabsch / RangeFinder / CETSA-TPP Explorer UI (base/swarm_web.py)- Original PTFE
$\rightarrow$ Fluorapatite Case Study:jonatas/teaflon(ideia.me/teaflon-intro)
π¬ Interactive Video Series & 3D Studio: "Hello World,
pg_bio!" New to computational biology or multiomics in PostgreSQL? Explore our narrated 1080p video series paired with interactive 3Dmol.js structures and Systems Engineer$\leftrightarrow$ Structural Biologist Rosetta Stone lenses:
- π Live 3D Video Library on
ideia.me: https://ideia.me/pg-bio-videos/- ποΈ Local Video & 3D Studio Catalog:
videos/README.mdΒ·videos/series_01_hello_world_pg_bio/index.html- Episodes:
- Ep 01: The Central Dogma in SQL (
int4rangeGiST & Sequence Physics) β MP4 Β· SQL- Ep 02: From 1D Strings to 3D Atoms with Morton Curves (
z_order_encode& SVD) β MP4 Β· SQL- Ep 03: Transcriptomics & CSR Sparse Attention Graphs (
SparseAttentionMap) β MP4 Β· SQL- Ep 04: The Multiomics Holy Grail β Vectors & Live UniProt (
halfvecHNSW) β MP4 Β· SQL
The ultimate frontier of biology is Multiomicsβthe fusion of DNA, RNA, and Protein data. Today, this is done using duct-tape pipelines:
- Downloading terabytes of sequence data from UniProt.
- Building an in-memory KD-Tree in Python to measure 3D distances.
- Using custom tools like
bedtoolsfor genomic overlaps. - Loading 20-billion-row RNA matrices into massive Pandas dataframes.
The result: The network I/O and RAM overhead crushes most laptops, and forces cloud deployments into hours of agonizing processing.
pg_bio eliminates this entire nightmare. It provides four distinct computational layers natively inside PostgreSQL. We move the compute directly to the data, resulting in order-of-magnitude speedups.
When engineering synthetic genes (e.g., bio-ceramics or CRISPR therapies), you must find a "Safe Harbor" in the genome. It must be near the correct tissue-specific promoter (to turn it on) but cannot overlap with any tumor suppressor genes (which could cause cancer).
- The Engine:
pg_biotreats the human genome as a 1D spatial environment utilizing native PostgreSQL Range Types (int4range) andGiST(Generalized Search Tree) indexes. - The Advantage: You can use native overlap operators (
&&) and adjacency operators (<->) to scan billions of base pairs in milliseconds. - SQL Example:
-- Instantly find a Safe Harbor insertion site next to the Nail Promoter, avoiding Cancer genes. SELECT safe.genomic_range FROM human_genome safe JOIN human_genome promoter ON safe.chromosome = promoter.chromosome WHERE safe.genomic_range <-> promoter.genomic_range < 5000 AND NOT EXISTS ( SELECT 1 FROM human_genome cancer_genes WHERE cancer_genes.feature_type = 'tumor_suppressor' AND safe.genomic_range && cancer_genes.genomic_range );
Once transcribed, linear sequences fold into 3D atomic structures. Finding which atoms are within a 4.0β10.0 Γ
ngstrom radius of a binding pocket usually requires extracting millions of coordinates into Python for brute-force Pythagorean mathβand a naive single-interval 1D Z-Order range (z_index BETWEEN min_z AND max_z) sweeps across thousands of false-positive atoms whenever the sphere crosses an octree boundary.
-
The Engine:
pg_biopairsz_order_encode(x, y, z)(64-bit Morton Coding / Z-Order curves interleaving 21-bit 3D coordinates) withz_order_layered_sphere_ranges(cx, cy, cz, r, max_ranges)βa 21-level 3D Octree Centroid Router that prunes disjoint octants ($d_{\min}^2 > R^2$ ), flags interior cubes ($d_{\max}^2 \le R^2$ ) to skipsqrt()rechecks, and coalesces the remaining leaf intervals into$\le 64$ tight B-tree Z-ranges. -
The Advantage: Across 200,000 atoms,
z_order_layered_sphere_rangesscans 74.05Γ fewer B-tree candidate rows (407.6vs.30,181atoms) and runs 10.25Γ faster (0.96 msvs.9.89 ms) with 100.0% exact mathematical recall. -
Reference Documentation & Benchmark:
docs/17_layered_centroids_multi_index_experiments.md|scripts/benchmark_layered_centroids_multi_index.py -
SQL Example:
-- Extracting a 10.0 Γ 3D Binding Pocket in 0.96 ms (74.05x fewer atoms scanned, 100% exact recall) SELECT a.atom_id, (a.coord).name FROM z_order_layered_sphere_ranges(10.0, 0.0, 25.0, 5.0, 64) r JOIN teaflon_atoms a ON a.z_curve_index BETWEEN r.min_z AND r.max_z WHERE r.fully_inside OR ((a.coord).x - 10.0)^2 + ((a.coord).y - 0.0)^2 + ((a.coord).z - 25.0)^2 <= 25.0;
To understand drug dosage, scientists use Single-Cell RNA-Seq. Humans have 20,000 genes. Sequencing 1 million cells creates a 20-Billion point matrix. Traditional SQL schemas grind to a halt.
- The Engine: Because a single cell only expresses ~2,000 genes at a time, the matrix is 85%+ zeroes.
pg_bioimplements Compressed Sparse Row (CSR) architecture natively using parallel PostgreSQL Arrays (expressed_gene_ids INT[]andexpression_counts REAL[]). - The Advantage: Storage overhead is slashed by 90%. Using parallel
LATERAL UNNEST() WITH ORDINALITY, PostgreSQL unpacks the sparse data dynamically in execution memory to calculate highly precise RNA dosage levels in milliseconds.
Traditionally, DNA sequences and 3D Protein folds live in different worlds. pg_bio breaks down that wall.
-
The Engine: By combining Tiger Data's
pg_vectorsearchPRISM index access method (1-bit RaBitQ quantization with theoretical error bounds, SOAR spill-orthogonal assignment, and hierarchical centroid routing) withpgvector'shalfvec(1280) STORAGE PLAINcolumns andpg_bio's<~>hybrid Smith-Waterman operator, we map Genomic Foundation Models (like Enformer) and Proteomic Foundation Models (like ESM-2) into a shared 1280-dimensional mathematical space. -
The Advantage: Across 2,340,766 UniProt proteins, PRISM shrinks the vector index by 9.72Γ (
8,772 MBHNSW$\rightarrow$ 902 MBPRISM), saves 7.65 GiB of total disk/RAM, builds in 3.08 minutes (down from 27 hours), and accelerates<=>cosine and<~>hybrid homology searches by 7.5Γ to 11.3Γ (26β37 msvs197β417 ms). -
Reference Documentation & Benchmark:
docs/16_pg_vectorsearch_vs_pgvector_benchmark.md|scripts/setup_and_benchmark_parallel_2m_proteome.py -
SQL Example:
-- Build a 902 MB PRISM index over 2.34M 1280-D protein embeddings in ~3 minutes: CREATE INDEX idx_proteins_prism_embedding ON proteins USING prism (embedding vec16_cosine_ops); -- Find which DNA enhancer matches the structural embedding of the P0DPB7 Protein: SELECT dna.locus, (dna.embedding <=> protein.embedding) as cross_omic_distance FROM dna_embeddings dna, proteins protein WHERE protein.uniprot_id = 'P0DPB7' ORDER BY cross_omic_distance ASC LIMIT 1;
Instead of relying on external Python scripts to fetch biological metadata, pg_bio contains a native Rust-powered synchronous HTTP client (ureq). It can fetch and parse JSON from the UniProt API directly into specialized PostgreSQL Composite Types dynamically.
-
The Engine: The
bio_fetch_uniprot()function queriesrest.uniprot.org, parses the JSON viaserde, and projects it instantly into a PostgresUniprotEntrytype (id,organism,taxonomy,sequence). -
The Advantage: Zero external scripts. You can enrich millions of orphan protein IDs dynamically inside pure SQL pipelines.
-
SQL Example (Multi-Row Batch Fetch & Insert):
Using a
CROSS JOIN LATERAL, you can map the HTTP fetch over a batch of IDs, evaluate it exactly once per row (saving network calls), andINSERTthe results directly into your metadata table in a single atomic SQL transaction!-- 1. Create a table for the newly discovered metadata CREATE TABLE dark_proteome_metadata ( uniprot_id VARCHAR(20) PRIMARY KEY, organism TEXT, taxonomy TEXT[], sequence TEXT ); -- 2. The Batch Fetch & Insert Pipeline WITH new_discoveries(uniprot_id) AS ( VALUES ('A0A5B9DCV6'), -- Deep-sea Asgard archaeon (RuBisCO) ('L0JL84') -- Halophilic archaeon ), enriched_data AS ( -- The LATERAL join ensures the HTTP request evaluates exactly once per ID SELECT u.id, u.organism, u.taxonomy, u.sequence FROM new_discoveries d CROSS JOIN LATERAL bio_fetch_uniprot(d.uniprot_id) u ) INSERT INTO dark_proteome_metadata (uniprot_id, organism, taxonomy, sequence) SELECT id, organism, taxonomy, sequence FROM enriched_data RETURNING uniprot_id, organism;
-
SQL Example (Native API Search via Virtual Tables):
We also provide a Set Returning Function (SRF), which acts mechanically identical to a read-only Foreign Data Wrapper (FDW). You can pass standard UniProt Lucene query parameters directly into the function and query it exactly like a local table.
-- Find the top 5 longest curated proteins for the BRCA1 gene in Humans SELECT id, organism, length(sequence) AS seq_len FROM bio_search_uniprot('gene:BRCA1 AND taxonomy_id:9606 AND reviewed:true') ORDER BY seq_len DESC LIMIT 5; -- Filter archaeal proteins by exact length and sequence SELECT id, sequence FROM bio_search_uniprot('taxonomy_id:2594042 AND length:[1 TO 50]') WHERE sequence LIKE 'M%'; -- standard SQL filters apply to the returning set
Supported UniProt Query Parameters: The
queryargument supports all standard UniProtKB REST API search fields, including:gene:BRCA1(Filter by gene name)taxonomy_id:9606(Filter by taxonomic ID, e.g., 9606 = Homo sapiens)organism_name:"Homo sapiens"(Filter by exact organism string)length:[1 TO 200](Filter by amino acid sequence length)reviewed:true(Only return manually curated Swiss-Prot entries)keyword:KW-0002(Filter by specific biological keywords, e.g., 3D-structure)
We have fully integrated classic dry-lab functions directly into the SQL engine, removing the need for Biopython or PyMOL in many scenarios.
- Native Sequence Translation:
bio_translate_dna('ATGCGT')instantly translates DNA to Amino Acids using standard codon tables. - Native PDB Parsing:
bio_parse_pdb(pdb_string)parses raw PDB files into relational SQL rows. - Structural Alignment:
bio_rmsd(coords_a, coords_b)calculates the RMSD between two protein conformations directly in PostgreSQL.
Layer 7: Cheminformatics (HΓΌckel $4n+2$ Aromaticity Perception, WL/ECFP4 Hashing, VF2 @> & Salt/Tautomer Normalization)
To discover novel drugs and enzyme substrates, you must traverse massive libraries of chemical compoundsβwhere the exact same molecule may be ingested in KekulΓ© form (C1=CC=CC=C1), queried in aromatic form (c1ccccc1), or stored as a ChEMBL/PubChem salt ([Na+].O=C([O-])C1=CC=CC=C1).
-
The Engine:
pg_bioimplements a zero-dependency Rust molecular graph normalizer and indexer inside PostgreSQL:-
Salt Stripping & Prototropic Tautomer Normalization: Splits disconnected
.fragments into connected components, retains the largest heavy-atom parent molecule, neutralizes counter-ion salt charges (CC(=O)[O-].[Na+]$\rightarrow$ CC(=O)O), and canonicalizes aliphatic 1,3-prototropic keto-enol / imidic-amide tautomers (C=CO$\rightarrow$ CC=O,CC(=N)O$\rightarrow$ CC(=O)N). -
HΓΌckelβs
$4n+2$ Aromaticity Perception: Traces fundamental and fused cycles ($3..=10$ ), sums$\pi$ -electron contributions across$sp^2$ conjugated ring atoms ((pi_sum >= 6) && ((pi_sum - 2) & 3) == 0), and rewrites aromatic rings toBOND_AROMATICsoC1=CC=CC=C1andc1ccccc1compile to the exact sameMoleculestruct. -
Weisfeiler-Lehman (WL) 64-Bit Canonical Hash & 1024-Bit ECFP4 Bitset: Computes vertex-permutation-invariant 64-bit
wl_hash(molecule_wl_hash) and16 Γ u64bitsets usingfmix64and sorted neighbor hashes, enabling$O(1)$ B-tree lookups (0.673 msacross 10,000 molecules β 1,513.7x faster than Python pull) and hardware-popcount (count_ones) Tanimoto similarity (Molecule % Molecule). -
VF2 Subgraph Isomorphism Recheck (
@>): Exact backtracking subgraph matcher (target_mol @> query_molandsmiles_contains) verifying atom numbers, aromaticity, and bond types across cyclic and fused scaffolds.
-
Salt Stripping & Prototropic Tautomer Normalization: Splits disconnected
-
Reference Documentation & Benchmark:
docs/14_aromaticity_wl_vf2_cheminformatics.md|scripts/benchmark_aromaticity_wl_vf2.py -
SQL Example:
-- 1. Canonical equivalence across KekulΓ©, Aromatic, and Salted representations (100% recall) SELECT molecule_wl_hash('C1=CC=CC=C1') = molecule_wl_hash('c1ccccc1') AS benzene_eq, molecules_are_identical('[Na+].O=C([O-])C1=CC=CC=C1', 'O=C(O)c1ccccc1') AS salt_normalized, parse_smiles('CC(=O)OC1=CC=CC=C1C(=O)O') @> parse_smiles('c1ccccc1') AS vf2_substructure, parse_smiles('C1=CC=CC=C1') % parse_smiles('c1ccccc1') AS tanimoto; -- 2. Screen Swarm Discovery enzyme substrates using B-tree WL hash, VF2 (@>), and ECFP4 Tanimoto (%) SELECT family_name, substrate_name, wl_hash FROM swarm_enzyme_substrates WHERE mol @> parse_smiles('c1ccc(C(=O)O)cc1') AND (mol % parse_smiles('O=C(OCCO)c1ccc(C(=O)O)cc1')) >= 0.75;
Scaling de novo enzyme design success rates from 14.7% (Zn series) to 87.5% (ZnO series) (Chen, Hilvert, Baker et al., Nature 2026) requires moving beyond coarse
- The Engine:
pg_bionatively indexesHETATMcofactors and catalytic water molecules in Morton-codedResidueCoordarrays, executes rotationally invariant 3D Kabsch / Horn Quaternion Superposition (theozyme_rmsd,kabsch_rmsd) against reference active-site motifs (such as'4qhp_zn_pentad'), computes bond/attack angles (bio_angle) and torsions (bio_dihedral), and evaluates trajectory histograms via thePreorganizationProfilecomposite type (ensemble_fraction_below). - The Scientist's Advantage: Screen thousands of RFdiffusion / AlphaFold3 enzyme-substrate complexes and MD ensembles in < 7 milliseconds directly inside PostgreSQLβwithout exporting gigabytes of PDB trajectories to Python/PyRosetta.
- SQL Example:
-- Filter de novo metalloprotease constructs for coordinated Zn(II)-water shells, -- sub-angstrom 4qhp theozyme RMSD, Burgi-Dunitz attack angles, and >80% MD preorganization: SELECT design_id, theozyme_rmsd(active_site_coords, '4qhp_zn_pentad') AS rmsd, bio_angle(water_o, substrate_c, substrate_o) AS burgi_dunitz_angle, ensemble_fraction_below(proton_transfer_dist_hist, 3.0) AS preorg_fraction FROM metalloprotease_designs WHERE has_coordinated_water_shell(active_site_coords, 'ZN', 2.4) = TRUE AND theozyme_rmsd(active_site_coords, '4qhp_zn_pentad') <= 0.90 AND bio_angle(water_o, substrate_c, substrate_o) BETWEEN 100.0 AND 115.0 AND bio_distance(glu_oe, water_h) < 3.0 AND ensemble_fraction_below(proton_transfer_dist_hist, 3.0) >= 0.80 ORDER BY rmsd ASC;
When analyzing explicit-solvent Molecular Dynamics (MD) trajectories and per-residue end-state free-energy decompositions (such as the UFAM / COARACI GGAS, GSOLV, DELTA TOTAL) and discover stabilizing cryptic sub-pocket residues outside pre-selected binding pockets.
-
The Engine:
pg_bioprovides native Rust double-entry thermodynamic auditors (audit_mmpbsa_decomposition,solvent_shift_penalty) and Compressed Sparse Row (CSR) energetic network profilers (build_energy_hotspot_map,discover_cryptic_hotspots,allosteric_mechanism_index). -
The Scientist's Advantage: Screens 180 protein-ligand MD systems (
121,860residue rows) in7.97 ms(31.14x faster than Python/NumPy), automatically flagging the$+20.72\text{ to }+26.05\text{ kcal/mol}$ non-decomposed Poisson-Boltzmann cavity/dispersion penalty and uncovering unannotated cryptic hydrophobic anchors (Ile126,Val29,Leu66in human 5-LOX). -
Interactive Tutorial & Blog Post:
- π Executed Jupyter Notebook:
experiments/11_5lox_triterpenoid_mmpbsa_validation.ipynb - π Reference Documentation:
docs/12_mmpbsa_free_energy_auditing.md - π Technical Deep-Dive & 3Dmol.js Blog Post: Auditing 500 ns Molecular Dynamics in SQL: Triterpenoids, 5-Lipoxygenase, and Cryptic Allosteric Pockets with pg_bio
- π Executed Jupyter Notebook:
-
SQL Example:
-- Build a 676-residue CSR energetic hotspot map and discover cryptic anchors outside the 9-residue pocket SELECT system_id, discover_cryptic_hotspots( build_energy_hotspot_map(677, residue_ids, mm_plus_polar_arr, 677, -0.15), 677, ARRAY[68, 108, 109, 110, 129, 130, 133, 134, 137], 0.35, 5 ) AS cryptic_hotspots, allosteric_mechanism_index( build_energy_hotspot_map(677, residue_ids, mm_plus_polar_arr, 677, 0.0), 677, ARRAY[29, 66, 109, 110, 126, 130], ARRAY[68, 108, 129, 133, 134, 137] ) AS mechanism_index FROM lox5_mmpbsa_decompositions;
Layer 12: Wet-Lab Synthetic Biology, Multi-Host Codon Cassettes, 3D Globular Gate & Defluorination Digital Twin
Transitioning an in silico multiomics design (such as the TeaFlon PTFE-degrading & fluorapatite-mineralizing TriFusion enzyme across 7,338 proteins and 930 organisms) into physical wet-lab validation requires host-specific codon optimization, plasmid cassette assembly, 3D globular folding quality control, and enzymatic assay digital twins.
-
The Engine:
pg_bioprovides native Rust wet-lab compilers (bio_reverse_translate,bio_codon_adaptation_index,bio_design_expression_cassette), 3D gyration tensor globular gates (evaluate_globular_compactness), built-in Fluoroacetate Dehalogenase theozyme templates ('q1ju72_dehalogenase_hexad'), and Michaelis-Menten + Fluorapatite$\text{Ca}_5(\text{PO}_4)_3\text{F}$ kinetic simulators (simulate_defluorination_kinetics). -
Reference Documentation & Python Friction Roadmap:
docs/13_wetlab_synbio_and_teaflon_validation.md -
SQL Example:
-- Design wet-lab expression cassettes across 9 bacterial, fungal, archaeal & mammalian hosts, -- audit 3D globular compactness, and simulate 48h Fluoride ISE + Fluorapatite yield: SELECT host, (bio_design_expression_cassette('MFEGFERRLVDWPSTDKTKREEVD', host, 'T7')).gc_content AS gc, (bio_design_expression_cassette('MFEGFERRLVDWPSTDKTKREEVD', host, 'T7')).cai_score AS cai, (bio_design_expression_cassette('MFEGFERRLVDWPSTDKTKREEVD', host, 'T7')).restriction_sites_free AS bsa1_free FROM unnest(ARRAY['e_coli', 'b_subtilis', 'p_putida', 's_cerevisiae', 'h_salinarum', 'h_sapiens']) AS host;
Layer 13: RosettaCommons Chaperone Protein Design Workflows & Official Core Examples (RFD3 -> Foundry-MPNN -> Boltz-2 / AF3)
Supporting RosettaCommons Chaperone (RosettaCommons/chaperone) and its 8 Official Core Examples (nanoparticle-design, peptide-binder, cortisol-binder, dna-binder, enzyme-glycosidase, enzyme-protease, ribozyme-hammerhead, multi-mpnn) requires pushing post-oracle evaluation blocks (RMSD, RASA, Hydrogen Bonds, BUNS, and PipelineDataHandler Lineage) directly into PostgreSQL (209.04 ms for 400 complexes β 36.9x faster than Python pull).
- The Engine:
pg_bioimplements a fused Rust Chaperone evaluation engine (bio_rasausing 64-point ShrakeβRupley Fibonacci spheres and Tien 2013 RASA normalization,bio_hbond_networkprojecting 3D H-bonds into CSRSparseAttentionMapmatrices,audit_hydrogen_bondscounting cross-interface H-bonds and Buried Unsatisfied Polar Atoms / BUNS,evaluate_chaperone_block/evaluate_chaperone_design,chaperone_lineage_hash, andchaperone_core_examples/evaluate_chaperone_core_example_block). - Reference Documentation & Benchmark:
docs/15_chaperone_protein_design_workflows.md|scripts/benchmark_chaperone_workflows.py|experiments/13_chaperone_protein_design_workflows.ipynb - SQL Example:
-- 1. Audit all 8 Official RosettaCommons Chaperone Core Examples in milliseconds: SELECT ex.example_name, ex.category, audit.sc_rmsd, audit.mean_plddt, audit.interface_delta_sasa, audit.cross_interface_hbonds, audit.buried_unsatisfied_polars AS buns, audit.active_site_or_motif_rmsd, audit.ligand_or_cofactor_verified, audit.passes_example_gate FROM chaperone_core_examples() AS ex CROSS JOIN LATERAL evaluate_chaperone_core_example_block( ex.example_name, ex.candidate_pdb, ex.reference_pdb, ex.ligand_smiles ) AS audit; -- 2. Filter Chaperone RFdiffusion3 -> Foundry-MPNN -> Boltz-2/AF3 candidates by scRMSD, pLDDT, -- interface delta-SASA, cross-interface H-bonds, zero BUNS traps, and compile lineage hashes: SELECT d.design_id, chaperone_lineage_hash('boltz2', d.parent_mpnn_id, d.sequence, d.cycle_num) AS lineage_id, eval.sc_rmsd, eval.mean_plddt, eval.interface_delta_sasa, eval.cross_interface_hbonds, eval.buried_unsatisfied_polars AS buns, eval.design_composite_score FROM chaperone_benchmark_designs d CROSS JOIN LATERAL evaluate_chaperone_block(d.oracle_pdb, d.rfd3_backbone_pdb, 'A', 'B') AS eval WHERE eval.passes_chaperone_gate = TRUE ORDER BY eval.design_composite_score DESC;
Inspired by PocketVina Atlas (Sarigun et al., arXiv:2506.20043) and PoseBusters (Buttenschoen et al., Chem. Sci. 2024), proteome-scale virtual screening requires moving beyond single guessed docking boxes to Multi-Pocket Conditioning (pk1..pk5) while verifying that top poses pass 21 physical, geometric, steric, and salt-hygiene checksβwithout silently hiding salted vendor entries ([Na+].O=C([O-])...) or teleporting sterically clashing poses into false positives.
-
The Engine:
pg_bioimplements three native Rust functions directly inside PostgreSQL (197.92 msfor 120 complexes (1.65 ms/complex) β20.96Γfaster than Python pull):-
bio_detect_top_pockets(pdb_text, max_pockets DEFAULT 5): Probes the protein surface with 24-ray Fibonacci Connolly Solvent Accessible Surface (SAS) spheres ($r_{\text{probe}} = 1.40,\text{\AA}$ ) accelerated by a$5.0,\text{\AA}$ 3D spatial voxel hash grid, filters for buried concave clefts, clusters SAS points via$4.0,\text{\AA}$ BFS flood-fill ($\ge 7.5,\text{\AA}$ inter-pocket separation), and emitspk1..pk5along with their 64-bit Mortonz_order_center, 3D SAS coordinates (sas_coords_flat), 9DRangeFinderPocketintervals, and 16-byte CPU register Fastscan sketch (fastscan_16b). -
bio_posebusters_audit(protein_pdb, ligand_sdf_or_smiles, cx, cy, cz)&bio_posebusters_audit_row(...): Audits all 21 PoseBusters & chemical hygiene checks (valence, connectivity, charge, salt counterion exclusion, covalent bond lengths/angles, internal clash,$3\times 3$ Jacobi SVD aromatic ring flatness$\le 0.25,\text{\AA}$ ,$sp^2$ flatness,$sp^3$ tetrahedral volume, pairwise proteinβligand VdW ratio$d_{ij}/(r_{\text{vdW},i}+r_{\text{vdW},j}) \ge 0.75$ , volume overlap, pocket burial, cofactor clearance, H-bond geometry, BUNS, RangeFinder compatibility, and PAINS/aggregator hygiene) with a Strict Non-Hiding Dual-Ledger Provenance contract (raw_passes_all_21,was_desalted,rescue_possible$\le 1.25,\text{\AA}$ ,rescue_rmsd_shift_a,provenance_tag). -
bio_multipocket_posebusters_screen(protein_pdb, ligand_smiles_or_sdf, max_pockets DEFAULT 5): Fuses top-$K$ pocket detection, 9D RangeFinder selectivity, and 21-check PoseBusters validation across all candidate pockets of a protein in a single SQL query, flagging the winning pocket withis_best_pocket = TRUE(β).
-
-
Reference Documentation & Benchmark:
docs/19_pocketvina_multipocket_and_posebusters.md|scripts/benchmark_pocketvina_posebusters.py|experiments/16_pocketvina_multipocket_posebusters.ipynb -
SQL Example:
-- 1. Detect the Top 5 P2Rank-style SAS pockets of an enzyme and emit 9D RangeFinder + 16-byte Fastscan sketches: SELECT pocket_rank, pocket_id, p2rank_score, probability, center_x, center_y, center_z, sas_points_count, residue_count, mean_plddt, residue_ids[1:4] AS top_residues, octet_length(fastscan_16b) AS fastscan_bytes FROM bio_detect_top_pockets(protein_pdb, 5); -- 2. Audit a salted vendor drug SMILES with Strict Non-Hiding Dual-Ledger Provenance: -- (passes_all_21 = TRUE on the desalted drug, while raw_passes_all_21 = FALSE and was_desalted = TRUE) SELECT passes_all_21, raw_passes_all_21, was_desalted, rescue_possible, rescue_rmsd_shift_a, provenance_tag, passed_count, total_checks, failed_checks, min_vdw_ratio, max_ring_rmsd_a FROM bio_posebusters_audit_row( protein_pdb, '[Na+].O=C([O-])c1ccccc1O', -- Sodium salicylate salt -> desalted to Salicylic acid 10.0, 10.0, 10.0 ); -- 3. Multi-Pocket Conditioning + 21-Check PoseBusters Screen for Diclofenac (Pipeline #6 feedstock): SELECT pocket_rank, CASE WHEN is_best_pocket THEN 'β ' || pocket_id ELSE pocket_id END AS pocket_badge, p2rank_score, pocket_probability, estimated_vina_kcal_mol, rangefinder_compatibility, posebusters_valid, posebusters_passed_checks FROM bio_multipocket_posebusters_screen( protein_pdb, 'O=C(O)Cc1ccccc1Nc2c(Cl)cccc2Cl', 5 );
Layer 20: SIMD EnzRef Catalytic Role-Contrast Kinetics, Reaction SMILES Splitter & Disordered Microprotein pSLiM Window Pooler
Inspired by EnzRef (Ding et al., bioRxiv 2026 β Reference-Centered Multimodal Adaptation of Protein Language Models for Enzyme Turnover Prediction) and pSLiM / SLiMNet (Poretsky et al., BMC Bioinformatics 2026; McFee & Kim 2026), Stage-2.5 enzymatic ranking and synthetic metabolon design require distinguishing true forward catalytic turnover from dead-end substrate binding ($\mathbf{r}{\text{prod}} = \mathbf{r}{\text{react}}$) and indexing disordered microprotein Short Linear Motifs (sORFs <= 110 aa) without diluting them via full-sequence mean pooling or cleaving hydrophobic domain cores across synthetic fusion linkers.
-
The Engine:
pg_bioimplements native ARM64 NEON / x86_64 AVX2 role-contrast and motif-pooling primitives directly inside PostgreSQL 18 (2,092,0901280-DEnzReftriplets/sec/core and617,845ZCA-whitened SLiM windows/sec/core):-
Reaction SMILES Agent-Stripping Splitter & Role Vectorizers (
bio_split_reaction_roles,bio_reaction_role_vectors,bio_batch_reaction_role_vectors): DecomposesA.B>>C.DorA>agent>B(stripping intermediate agents/solvents) and vectorizes dot-separated multi-component reactants and products into 1024-bit Morgan ECFP4 + 9DRangeFinderdescriptors projected to any target dimension$D$ (e.g.1280). -
Reference-Centered SIMD
EnzRefKinetics (bio_enzref_kinetics,bio_enzref_flux_rank,bio_enzref_kinetics_g128,bio_enzref_flux_rank_g128,bio_enzref_kinetics_smiles): Computes centered deviations $\mathbf{d}{\text{react}} = \mathbf{r}{\text{react}} - \mathbf{v}{\text{bg}}$ and $\mathbf{d}{\text{prod}} = \mathbf{r}{\text{prod}} - \mathbf{v}{\text{bg}}$, symmetric mean response $\mathbf{m} = \frac{1}{2}(\mathbf{d}{\text{react}} + \mathbf{d}{\text{prod}})$, directed forward role contrast $\mathbf{c}{\text{fwd}} = \mathbf{d}{\text{prod}} - \mathbf{d}_{\text{react}}$, and product-retentionbackpressure_risk($K_p$ stall) in a single fused SIMD pass overfloat4[]or inline 1,304-byte zero-TOASTBioVecInt8G128varlenasβguaranteeing exact antisymmetry under reaction reversal ($\text{FluxRank}(e, p, r) = -\text{FluxRank}(e, r, p)$) and exact zeroing on dead binders. -
Disordered Microprotein
pSLiMWindow Pooler & Bivalent Tether Matcher (bio_pslim_window_pool,bio_match_dual_slim_tether,bio_audit_fusion_junction_sanity): Extracts strided 5β12 aa motif windows gated by disorder/loop masks, applies in-memory corpus ZCA whitening + exact L2 unit normalization ($|\mathbf{w}|_2 = 1.0$ , emitting 68-bytevec16vectors compatible with 2-level layered-centroidfastscantables), and matches non-overlapping dual-SLiM metabolon couplers (end_a + min_linker <= start_b) while enforcing a hydrophobic-core linker junction sanity gate (Single_Polypeptide_Fusionvs.Bicistronic_Operon_Required).
-
Reaction SMILES Agent-Stripping Splitter & Role Vectorizers (
-
Reference Documentation:
docs/20_enzref_role_contrast_and_pslim_tethers.md -
SQL Example:
-- 1. Evaluate EnzRef catalytic flux rank and backpressure risk directly from reaction SMILES: SELECT reactants_smiles, products_smiles, forward_flux_score, backpressure_risk, role_contrast_norm, mean_catalytic_response, cosine_alignment, norm_ratio_react_over_prod FROM bio_enzref_kinetics_smiles( ARRAY(SELECT sin(g::float8)::float4 FROM generate_series(1, 1280) g), 'CC(=O)Oc1ccccc1C(=O)O.O>[H+]>CC(=O)O.O=C(O)c1ccccc1O' ); -- 2. Match a disordered microprotein as a Dual-SLiM Metabolon Tether with Linker Junction Sanity: SELECT start_a, end_a, subseq_a, sim_a, l2_centroid_a, start_b, end_b, subseq_b, sim_b, l2_centroid_b, linker_len, linker_gravy, junction_sanity_pass, recommended_operon_mode, dual_tether_score FROM bio_match_dual_slim_tether( 'MKKLVLVAVILGLAVAGSAQAPVGRDTVPDPLRERAQELGVKVTVEGPGGGSGGGGSLLPAIVHIEQDKTKREEVD', ARRAY[0.45, -0.20, 0.30, 0.15, -0.40, 0.25, 0.10, -0.35, 0.20, 0.10, -0.15, 0.30, 0.05, -0.25, 0.40, 0.12]::real[], ARRAY[-0.30, 0.50, -0.15, 0.40, 0.20, -0.35, 0.25, 0.10, -0.45, 0.30, 0.15, -0.20, 0.35, 0.10, -0.25, 0.18]::real[], 8, 2, 6, NULL, NULL );
Inspired by ipSAE (Dunbrack, bioRxiv 2025/2026 β "RΔs ipSAE loquuntur: What's wrong with AlphaFold's ipTM score and how to fix it") and MiniPAE (Veinstein et al., Briefings in Bioinformatics 2025; Omidi et al., 2024), scoring multi-chain complexes or synthetic metabolon tethers (ipTM causes severe false negatives whenever one partner contains an Intrinsically Disordered Region (IDR) or flexible linker (GGGSGGGGS). Because global ipTM sets
-
The Engine:
pg_bioimplements Dunbrack's contact-restricted directionalipSAE($d_0(N_i) = 1.0$ for$N_i < 27$ else$1.24(N_i - 15)^{1/3} - 1.8$ , evaluated strictly over qualifying contacts$\text{PAE}_{i,j} < 10.0,\text{\AA}$ ) paired with Veinstein's 2D-prefix-sum$5 \times 5$ sliding-windowMiniPAEand a< 2,000 Bzero-TOAST"PGPA"quantized CSRbyteacontainer (bio_ipsae_minipae_audit,bio_ipsae_minipae_from_pae_flat,bio_pack_sparse_pae_csr,bio_peek_pae_csr_header). -
Reference Documentation:
docs/21_ipsae_minipae_cofolding_gate.md -
SQL Example:
-- Audit a 2-chain receptor + disordered SLiM tether complex and rescue it from global ipTM IDR dilution: SELECT chain_a_id, chain_b_id, ipsae_a_to_b, ipsae_b_to_a, ipsae_min, ipsae_max, iptm_global_diluted, idr_dilution_rescue_delta, minipae_5x5_a, best_window_a_start, best_window_b_start, passes_cofold_gate, gate_verdict, packed_csr_bytes FROM bio_ipsae_minipae_audit(complex_pdb_text, NULL, 10.0, 3.5);
Inspired by Professor Kwang-Hyun Cho's KAIST Systems Biology Lab (Gong et al., "Control of Cellular Differentiation Trajectories for Cancer Reversion", Advanced Science 2024/2025, doi:10.1002/advs.202402132), Layer 22 brings native Single-Cell Boolean Network Attractor & Combinatorial Reversion Control (BENEIN) into PostgreSQL 18. Instead of destroying cancer cells, BENEIN searches for the minimal combination of master regulators whose simultaneous inhibition collapses a malignant proliferative attractor (MYB + HDAC2 + FOXA2 triple knockdown).
-
The Engine:
pg_biopacks$N$ -gene ($N \le 64$ ) canalizing Boolean regulatory networks into a192-byteinline zero-TOAST"PGBN"byteacontainer (bio_pack_benein_grn,bio_kaist_colorectal_grn) and transposes 64 stochastic single-cell initial states into$N$ bit-slicedu64registers (bio_benein_simulate_perturbation,bio_benein_reversion_scan), evaluating all 64 cell trajectories per time step in a single CPU register pass (> 184Mcell trajectories/sec/core, 940.71Γ faster than Python/NumPy). -
Reference Documentation & Benchmark:
docs/22_benein_boolean_attractor_cancer_reversion.md|scripts/benchmark_benein_cancer_reversion.py -
SQL Example:
-- Exhaustively scan all C(6, 1..3) = 41 single, dual, and triple knockdowns on the KAIST Colorectal GRN -- across 64 parallel bit-sliced single-cell trajectories to discover MYB + HDAC2 + FOXA2: SELECT rank, combo_size, knockdown_genes, normal_basin_pct, cancer_escape_pct, reversion_score, synergy_over_subsets, steps_to_converge, reversion_verdict FROM bio_benein_reversion_scan( bio_kaist_colorectal_grn(), ARRAY['MYB','HDAC2','FOXA2','EP300','CTNB1','MYC','CDX2','HNF4A','KLF4','VIL1'], 3, 63, 32, 10 );
pg_bio isn't just mathematically clever; it is heavily optimized for multi-million scale deployment on commercial hardware.
High-dimensional 1280-D ESM-2 vectors (2,568 bytes) exceed PostgreSQL's 2 KB TOAST threshold by default, spawning 6.11 GB of out-of-line TOAST chunks across 2.34 million proteins. pg_bio pairs halfvec(1280) (16-bit floating-point) with STORAGE PLAIN to eliminate external TOAST tables and random chunk lookups.
2. Tiered Vector & Multi-Index Routing (pg_vectorsearch PRISM + Layered Centroids + Register Fastscan)
-
pg_vectorsearch(USING prismβ Primary 1M+ Proteome Engine): Uses 1-bit RaBitQ quantization with theoretical error bounds, SOAR spill-orthogonal secondary cluster assignment, and hierarchical centroid routing. Across 2,340,766 proteins, PRISM shrinks the vector index by 9.72Γ (8,772 MB$\rightarrow$ 902 MB), builds in 3.08 minutes (vs. 27 hours for HNSW), and accelerates homology queries by 7.5Γβ11.3Γ (1.22 msto26 ms). -
100% Lossless Layered Centroids & Register-Direct Fastscan (
PR #14): Portspg_vectorsearch's hierarchical centroid routing, SOAR boundary assignment, and register-direct Fastscan upper bounds topg_bio's other three biological index families:-
3D Morton Octree (
z_order_layered_sphere_ranges):74.05Γfewer atoms scanned,10.25Γfaster (0.96 ms),100.0%exact recall. -
1024-Bit ECFP4 Tanimoto (
ecfp4_fastscan_ub_raw): Prunes99.89%of molecules in 64-bit CPU registers,31.19Γfaster (16.98 ms) at100.0%exact recall (or158.15Γfaster at3.35 mswith SOAR dual-centroid routing). -
9D RangeFinder Active-Site Pockets (
pocket_quantize_fastscan&pocket_fastscan_iou_ub_raw): Compresses 350-byte pockets by 22Γ into two 64-bit CPU registers (16 bytes), running13.24Γfaster (7.79 ms) at100.0%exact Recall@10 (or20.42Γfaster at5.05 mswith 37 balanced Level-2 centroid envelopes + SOAR).
-
3D Morton Octree (
You don't need to write raw SQL to leverage this power.
-
pgbio-py: A seamless Python SDK that connects directly to the Rust engine. -
Jupyter Integration: Full compatibility with Pandas and Matplotlib. View our complete tutorial notebook demonstrating all four layers in action:
https://github.com/jonatas/teaflon/blob/main/pg_bio_multiomics_pipeline/teaflon_multiomics_tutorial.ipynb. -
Dry Lab Tutorial: Learn how to use these new structural and sequence analysis tools natively in SQL: examples/bio_dry_lab_tutorial.ipynb
from pgbio import PgBioClient
client = PgBioClient("postgresql://localhost:28818/bio_demo")
# Query the Joint Vector Space natively from Python
dna_matches = client.find_joint_enhancers(protein_id="P0DPB7")
print(f"Strongest regulatory match: {dna_matches[0].locus}")# 1. Clone the repository
git clone https://github.com/jonatas/pg_bio.git
cd pg_bio
# 2. Spin up the Rust-optimized Postgres Engine
docker-compose up -d
# 3. Compile the Database and Interactive Notebooks
uv run jupyter nbconvert --execute https://github.com/jonatas/teaflon/blob/main/pg_bio_multiomics_pipeline/teaflon_multiomics_tutorial.ipynb
# 4. Run the Declarative Multi-Feedstock Bioprocess Compiler & Autonomous Swarm UI (jonatas/bio-pipelines)
git clone https://github.com/jonatas/bio-pipelines.git ../bio-pipelines
cd ../bio-pipelines && uv sync
uv run python base/compiler.py
uv run python base/swarm_web.py(For an extended deep-dive into the architectural theory, read docs/MULTIOMICS_ARCHITECTURE.md)
Below is the complete reference of correlation engines built into src/lib.rs, how each correlation works intuitively, how pg_bio executes it natively inside PostgreSQL, why it outperforms Python pipelines, and where to find the official documentation and runnable examples.
| # | Correlation Type | Simple Explanation (How It Works) | Technical pg_bio Approach (src/lib.rs & SQL) |
Why pg_bio (Rust in Postgres) Is Faster Than Python |
Official Docs & Examples |
|---|---|---|---|---|---|
| 1 |
Twilight-Zone Homology Index (3D Convergence vs. Sequence Divergence) |
Finds pairs of proteins that fold into the exact same 3D shape even though their amino acid sequences have mutated heavily (15%β75% similarity), filtering out both 100% clones and random k-mer noise. |
Combines HNSW cosine distance (<=>), smith_waterman_score, and sequence_entropy in a bell-curve filter:(1 - d_cos)^2 * [4 * s * (1 - s)] * (L_min / L_max)^2 * min(H / 4.0, 1.0). |
Zero-IPC & smith_waterman_score runs in compiled Rust using two flat Vec<i32> rolling buffers directly on Postgres TEXT pointersβno |
π 01_vector_homology.mdπ 08_native_alignment.mdπ jonatas/bio-pipelines (swarm_discovery.py)π 07_native_alignment.ipynb
|
| 2 |
Extremophile Niche Shift Index (Electrostatic & Hydropathy Remodeling: $\Delta\text{pI}$ / $\Delta\text{GRAVY}$) |
Measures how a protein rewires its surface charge (acidic vs. basic) and water-repellency to survive extreme habitats (deep-sea brine, acid vents, soda lakes) while keeping the same 3D core. | Computes isoelectric_point via 100-step bisection on Henderson-Hasselbalch gravy_score (Kyte-Doolittle hydropathy) inline with <=>. |
Single-Pass Byte-Slice Histograms: Counts amino acid frequencies in a single CPU register pass (seq.bytes()) and solves f64 math (~200 ns/protein vs. ~40 Β΅s in BioPython). |
π 11_sequence_analysis.mdπ 04_native_chemistry.mdπ jonatas/bio-pipelines (swarm_web.py)
|
| 3 |
Layer 8 Interface Complementarity (ProteinβProtein / Complex Docking Compatibility) |
Checks whether two proteins can physically dock togetherβlike a lock and keyβwhere a positively charged or convex patch on one matches a negatively charged or concave pocket on the other. |
interface_complementarity splits embeddings into Steric/Shape (first half: anti-correlated $p_i \cdot (-q_i)$) and Electrostatic/Hydrophobic (second half: complementary product), mapped via tanh. |
Fused SIMD Vector Loop: Operates directly on Postgres real[] / vector slices in L1 cache without copying arrays across Python/NumPy FFI boundaries. |
π MULTIOMICS_ARCHITECTURE.mdπ swarm_discovery/README.mdπ 09_huggingface_esm2_discovery.ipynb
|
| 4 |
Active-Site Motif & Metal-Cage Gate (Catalytic Residue Conservation) |
Checks if a newly discovered dark protein still has the exact chemical "teeth" (e.g., a C-x(2)-C-x(12)-H zinc finger or [CH]-x-[CH] iron-sulfur cage) needed to run a chemical reaction. |
prosite_match compiles Prosite syntax ([LIVM]-x(2,4)-{P}-C) into a native Rust finite-state token matcher; has_coordinated_water_shell checks metal-water geometry. |
Zero-Regex-Engine Overhead: Avoids Python re backtracking by stepping through fixed PrositeToken enums (Exact, AnyOf, NotOf, Wildcard(min,max)) directly on ASCII bytes. |
π 04_native_chemistry.mdπ 10_metalloprotease_theozyme_design.ipynbπ bio_dry_lab_tutorial.ipynb
|
| 5 |
3D Z-Order (Morton) Pocket & Theozyme Correlation (Spatial Active-Site Superposition) |
Compares the 3D arrangement of catalytic atoms inside an enzyme's pocket against known catalytic templates ("theozymes"), regardless of sequence order. |
z_order_encode interleaves 21-bit split_by_3) into a 64-bit BIGINT B-tree key; kabsch_rmsd & theozyme_rmsd run Jacobi SVD. |
3D-to-1D B-Tree Indexing + Stack i64), and runs a zero-allocation |
π 03_spatial_indexing.mdπ 09_pdb_parsing.mdπ 08_pdb_parsing.ipynbπ 10_metalloprotease_theozyme_design.ipynb
|
| 6 |
Substrate & Catalytic Warhead Correlation (Enzyme $\leftrightarrow$ Small-Molecule Pairing) |
Verifies that an enzyme family's chemical substrate contains the reactive "warhead" bond that the enzyme cleaves or oxidizes, even if drawn in different tautomer, salt, or KekulΓ© forms. |
parse_smiles runs DFS cycle detection, HΓΌckel pgbio_perceive_aromaticity), 64-bit Weisfeiler-Lehman hashing (molecule_wl_hash), VF2 subgraph isomorphism (@>, pgbio_vf2_is_subgraph), and ECFP4 Tanimoto (%). |
Bit-Packed Graph & Native Operators (@>, %): Stores molecules as compact PgBioAtom/PgBioBond structs inside Postgres pages and executes recursive VF2 subgraph matching and 64-bit POPCNT Tanimoto (1,513.7x faster than Python pull). |
π 14_aromaticity_wl_vf2_cheminformatics.mdπ 05_cheminformatics.mdπ 06_smiles_rules.mdπ 05_cheminformatics_tutorial.ipynb
|
| 7 |
Sparse CSR Allosteric & Cryptic Pocket Correlation (Long-Range Neural Attention & Energy Networks) |
Tracks how binding a molecule at a distant surface site sends a ripple through the protein's internal contact network to open or close the active site. |
create_sparse_map, discover_cryptic_hotspots, allosteric_mechanism_index, and sparse_cross_reactivity_score use Compressed Sparse Row (CSR) graphs. |
row_ptr, col_idx, values), cutting memory by >95% and scanning row slices in nanoseconds (31.14x faster than Python/NumPy). |
π 02_attention_traversal.mdπ 12_mmpbsa_free_energy_auditing.mdπ 11_5lox_triterpenoid_mmpbsa_validation.ipynb
|
| 8 |
Globular Compactness & Hydrophobic Core Correlation (Foldability vs. Disordered Spaghetti) |
Distinguishes proteins that fold into a tight, stable 3D ball with a water-free core from floppy, unfolded "spaghetti" predictions. |
evaluate_globular_compactness and bio_rasa compute Radius of Gyration ( |
Spatial Voxel Grid Hashing for SASA: Bins atoms into HashMap<(i32,i32,i32), Vec<usize>>) in compute_atomic_sasa, turning |
π 13_wetlab_synbio_and_teaflon_validation.mdπ 15_chaperone_protein_design_workflows.mdπ 07_on_the_fly_folding.md
|
| 9 |
Hydrogen-Bond Network & Buried Unsatisfied Polar (BUNS) Audit (Thermodynamic Pocket Stability) |
Finds polar atoms (N, O) trapped deep inside a water-free protein core without a hydrogen-bond partnerβa major cause of misfolding or unstable designs. |
bio_hbond_network and audit_hydrogen_bonds combine Shrake-Rupley SASA burial ( |
Fused Single-Pass SASA + Angle Geometry: Shares the precomputed atomic SASA buffer with the H-bond angular validator in a single Rust call (evaluate_chaperone_block), eliminating redundant PDB parsing. |
π 15_chaperone_protein_design_workflows.mdπ 13_chaperone_protein_design_workflows.ipynb
|
| 10 |
Conformational Preorganization Correlation (MD Trajectory & Ensemble Gating) |
Measures what fraction of the time a flexible enzyme naturally spends in its "ready-to-react" state before the substrate even arrives. |
create_preorganization_profile, ensemble_fraction_below, and ensemble_fraction_between compress millions of MD trajectory frames into quantized histogram bins inside Postgres. |
.xtc/.dcd trajectory files in Python with a 20-bin linear interpolation over PreorganizationProfile in <1 Β΅s per row. |
π 10_metalloprotease_theozyme_design.ipynbπ 12_mmpbsa_free_energy_auditing.md
|
| 11 |
MS/MS Proteomics Isotope & Fragment Correlation (Experimental Validation of Dark Proteins) |
Matches predicted dark-proteome sequences against real-world mass spectrometry peaks ( |
generate_theoretical_fragments, is_mass_within_ppm, and isotope_fit_score compute Poisson Spectrum. |
Set-Returning Rust Iterators (TableIterator): Streams .mgf spectra (parse_mgf) directly into the PostgreSQL executor pipeline with zero temporary Python list materialization. |
π 10_mass_spectrometry.mdπ bio_dry_lab_tutorial.ipynb
|
| 12 |
Genomic Safe-Harbor & SynBio Host Expression Correlation (Discovery $\rightarrow$ Wet-Lab DNA Construct) |
Links a discovered protein to genomic variants (.vcf), safe-harbor insertion loci, and optimal DNA codons/GC%/RBS for expression in E. coli, B. subtilis, or H. salinarum. |
parse_vcf, bio_reverse_translate, bio_codon_adaptation_index, and bio_design_expression_cassette emit complete Golden-Gate/Gibson expression cassettes in SQL. |
Compile-Time Lookup Tables (match (host, aa)): Translates and scores CAI in a single zero-allocation loop over static Rust (&'static str, f64) codon tables. |
π 07_genomics_io.mdπ 13_wetlab_synbio_and_teaflon_validation.mdπ 06_genomics_io_tutorial.ipynb
|
| 13 |
Layer 14 Industrial Bioprocess Cascade Kinetics (RK4), Pareto Domain Scoring & Biomass Stoichiometry (Multi-Feedstock Upcycling & Equilibrium Sinks) |
Ranks (Anchor Γ Scissor) domain pairs across hydropathy, pI, and sequence entropy, integrates 48-hour two-stage enzymatic cascades with competitive product inhibition ( |
pareto_score_domain_pair, simulate_cascade_kinetics, optimize_consortium_stoichiometry, and translate_and_merge_pdb_chains execute natively inside PostgreSQL 18. |
In-Database RK4 & Simplex Grid in < 1 ms: Eliminates shipping thousands of candidate pairs and ODE time-series arrays to Python/SciPy; evaluates 12 full 97-step RK4 trajectories in ~24 ms directly inside SQL. | π jonatas/bio-pipelinesπ§ͺ jonatas/teaflon
|
| 14 |
Layer 15 RangeFinder Pocket-Interval GiST & B-Tree Virtual Screening (100M+ Ligand Filtering & Reverse Target Fishing, arXiv:2611.03379v1)
|
Predicts 9 compatible ligand property intervals ($\hat{I}{pj} = [\hat{\mu}{pj} - 2 | \hat{\sigma}_{pj} | , \hat{\mu}_{pj} + 2 | \hat{\sigma}_{pj} |
| 15 | Anisotropy Whitening (Know Thy Neighbour), Inline BioVecInt8G128 Varlena, Structure/PAINS Hygiene & Stage-2.5 (EnzRef / STORM) Re-Rankers |
Eliminates ESM-2/ProstT5 SwiGLU cone anisotropy (0.9963 -> -0.0151) to tighten RaBitQ error bounds (eps_bound) by 2.78Γ, keeps 1280-D Stage-2 reranking vectors 100% inline on the Postgres heap (1,304 B < 2,000 B TOAST threshold), repairs missing PDB/mmCIF atoms via Kabsch SVD + < 2.2 Γ
CYX disulfides + HID/HIE/HIP tautomers, filters PAINS/aggregators at 11,995 mols/s, and re-ranks enzyme/ligand candidates via EnzRef SIMD role-contrast and STORM 64-hot ID128 + Tanimoto cliff-preserving smoothing. |
bio_fit_whitening_stats, bio_whiten_embedding, BioVecInt8G128, bio_sanitize_structure, bio_is_pains_or_aggregator, bio_enzref_role_contrast, bio_id128_hash, bio_smooth_assay_series. |
2.78Γ Tighter RaBitQ Bound, Zero TOAST Reads (1,304 B Inline Varlena), 2.00Γ Faster SIMD i32 Reranking & 52,970 rows/s EnzRef SIMD: Fuses ARM64 NEON / x86_64 AVX2 whitening, 128-channel group i8+f16 i32 accumulation, and 3-vector role-contrast inside Postgres buffer pages. |
π 18_whitening_inline_reranking_and_hygiene.mdπ 17_layered_centroids_multi_index_experiments.md
|
| 16 |
Layer 19 PocketVina Multi-Pocket SAS Conditioning & 21-Check PoseBusters Physical Validity Gate (Multi-Pocket pk1..pk5 Concavity + 21-Check Steric/Chemical Audit)
|
Detects and ranks the Top 5 binding pockets per protein using 24-ray Fibonacci Connolly SAS probes + P2Rank-inspired), emits 9D RangeFinderPocket intervals + 16-byte register Fastscan sketches per pocket, and audits any ligand pose (SDF, PDBQT, or desalted SMILES) across all 21 PoseBusters physical, geometric, salt-hygiene, and steric clash checks inside SQL. |
bio_detect_top_pockets, bio_posebusters_audit, bio_posebusters_audit_row, and bio_multipocket_posebusters_screen. |
Zero Python/RDKit IPC + Fused Salt Rescue & [Na+].O=C([O-])...), rejects bare salt counterions ([Na+]) and PAINS motifs, and audits VdW clashes ( |
π 19_pocketvina_multipocket_and_posebusters.mdβ‘ benchmark_pocketvina_posebusters.pyπ 16_pocketvina_multipocket_posebusters.ipynb
|
| 17 |
Layer 20 SIMD EnzRef Catalytic Role-Contrast Kinetics & Disordered Microprotein pSLiM Window Pooler(Exact Antisymmetric $k_{\text{cat}}$ Flux, Backpressure & Dual-SLiM Metabolon Tethers) |
Decomposes reaction SMILES (A.B>>C.D, stripping >agent>), computes reference-centered substrate/product deviations ($\mathbf{d}{\text{react}} = \mathbf{r} - \mathbf{e}$, $\mathbf{c}{\text{fwd}} = \mathbf{p} - \mathbf{r}$) with exact antisymmetry and product-retention backpressure (vec16) to match bivalent microprotein tethers with hydrophobic-core linker junction sanity gating. |
bio_split_reaction_roles, bio_reaction_role_vectors, bio_enzref_kinetics, bio_enzref_flux_rank, bio_enzref_kinetics_g128, bio_enzref_kinetics_smiles, bio_pslim_window_pool, bio_match_dual_slim_tether, bio_audit_fusion_junction_sanity. |
2,092,090 EnzRef 1280-D Triplets/sec/core (0.48 Β΅s/row) & 617,845 ZCA-Whitened SLiM Windows/sec/core: Computes all 4 directional moments in a single streaming NEON/AVX2 pass over float4[] or inline 1,304-byte zero-TOAST BioVecInt8G128 varlenas without heap allocations. |
π 20_enzref_role_contrast_and_pslim_tethers.mdπ 18_whitening_inline_reranking_and_hygiene.md
|
| 18 |
Layer 21 Directional ipSAE & MiniPAE Co-Folding Confidence Gate(IDR Dilution Rescue for Co-Folded Complexes & Disordered SLiM Tethers) |
Rescues disordered microprotein SLiM tethers (sORFs <= 110 aa) and multi-domain chimeras from AlphaFold/Boltz-2 global ipTM IDR dilution by evaluating Dunbrack's contact-restricted ipSAE (MiniPAE window over zero-TOAST < 2,000 B "PGPA" quantized CSR bytea containers. |
bio_ipsae_minipae_audit, bio_ipsae_minipae_from_pae_flat, bio_pack_sparse_pae_csr, bio_peek_pae_csr_header. |
Zero-TOAST < 2,000 B "PGPA" CSR Storage + MiniPAE + ipSAE + MiniPAE in microseconds without Python JSON parsing. |
π 21_ipsae_minipae_cofolding_gate.mdβ‘ benchmark_ipsae_minipae_gate.pyπ 18_ipsae_minipae_cofolding_gate.ipynb
|
| 19 |
Layer 22 Bit-Sliced 64-Way BENEIN Boolean Attractor & Synergistic Cancer Reversion Control(Combinatorial Master Regulator Discovery, KAIST Adv. Sci. 2024/2025) |
Simulates 64 stochastic single-cell Boolean regulatory trajectories simultaneously in u64 bit-planes across MYB + HDAC2 + FOXA2) that collapse a malignant cancer attractor into a differentiated normal tissue attractor. |
bio_pack_benein_grn, bio_kaist_colorectal_grn, bio_benein_simulate_perturbation, bio_benein_reversion_scan. |
64-Way Bit-Sliced u64 Register Logic + 192-Byte Zero-TOAST "PGBN" Container: Evaluates 64 cells per bitwise OR/AND/NOT/POPCNT instruction at >184M trajectories/sec/core (0.0142 ms per 41-combo scan, 940.71Γ faster than Python/NumPy). |
π 22_benein_boolean_attractor_cancer_reversion.mdβ‘ benchmark_benein_cancer_reversion.pyπ 19_kaist_colorectal_reversion_trio_exploration.ipynb
|
| 20 |
Layer 23 Sequence-Encoded 3Di Conformational Entropy, FlexProfile Cryptic Pocket Breathing Gate & 128-Bit 64-Hot POPCNT Structural Sketch(ProtProfileMD / AlloDyn / ProstT5 / SaProt + RangeFinder GiST Carbohydrate/PFAS Calibration) |
Computes per-residue 20-state Foldseek 3Di probability distributions and normalized conformational Shannon entropy (RIGID_ORTHOSTERIC_CLEFT (CRYPTIC_BREATHING_POCKET (DISORDERED_NON_POCKET_LOOP (SaProt tokens and a 16-byte 64-hot (popcount == 64) 3Di POPCNT sketch, and calibrates RangeFinder 8-property GiST intervals for Fsp3 = 1.00 carbohydrates and Arom = 0 perfluoroalkyls. |
bio_encode_3di_flex_profile, bio_peek_flex3di_header, bio_3di_structural_tokens, bio_3di_sketch_similarity, bio_detect_cryptic_flex_pockets. |
1,232-Byte Zero-TOAST "PGFP" Container (19.48Γ Smaller) + >58M POPCNT Structural Comparisons/sec/core + 86,956 FlexProfiles/sec/core: Inspects 32-byte "PGFP" headers in u64::count_ones() instructions. |
π 23_flex3di_cryptic_pockets_and_popcnt_sketch.mdβ‘ benchmark_flex3di_cryptic_popcnt.pyπ 21_flex3di_cryptic_pockets_and_popcnt.ipynb
|
| 21 |
Layer 24 3D Metalloenzyme Coordination Polyhedra (CShM, BVS & Vacancy Cone) + 96-Byte Condensed Graph of Reaction (CGR) POPCNT & Mahalanobis OOD) Gate(Metal Mers / dEVA / EzHit / VenusRXN) |
Audits 3D metalloenzyme active sites ( |
\text{BVS} - Z_{\text{ox}} | \le 0.35$), and open catalytic vacancy cone ("PGMC", 128 B inline), and packs 256-bit Condensed Graph of Reaction (CGR) bond-change bit-vectors + 16-D ZCA Diagonal Mahalanobis $\chi^2{16}$ OOD confidence gates into a fixed 96-byte zero-TOAST "PGRX" container. |
bio_pack_cgr_ood_container, bio_peek_cgr_ood_header, bio_cgr_mahalanobis_ood_gate, bio_metalloenzyme_cshm_bvs_audit, bio_peek_metalloenzyme_header. |
| 22 |
Layer 25 Orthosterically-Conditioned Allosteric Contact-Graph Widest-Path Conductance ("PGAL") & Thread-Local Zero-Copy Header Cache(Eccleston & Furnham / Allofusion / FrustraMPNN / Ohm) |
Solves Modified Dijkstra widest-path (minimax bottleneck capacity pk1) to distal pockets (pk2..pk5 in the <= 192 B zero-TOAST "PGAL" container, and provides a 16-slot thread-local header memoization cache across all 5 binary containers ("PGPA", "PGFP", "PGMC", "PGRX", "PGAL"). |
bio_allosteric_orthosteric_coupling, bio_peek_allosteric_header, bio_allosteric_pathway_similarity, bio_peek_container_fast. |
96β192 Byte Zero-TOAST "PGAL" Container + |
π 25_allosteric_orthosteric_coupling_and_container_cache.mdβ‘ benchmark_allosteric_pgal_cache.pyπ 23_allosteric_orthosteric_coupling_and_pgal_cache.ipynb
|
When executing a multi-modal discovery query (such as jonatas/bio-pipelines (base/swarm_discovery.py)), pg_bio fuses all filtering layers inside a single PostgreSQL backend process:
-
Zero Data Movement (Compute Pushed to Shared-Buffer Pages):
-
Python Stack (
psycopg+BioPython+SciPy+RDKit): Must serialize sequences, 1280-D vectors, or 3,000-line PDB strings over a socket from PostgreSQL, allocate Pythonstr/list/numpy.ndarrayobjects, and garbage-collect them. -
pg_bioEngine: Reads PostgreSQL shared-buffer memory pages directly in Rust viapgrxpointers. Only the final winning rows ever cross the wire to the client.
-
Python Stack (
-
Query-Planner Short-Circuiting (HNSW Index
$\rightarrow$ B-Tree Anti-Join$\rightarrow$ DP Verification):- PostgreSQL uses the HNSW vector index (
<=>) to narrow 2,340,573 proteins down to 15 candidates in ~0.4 ms, applies theNOT EXISTSB-tree anti-join, and executessmith_waterman_scoreandinterface_complementarityon only those 5β15 survivors.
- PostgreSQL uses the HNSW vector index (
-
LLVM-Vectorized Native Rust Loops vs. Python Interpreter Overhead:
- Inner loops for
smith_waterman_score($O(M \cdot N)$ dynamic programming),compute_atomic_sasa(Fibonacci sphere integration), andpgbio_vf2_is_subgraph(recursive subgraph isomorphism) compile withrustc -C opt-level=3, auto-vectorizing into ARM64 NEON / x86 AVX2 SIMD instructions with zero GIL contention.
- Inner loops for
-
Domain-Specific Spatial & Graph Reductions:
-
3D Atomic Coords
$\rightarrow$ 64-bit Morton Integer (z_order_encode): Replaces 3D Euclidean scans with 1D B-tree index lookups (docs/03_spatial_indexing.md). -
Dense
$L \times L$ Contact Matrix$\rightarrow$ CSR Graph (create_sparse_map): Reduces$O(L^2)$ attention and H-bond matrices to$O(\text{nnz})$ linear arrays (docs/02_attention_traversal.md). -
All-vs-All SASA
$\rightarrow$ $5\text{ Γ }$ Voxel Hash Grid (compute_atomic_sasa): Drops surface-area and H-bond burial complexity from$O(N_{\text{atoms}}^2)$ to$O(N_{\text{atoms}})$ (docs/15_chaperone_protein_design_workflows.md).
-
3D Atomic Coords