Edlib - Sequence Alignment

1.3.9.post1 · active · verified Fri Apr 17

Edlib is a lightweight and super-fast C/C++ library for sequence alignment using various edit (Levenshtein) distance algorithms, with official Python bindings. It supports global, semi-global, and local alignment modes and can return distance, locations, or even the full alignment path. The current version is 1.3.9.post1, with releases typically driven by bug fixes and minor improvements rather than a strict schedule.

Common errors

Warnings

Install

Imports

Quickstart

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']}")

view raw JSON →