Skip to content

Python bindings

Anuradha Wickramarachchi edited this page Mar 28, 2026 · 3 revisions

Python bindings (pykmertools)

Overview

kmertools exposes Python bindings through the module pykmertools. The public API is exported from kmertools/conda/src/lib.rs and includes:

  • OligoComputer
  • CgrComputer
  • KmerGenerator
  • MinimiserGenerator
  • utils (to_numeric, to_acgt)

These bindings are available when you install from:

  • pip install pykmertools
  • conda install -c bioconda kmertools

Quick start

import pykmertools as kt
from pykmertools import utils as ktutils

print(kt.__doc__)
print(ktutils.to_numeric("ACGTT"))  # (111, 27)
print(ktutils.to_acgt(111, 5))      # ACGTT

API guide

Notes

  • DNA alphabet handling is mostly A/C/G/T/U (case-insensitive).
  • CgrComputer is strict and raises ValueError on invalid bases.
  • KmerGenerator, MinimiserGenerator, and OligoComputer skip windows crossing ambiguous bases.
  • utils.to_numeric(kmer) currently enforces len(kmer) <= 32.

Clone this wiki locally