Install & Compatibility
Where this runs
tested against v1.3.9.post1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 22.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
18MB installed
● package 18MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
align
✓ import edlib
edlib.align(...)
✗ from edlib import align
The primary `align` function is accessed directly from the `edlib` module, not as a top-level import.
This quickstart demonstrates how to use `edlib.align()` for basic sequence alignment, showing different `mode` and `task` parameters to get either the edit distance or the full alignment path.
import edlib
# Global alignment (Needleman-Wunsch-like)
result = edlib.align("apple", "aple", mode="NW", task="distance")
print(f"NW Distance: {result['editDistance']}")
# Semi-global alignment (ends don't cost)
result = edlib.align("apple", "pple", mode="SHW", task="distance")
print(f"SHW Distance: {result['editDistance']}")
# Global alignment with path (more computationally intensive)
result = edlib.align("apple", "apply", mode="NW", task="path")
print(f"NW Distance with path: {result['editDistance']}")
print(f"Alignment path: {result['alignment']}")
Debug
Known issues
gotchaOlder versions (pre-1.2.7) could freeze or exhibit incorrect behavior when the input alphabet was exactly 256 unique characters. While fixed, be mindful of extremely large or unusual character sets in older installations.fixUpgrade to edlib >= 1.2.7 or ensure your input sequences don't trigger this specific edge case in older versions.
affects: <1.2.7
gotchaWhen only the edit distance is needed, explicitly set `task='distance'` for optimal performance. Using `task='locations'` or `task='path'` involves additional computation to traceback the alignment, which is slower.fixUse `edlib.align(seq1, seq2, task='distance')` if you only need the numerical edit distance.
affects: All versions
gotchaProviding empty strings as query or target sequences in versions prior to 1.2.5 could lead to incorrect results or crashes. Modern versions handle this correctly.fixUpgrade to edlib >= 1.2.5. If stuck on an older version, pre-validate inputs to ensure sequences are non-empty.
affects: <1.2.5
gotchaSetting the `k` parameter (maximum edit distance) too aggressively low might result in `no solution found` even if a solution exists with a slightly higher distance. This was particularly buggy in v1.1.1 but is still a design consideration.fixCarefully choose `k` based on expected edit distances. If a solution is expected but not found, try increasing `k` or removing it (for unlimited distance).
affects: All versions, especially <1.1.2
Upgrade
Version history
1.3.9.post1latest on PyPI · released Sep 4, 2024
Audit
Dependencies
No dependency data recorded yet.