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.0.tar.gz (183.4 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.0-py3-none-any.whl (178.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kaptive_web-2.0.0.tar.gz
  • Upload date:
  • Size: 183.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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.0.tar.gz
Algorithm Hash digest
SHA256 2926179ce0772d29ea407c9b4a0d4f3ea6cf3c6c59eb84aeafbd504c9cac40b1
MD5 f1d6a6b4ce791d6434f28b5480ab3664
BLAKE2b-256 aa274185f22f91c8797bd2adb6f0532976da5b6e149f871fa25f64ce8b9c4483

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kaptive_web-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 178.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e89df52a4c585cfb03e1aeaa2df28225d7c106e3d6bdd8be66824bed8deb6167
MD5 8950bf96a8bc1b175a55538883eb62c6
BLAKE2b-256 d0f2e14dedbff1ef8dd184ead466971b0d26c22b1f1181d12e7d32e16240e3b6

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