Skip to main content
Kaptive

The tool for in silico serotyping

PyPI - Python Version ruff ty Made with FastAPI

For full documentation, including install and usage instructions, click here.

Kaptive Web is hosted online at kaptive-web.erc.monash.edu. This repository hosts the open-source code used to run the site, allowing you to deploy Kaptive-Web locally or on your own infrastructure.

📖 Background & History

In bacterial genomics, determining the serotype (surface polysaccharide structures) is critical for tracking outbreaks, understanding virulence, and vaccine development. The core Kaptive engine was built to take genome assemblies and rapidly map them to known locus databases using a highly-optimized alignment and scoring algorithm.

Historically, running Kaptive required command-line expertise. Kaptive-Web was created to democratize access to this powerful tool, providing researchers of all computational skill levels an intuitive web portal to upload assemblies, run the serotyper, and interactively explore the results.

🏗️ v2 Design, Implementation & Layout (FastAPI)

Kaptive-Web v2 has been completely rewritten from the ground up to be faster, more robust, and easier to deploy.

The backend is built in modern Python (3.11+) using FastAPI. It leverages asynchronous I/O and direct integration with the Kaptive core API. To handle the massive, complex dataclasses and NumPy arrays generated by Kaptive's internal engine, the API utilizes a custom ORJSON response class, binding directly to C-hooks for blistering fast serialization.

Backend Architecture Diagram

graph TD
    Client[Web Browser / User] -->|Uploads Genome| API[FastAPI Application]
    API -->|Serves UI| Frontend[Static Assets]
    API -->|Async Session Management| SQLite[(SQLite Database)]
    
    API -->|GenomeAssembly| Core[Kaptive Core Engine]
    
    subgraph Kaptive Serotyping Pipeline
        Core --> Mappy[Mappy / Minimap2 Aligner]
        Core --> Scorer[Locus Scoring]
        Core --> Phenotype[Phenotype Logic Evaluation]
    end
    
    Phenotype -->|SerotypingResult| Serializer[ORJSON Response Serializer]
    Serializer -->|Blazing Fast Native JSON| API
    API -->|Results payload| Client

Frontend Implementation

The frontend is a lightweight, responsive interface bundled directly with the application. It consists of static HTML, CSS, and Vanilla JavaScript assets (located in src/kaptive_web/frontend/) that are served via FastAPI's StaticFiles integration. It handles file chunking, progress reporting, and rendering the rich JSON responses from the backend into human-readable tables, badges, and interactive components.


🛠️ Installation

You can install kaptive-web using standard Python package managers. We highly recommend using uv for lightning-fast dependency resolution.

Using uv (Recommended)

# Install globally or in a virtual environment
uv pip install kaptive-web

# Or, if you've cloned the repository and want an editable install:
uv sync

Using pip

pip install kaptive-web

🚀 Usage & Deployment

Kaptive-Web is designed to be completely flexible. Whether you are a solo researcher running it locally, or a sysadmin deploying it on an HPC or Cloud cluster, there is an execution method for you.

1. The Native CLI Hook

The easiest way to run the local development server is using the native CLI command installed by pyproject.toml. This starts the Uvicorn server on 127.0.0.1:8000.

kaptive-web

# Or if using uv to manage environments:
uv run kaptive-web

2. The justfile (Task Runner)

If you have just installed, the project comes with a justfile containing handy aliases for common tasks. Simply type just to see all commands!

  • just serve - Syncs dependencies and runs the development server.
  • just test - Runs the pytest suite.
  • just clean - Cleans up pycache and virtual environments.

3. Container Managers

For production deployments or HPC environments, containerization is fully supported.

Docker & Docker Compose

  • just docker-build (Builds the standalone kaptive-web:latest image)
  • just docker-serve (Spins up Kaptive-Web and a Caddy reverse proxy using Docker Compose in detached mode)
  • just docker-stop (Tears down the compose stack)

Singularity & Apptainer For HPC environments where Docker is not permitted, you can build Singularity or Apptainer images (.sif files).

  • just singularity-build (Builds via Singularity.def)
  • just apptainer-build (Builds via Apptainer.def)

Once built, you can run the container directly:

# Example Apptainer usage
apptainer run kaptive-web.sif

Release files for kaptive-web 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kaptive-web 2.0.1
File Size Uploaded
kaptive_web-2.0.1.tar.gz 185.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kaptive-web 2.0.1
File Interpreter ABI Platform
kaptive_web-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 364.5 kB

Release files / kaptive_web-2.0.1.tar.gz

Download URL kaptive_web-2.0.1.tar.gz
Size 185.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3e925da78ee3e45b033b68f105187d9da6a88fedd2fef6269ee3c43b5ec4ad55
BLAKE2b-256 checksum
How to use checksums
ce0786a6110edceb6007f0a8e20095de478367a75093084f8f8ac2c4056a2458
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kaptive_web-2.0.1-py3-none-any.whl

Download URL kaptive_web-2.0.1-py3-none-any.whl
Size 178.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cc1d1b050d90352b5508097267015432e1e996dadda085738137d66d11e108e
BLAKE2b-256 checksum
How to use checksums
5e583389c7179573d060f53a3ca0a0c093607be9e600a9dbda5fa5985f51998e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

2 release 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