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

Download files

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

Source Distribution

kaptive_web-2.0.1.tar.gz (185.7 kB view details)

Uploaded Source

Built Distribution

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

kaptive_web-2.0.1-py3-none-any.whl (178.7 kB view details)

Uploaded Python 3

File details

Details for the file kaptive_web-2.0.1.tar.gz.

File metadata

  • Download URL: kaptive_web-2.0.1.tar.gz
  • Upload date:
  • Size: 185.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for kaptive_web-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3e925da78ee3e45b033b68f105187d9da6a88fedd2fef6269ee3c43b5ec4ad55
MD5 650e6c03b6f268c168582699645d1faf
BLAKE2b-256 ce0786a6110edceb6007f0a8e20095de478367a75093084f8f8ac2c4056a2458

See more details on using hashes here.

File details

Details for the file kaptive_web-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: kaptive_web-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 178.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for kaptive_web-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5cc1d1b050d90352b5508097267015432e1e996dadda085738137d66d11e108e
MD5 6d694c3d19a1628b6a4d0194867e4c06
BLAKE2b-256 5e583389c7179573d060f53a3ca0a0c093607be9e600a9dbda5fa5985f51998e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page