bioRxiv · 10.64898/2025.12.22.695990
NW-flex: flexible-block sequence alignment for short tandem repeats
Abstract
Aligning sequencing reads to short tandem repeats (STRs) is challenging: the number of repeat copies in a read often differs from the reference, and small changes inside and around the repeat can lead to many competing alignments. We introduce NW-flex, a simple extension of classical sequence alignment that addresses this problem. NW-flex takes a reference with a designated internal block and, while allowing that block to contract to any shorter substring, identifies the best-scoring alignment. Apart from this substring choice, the alignment obeys the usual substitution scoring and gap constraints. For STRs, we design the flexible block with enough repeat copies to accommodate any expected repeat count. The alignment then contracts the reference to match the read while the unique flanks remain fully constrained. NW-flex requires a small modification to the Needleman-Wunsch/Gotoh algorithm, adds minimal computational overhead, and preserves optimality with respect to classical scoring. We provide open-source Python and Cython implementations, a set of worked examples, and notebooks that reproduce the figures and validate correctness against baseline alignments.
Explore related subjects
Keep this discovery
Explore connections, maps & timelines
Yu, Z., Levy, D.. 2025-12-24. NW-flex: flexible-block sequence alignment for short tandem repeats. https://doi.org/10.64898/2025.12.22.695990
Cite the original work for its findings. Save a collection to share your selection of sources.