🧬 SeroGen
De novo bacterial polysaccharide antigen locus discovery, twilight-zone CNN gene role classification, hybrid MCL orthogroup clustering, and graph-based pan-locus analysis.
Overview
SeroGen is the core genomic engine of the SeroVerse suite. Built from the ground up on zero-copy Structure-of-Arrays (SoA) containers (numpy) and SIMD-parallel JIT kernels (numba), SeroGen transforms raw bacterial or prophage genome assemblies into annotated polysaccharide synthesis loci, orthogroup pan-graphs, and de novo reference databases in tens of milliseconds — with zero external CLI dependencies.
Core Capabilities
- ⚡ Single-Pass 29-State Bacterial & Prophage ORF Calling (
OrfPredictor): Decodes a 4.66 Mb E. coli chromosome in~71 ms(>65 Mb/s) via a 29-state frameshift- and operon-overlap-aware (TGATG/ATGA) profile-HMM Viterbi decoder with sliding 4-kb local GC adaptation, Shine-Dalgarno RBS scoring, and single-pass viral/prophage gap rescue (include_phage=True). - 🧠 Polysaccharide-Specific 1D-CNN Role Classification (
GeneRoleClassifier): Beats remote homology detection (BLAST/MMseqs2) in the< 25%sequence identity twilight zone by combining multi-scale 1D convolutional motif filters (kernels=(3, 5, 9)) with a 20-D biophysical composition/hydropathy/charge head across 29 functionalGeneRoles (+ open-setUNKNOWN). - 🔬 Smart Hybrid Clustering & CNN-Rescued MCL (
Clusterer): CombinesFNV-1aexact deduplication,RandstrobeIndexstrobemer seeding,MMSEQS12reduced-alphabet $12^4$ CSR + ungapped BLOSUM62 diagonal prefiltering, SIMD-parallel Smith-Waterman-Gotoh (PairwiseAligner), role-gated CNN active-site motif rescue (conv_max), and sparse Markov Clustering (mode="mcl") or greedyCD-HIT(mode="cdhit"). - 🕸️ Zero-Copy Graph Data Structures & Solvers (
serogen.core.graph): Bit-packed 32-bitIntNodes (GeneNode,IntergenicEdge),GraphBatch(Loci) containers with.as_pan_graph()consensus compression, Weisfeiler-Lehman + HungarianGraphAligner, Chu-Liu/Edmonds + constrained $K$-bestmaximum_spanning_arborescence, and NumbaRelationalMPNN. - 🧩 De Novo Fragmented & MGE-Tolerant Locus Discovery (
LocusPredictor&LocusMatcher): SegmentsCPS,O_AG,WTA,LTA,EPS,LOS_CORE, andPGAloci de novo using All-Contiguous-Partitions Dynamic Programming (LocusSegmenter), bridges/healsIStransposase/integrase insertions (heal_mobile_elements=True), stitches fragmented loci split across draft contigs (stitch_contig_splits=True), and builds de novo searchable databases (LocusMatcher).
Installation
uv add serogen
# or with pip:
pip install serogen
Quickstart
from serogen.core.genome import GenomeAssembly
from serogen.loci.matcher import LocusMatcher
from serogen.loci.models import GeneNode, Loci
from serogen.loci.predictor import LocusPredictor
# 1. Load a genome assembly and discover polysaccharide loci de novo
assembly = GenomeAssembly.from_fasta("genome.fasta")
predictor = LocusPredictor(stitch_contig_splits=True, heal_mobile_elements=False)
loci = predictor.predict(assembly)
for locus in loci:
print(
f"{locus.archetype.name}: {locus.start}..{locus.end} "
f"({locus.num_genes} genes, completeness={locus.completeness:.2f})"
)
# 2. Build a de novo MCL-clustered locus database and consensus pan-locus graph
db_loci = Loci.from_list(reference_loci).canonicalize_strands()
matcher = LocusMatcher(db_loci, cluster_mode="mcl", min_identity=80.0, min_coverage=0.80)
pan_adj, pan_nodes, pan_counts = matcher.targets.as_pan_graph(node_mask=GeneNode.mask("ROLE_ID", "CLUSTER_ID"))
# 3. Match newly discovered loci and inspect structural variant bitflags
matches = matcher.match(loci)
best = matches[0]
print(f"Matched locus: {best.target_name} (score={best.score:.3f}, flags={best.match_type!r})")
Development
# Install all development, test, lint, typing, and docs groups
uv sync --all-groups
# Run linter and static type checker
uv run ruff check .
uv run ty check src/
# Run test suite
uv run pytest
# Build and serve documentation locally with Zensical
uv run zensical serve
License
Released under the GNU General Public License v3.0 (GPLv3).
Metadata
Release files for serogen 0.0.1
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 | |
|---|---|---|---|---|
| serogen-0.0.1.tar.gz | 18.4 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| serogen-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 MB
Release files / serogen-0.0.1.tar.gz
| Download URL | serogen-0.0.1.tar.gz |
|---|---|
| Size | 18.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25efe72b5b5938ad09c69a8b7dbeab4d4b004af5098781216f734e447c0f16ef
|
|
BLAKE2b-256 checksum How to use checksums |
77880ef567ac372dafbc0f92c99145100bebc6fffbfa7dda16fb4ee4802edc99
|
| 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 22, 2026.
Transparency logRelease files / serogen-0.0.1-py3-none-any.whl
| Download URL | serogen-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbfb17ad5f54322f2efac614d89c1cb48a5439b61aa5c7bf74bb9243ef19061c
|
|
BLAKE2b-256 checksum How to use checksums |
3f4518b1be761c03b5169dc538b30292d18f1c92ae56aa4837c56101872c2905
|
| 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 22, 2026.
Transparency logSecurity for serogen 0.0.1
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 serogen-0.0.1.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 22, 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.