{"id":9717,"library":"edlib","title":"Edlib - Sequence Alignment","description":"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.","status":"active","version":"1.3.9.post1","language":"python","source_language":"en","source_url":"https://github.com/Martinsos/edlib","tags":["sequence alignment","edit distance","Levenshtein","bioinformatics","string matching"],"install":[{"cmd":"pip install edlib","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary `align` function is accessed directly from the `edlib` module, not as a top-level import.","wrong":"from edlib import align","symbol":"align","correct":"import edlib\nedlib.align(...)"}],"quickstart":{"code":"import edlib\n\n# Global alignment (Needleman-Wunsch-like)\nresult = edlib.align(\"apple\", \"aple\", mode=\"NW\", task=\"distance\")\nprint(f\"NW Distance: {result['editDistance']}\")\n\n# Semi-global alignment (ends don't cost)\nresult = edlib.align(\"apple\", \"pple\", mode=\"SHW\", task=\"distance\")\nprint(f\"SHW Distance: {result['editDistance']}\")\n\n# Global alignment with path (more computationally intensive)\nresult = edlib.align(\"apple\", \"apply\", mode=\"NW\", task=\"path\")\nprint(f\"NW Distance with path: {result['editDistance']}\")\nprint(f\"Alignment path: {result['alignment']}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to edlib >= 1.2.7 or ensure your input sequences don't trigger this specific edge case in older versions.","message":"Older 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.","severity":"gotcha","affected_versions":"<1.2.7"},{"fix":"Use `edlib.align(seq1, seq2, task='distance')` if you only need the numerical edit distance.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to edlib >= 1.2.5. If stuck on an older version, pre-validate inputs to ensure sequences are non-empty.","message":"Providing 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.","severity":"gotcha","affected_versions":"<1.2.5"},{"fix":"Carefully choose `k` based on expected edit distances. If a solution is expected but not found, try increasing `k` or removing it (for unlimited distance).","message":"Setting 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.","severity":"gotcha","affected_versions":"All versions, especially <1.1.2"}],"env_vars":null,"search_vec":"'1.3.9':52 'algorithm':22 'align':3,16,35,46,70 'bind':26 'bioinformat':74 'bug':59 'c/c':12 'current':49 'distanc':21,40,72 'driven':57 'edit':19,71 'edlib':1,4 'even':43 'fast':11 'fix':60 'full':45 'global':29,32 'improv':63 'levenshtein':20,73 'librari':13 'lightweight':7 'local':34 'locat':41 'match':76 'minor':62 'mode':36 'offici':24 'path':47 'post1':53 'python':25 'rather':64 'releas':55 'return':39 'schedul':68 'semi':31 'semi-glob':30 'sequenc':2,15,69 'strict':67 'string':75 'super':10 'super-fast':9 'support':28 'typic':56 'use':17 'various':18 'version':50","created_at":"2026-04-17T01:20:21.776146+00:00","updated_at":"2026-04-17T01:20:21.776146+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 2, in <module>\n  File \"edlib.pyx\", line 56, in edlib.align\nTypeError: align() takes at least 2 positional arguments (1 given)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.3.9.post1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Martinsos/edlib","docs":null,"changelog":null,"pypi":"https://pypi.org/project/edlib/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-08-01","install_tag":null}}