Skip to main content

QuickMers

PyPI Version License

Overview

QuickMers is a high-performance library for computing distances between k-mers (short DNA sequences), implemented in C with Python bindings. It provides fast functions for:

  • Hamming distance – number of mismatches between equal-length sequences.
  • Levenshtein (edit) distance – minimum number of insertions, deletions, or substitutions needed to transform one sequence into another.

The library leverages bitwise operations for Hamming distance and the Myers bit-parallel algorithm for edit distance. On systems with AVX2 instructions, computations are further accelerated.

Installation

Planned: Quickmers will be available on PyPI in the future.
Install using pip:

python -m pip install quickmers

or manually:

python setup.py install

Usage

import numpy as np
from quickmers import (
    hamming_distance_array,
    hamming_distance,
    levenshtein_distance,
    levenshtein_distance_array,
    levenshtein_distance_array_with_min_dist
)

1. Hamming Distance

Signature:

hamming_distance(sequence1: str, sequence2: str) -> int

Compute the Hamming distance between two sequences of equal length.

d = hamming_distance("ACGT", "TCGA")
print(d)  # Output: 2

2. Hamming Distance (array)

Signature

hamming_distance_array(query: str, targets: Union[List[str], np.ndarray]) -> np.ndarray

Compute Hamming distances between one query sequence and a list of target sequences.

query = "ACGT"
targets_list = ["ACGT", "TCGA", "CGTA"]
targets_array = np.array(targets_list, dtype=object)

distances1 = hamming_distance_array(query, targets_list)
distances2 = hamming_distance_array(query, targets_array)

print(distances1) # Output: array([0, 2, 4])
print(distances2) # Output: array([0, 2, 4])

3. Levenshtein Distance

Signature

levenshtein_distance(sequence1: str, sequence2: str) -> int

Compute the edit distance between two sequences.

d = levenshtein_distance("ACGT", "CGTA")
print(d)  # Output: 2

4. Levenshtein Distance (array)

Signature

levenshtein_distance_array(query: str, targets: Union[List[str], np.ndarray]) -> np.ndarray

Compute edit distances between a query sequence and a list of sequences.

query = "ACGT"
targets = ["ACGT", "TCGA", "CGTA"]
distances = levenshtein_distance_array(query, targets)
print(distances)  # Output: array([0, 2, 2])

5. Levenshtein Distance with Minimum Distance

Signature

levenshtein_distance_array_with_min_dist(query: str, targets: Union[List[str], np.ndarray], min_distance: int) -> Tuple[bool, List[Optional[int]]]

Compute the Levenshtein (edit) distance between a query k-mer and a list of target k-mers, with early exit if a minimum distance is violated.

This function is useful when you want to skip unnecessary calculations once a target is "too close" to the query, which can save significant computation time for long lists.

query = "ACGT"
targets = ["AGGG", "TCGA", "CGTA"]
early_exit, distances = levenshtein_distance_array_with_min_dist(query, targets, 1)
print(early_exit) # Output: False
print(distances)  # Output: array([2, 2, 2])

Implementation Details

  • Hamming distance: computed using bitwise operations on 64-bit integers for speed. The sequence length has to be 32 or lower.
  • Levenshtein distance: implemented with Myers bit-parallel algorithm for rapid edit distance computation. The sequence length has to be 64 or lower.
  • Array functions: can take Python lists or NumPy object arrays as input.
  • AVX2 acceleration: if your CPU supports AVX2, internal loops are vectorized for faster computation.
  • Memory management: all functions use efficient pre-allocated arrays to minimize Python overhead.

Performance

Benchmarking was performed on randomly generated k-mers of varying lengths. Values represent the number of string pairs distances calculated per second.

Benchmark Results

Function k=5 k=10 k=15 k=20 k=25 k=30
hamming_distance 9,505,940 9,192,009 8,866,906 8,555,942 8,249,809 7,946,207
hamming_distance_array 49,038,568 47,807,278 44,236,469 38,861,603 35,788,375 33,238,156
levenshtein_distance 7,499,375 6,407,775 5,797,060 5,131,730 4,688,698 4,267,584
levenshtein_distance_array 26,354,634 20,227,311 16,396,735 13,399,246 11,772,501 10,360,021

Results may vary depending on CPU architecture, compiler optimizations, and whether AVX2 instructions are available.

References

[1] Gene Myers. 1999. A fast bit-vector algorithm for approximate string matching based on dynamic programming. J. ACM 46, 3 (May 1999), 395-415. https://doi.org/10.1145/316542.316550

License

This software is licensed under LGPL-3.0-or-later.

Copyright 2025 Alexander Schliep

Download files

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

Source Distribution

quickmers-0.1.2.tar.gz (25.1 kB view details)

Uploaded Source

Built Distributions

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

quickmers-0.1.2-cp312-cp312-win_amd64.whl (30.1 kB view details)

Uploaded CPython 3.12Windows x86-64

quickmers-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (45.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

quickmers-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (29.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

quickmers-0.1.2-cp311-cp311-win_amd64.whl (30.1 kB view details)

Uploaded CPython 3.11Windows x86-64

quickmers-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (45.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

quickmers-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (29.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

quickmers-0.1.2-cp310-cp310-win_amd64.whl (30.1 kB view details)

Uploaded CPython 3.10Windows x86-64

quickmers-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (44.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

quickmers-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (29.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

quickmers-0.1.2-cp39-cp39-win_amd64.whl (30.1 kB view details)

Uploaded CPython 3.9Windows x86-64

quickmers-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (44.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

quickmers-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (29.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file quickmers-0.1.2.tar.gz.

File metadata

  • Download URL: quickmers-0.1.2.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quickmers-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5a8512cf19a5e05fd6466e295614f4f70e5a57433bd29fc009228dc659b81800
MD5 c85f696856340da5595a39bda5fb85ed
BLAKE2b-256 e5661cff215603048b14039700c136518f3723aa1233b57681a6acb616909934

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2.tar.gz:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: quickmers-0.1.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quickmers-0.1.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fda13b400c7604c87013143750cc512eb8fc702d4a28ee22c855b908dc7a8dd9
MD5 03a2cf17b2bd75fd90582b8e922e83b5
BLAKE2b-256 394844356205f397e7dbb04aa214e3cc22a70cf77fd6274f6332f24c5aa6870b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp312-cp312-win_amd64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d4967bb04a942caf3eb669f60eb4e335605cc611ef3ab3aae626e4f1819ebb57
MD5 6b0c2a920e1a851fe89a11364379fcf5
BLAKE2b-256 9ebf4a8831bdd262d9cef1af94a660b35936539b353ca9af6a7b442d5412e54b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79dc5e5175b929f62874b3606f163ae30b9f327b86d12ae83507ea13862d0989
MD5 26066f1e4db4d2bbe27abf876b1e32aa
BLAKE2b-256 3dd9ee6c04afbfa9b3e403c4dbaf6ea3813a485b893f67121301cc0e01ca48bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: quickmers-0.1.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quickmers-0.1.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b2dc7b837d996d7ca4cf44ca35d520b689abe2c748ecccce3f679020846df621
MD5 e03d508fe7452258bdcf66f353da3f02
BLAKE2b-256 0a33a89b056aba4c3694c36a00db127b611a70d08243fb5044598a107e37a666

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp311-cp311-win_amd64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 46ff2865429a977a0f4425f7f9891a46e4dc1b4b32841196c18cbabf7fc8986a
MD5 7c3d575e820d953fabcc41193f77a63b
BLAKE2b-256 3a6486d76f4397f24b7dcfae17821c999fe59bc5698fef94bc348e2094f59cc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d01afdb15dab60cfe660b89dbfda53a677cd0f2d5bbb27b18e1b1826f5904be7
MD5 5ce64bd1c7a0f0f4220211323410125b
BLAKE2b-256 bf425f16df0fcb59b0ec2f66454a61b2eb9beea02f39a807e41bffd91c037f8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: quickmers-0.1.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quickmers-0.1.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 28749c4507bc218ddc1bebb0e69d8fd3651b41073419ea65d9b72dd9ef412d6b
MD5 77fdc19e98d9cda179d2a560708d6c9a
BLAKE2b-256 148acc1c81ad8e40db283f732866161e0e6348e92078145427c74b6ff789dafa

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp310-cp310-win_amd64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b32d51ecb61b6eb7e99c72d386d2ea1a8461e8adc28f45bc43be5d859cee0a5
MD5 d45e597f706f425fe7f4a357264cf11e
BLAKE2b-256 0ff938ddeff9fcc4cdd873d5f2ce1ab720659d1fa937031c26af8dbcf7d3a52a

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ac84aa4889d45230a62bfc44928e3c915822fa55e8170504c524b879a480f142
MD5 0f7ad4873ca0434db76a4c75bbd077f4
BLAKE2b-256 51e682e34d953bfd3c8b1238e9f95b74b81df975ab987488578ea35ee9df24f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: quickmers-0.1.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for quickmers-0.1.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0ae1cafc4c349e90bd7a273247d2940d9f6c86d80423074ef6ea4f032023acac
MD5 cb918ed1f13f0b4682a7b70b1f4e649b
BLAKE2b-256 2814db8077848e5b8149d749925ae5bf19cae9387dc1a5b981f87f1545aa7e2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp39-cp39-win_amd64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de2115a5c84e492323b84a0644f0b622dc665ed0485ea02729c95a6cb68d6b93
MD5 1b9b00d68b02e6618755640165094f3a
BLAKE2b-256 8da83c63d5479a13aa2a3dcbae74e191b3e1e43f5cbc634a6171b726bad72649

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quickmers-0.1.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for quickmers-0.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 940d594179edd05b00a438b1a75a5f05b7ab032181bc178c9df9f5184a0608d5
MD5 f19c83c49f7c151980f376b8a8d84b4e
BLAKE2b-256 8efc1e9b73b59b0a5ccfb1064b95b3db18c89f3d493adae174cdcf16a8c1a5af

See more details on using hashes here.

Provenance

The following attestation bundles were made for quickmers-0.1.2-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on Schlieplab/quickmers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

13 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