Introduction
wavefront_local is a library implement the wavefront alignment in the local alignment scope. Current implementation like WFA2-lib only support semi-global alignment. wavefront_local fill the gap to the local alignment.
Scoring system
The difficulty of applying WFA to the local alignment is that the WFA scoring system does not award matches. Thus, the best possible score is zero. However, in the local alignment scope, this can be easily achieved by aligning nothing at all. Eizenga and Paten show that the WFA scoring system with mismatch penalty $x$, gap opening penalty $o$, and gap extension penalty $e$, can be related to the classical scoring system with match score $l_c$, mismatch penalty $x_c$, gap opening penalty $o_c$, and gap extension penalty $e_c$ by
\begin{aligned}
&x = 2l_c + 2x_c \\
&o = 2o_c \\
&e = 2e_c + l_c
\end{aligned}
By the identiy
2L + 2X + E = M + N
with $L$ the total matches, $X$ the total mismatches, $E$ the total gap size, $M$ and $N$ the size of text and qury, respectively, Eizenga and Paten prove that the classical score $s_c$ and the WFA score $s_w$ are related by
2s_c + s_w = l_c(M + N)
We extend their observation by penalize the unaligned region in the local scope. In detail, let $J$ be the total size of unaligned region. Then there is the identity
2L + 2X + E + J = M + N
for the local scope. We penalty each step in the unaligned region by $j$. Observe that if set the local-scope WFA scoring system by
\begin{aligned}
&x = 2l_c + 2x_c \\
&o = 2o_c \\
&e = 2e_c + l_c \\
&j = l_c
\end{aligned}
then we recover the relation between the global-scope WFA scoring system and the classical one as
2s_c + s_w = l_c(M + N)
Recurrence of wavefront components in the local alignment scope
The recurrence of wavefront components for the wavefront alignment in the local scope (lWFA) is
\begin{aligned}
&\mathcal{I}_{s,d} = \max(\mathcal{M}_{s-o-e,d-1} + 1, \mathcal{I}_{s-e,d-1} + 1) \\
&\mathcal{D}_{s,d} = \max(\mathcal{M}_{s-o-e,d+1} + 1, \mathcal{D}_{s-e,d+1} +1) \\
&\mathcal{X} = \max(f, \mathcal{M}_{s-x,d} + 2, \mathcal{I}_{s,d}, \mathcal{D}_{s,d}) \\
&\mathcal{M}_{s,d} = \mathcal{X}_{s,d} + 2\mu(m,n)
\end{aligned}
where $f = s / j$ if $0 = s\pmod j$, otherwise $f = -\infty$. Compared with the global WFA, lWFA computes $\mathcal{X}_{s,d}$ by including the possibility that $\mathcal{X}_{s,d}$ corresponds to the start cell of the aligned region. This is achieved by the term $f$. If $0 = s\pmod j$, then the unaligned region of size $f = s / j$ has the score exactly equal to $s$. Otherwise, just set $f = -\infty$.
It can be prove that this recurrence format keeps the $O(sN)$ time complexity and the $O(s^2)$ space complexity. Furthermore, the bidirectional technique also works for the WFA in the local scope, which improve the space complexity from $O(s^2)$ to $O(s)$ while keep the $O(sN)$ time complexity.
pybind11 python langauage binding
Install the pypi package.
$ pip install wavefront_local
There are four functions.
wavefront_local._core.cpplwfawavefront_local._core.cpplbiwfawavefront_local.pylwfawavefront_local.pylbiwfa
All functions have the same signature, see the example. To run the example,
$ examples/example.py
cpplwfaimplements the wavefront alignment in the local scope.cpplbiwfaimplements the bidirectional wavefront alignment in the local scope. It use the least time and space (even faster thancpplwfa).pylwfaandpylbiwfaare python prototypes. These have higher readability than the c++ library. One may learn how lWFA and lBiWFA work by reading these python prototypes.
c++ library
To use the c++ library, you need to clone the repository or download a release tarball.
$ git clone https://github.com/ljw20180420/wavefront_local.git
$ cd wavefront_local
Local wavefront alignment (lWFA)
See this example. To compile and run the example,
$ examples/lwfa.sh
Local bidirectional wavefront alignment (lBiWFA)
See this example. To compile and run the example,
$ examples/lbiwfa.sh
Citation
In preparation.
TODO
- 先完成作图,整理格式,攥写文章
- learn
- uv
- sckkit-build-core
- cmake
- pybind11
- vscode debug
- mv long proof to supplementary information
- add a diagram to illustrate the lwfa algorithm
- check plos computational biology
- skip calculation for $s<e,o+e,x$
- optimize out intialization of fs
- SeqAn3 introduces highly optimized, native low-bit alphabets like seqan3::dna4 (which uses only 2 bits per base to represent A, C, G, T) and seqan3::dna5
- SeqAn3 handles dynamic programming matrices by utilizing specialized allocation stripes and structures that recycle memory buffers.
- compact custom alphabets (bit vector)
- Skip useless jumping at diagonals which have been passed by previous low-score waves. This prevent redundant extension, thereby the time complexity no longer depends on x.
- Prove the correctness of skipping useless jumping as follows.
- The optimal score keep.
- The iteration get Fr (wavefront).
- The optimal score is achieved at Fr.
- The iteration skipping useless jumping achieves optimal score.
- Implement the technique in the paper: Improving the time and space complexity of the WFA algorithm and generalizing its scoring.
- find sota library for efficient implementaion
- bit vector for recording alignment
- efficient sparse matrix
- manual simd
- webassembly
Metadata
Release files for wavefront-local 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wavefront_local-0.1.5.tar.gz | 66.3 kB | With provenance | Details for wavefront_local-0.1.5.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| wavefront_local-0.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl | CPython 3.14 | CPython 3.14 free-threading | Linux musl 1.2+ x86-64 | Details for wavefront_local-0.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl |
| wavefront_local-0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.14 | CPython 3.14 free-threading | Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 | Details for wavefront_local-0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
| wavefront_local-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux musl 1.2+ x86-64 | Details for wavefront_local-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl |
| wavefront_local-0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details for wavefront_local-0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
Total release size: 2.6 MB
Release files / wavefront_local-0.1.5.tar.gz
| Download URL | wavefront_local-0.1.5.tar.gz |
|---|---|
| Size | 66.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fc98ed457ec89d1bc289c2b5159ef7650bcb9dd87957fc4f7a41fb22e0fa015
|
|
BLAKE2b-256 checksum How to use checksums |
a121d4fbc804af38c641607715b6348115c9a661994277a36cc77c51dfbf40f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / wavefront_local-0.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl
| Download URL | wavefront_local-0.1.5-cp314-cp314t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
f1d62b54011e288a4472e09cbeb65f243f45ec4708e8641ef48770f56c373cf8
|
|
BLAKE2b-256 checksum How to use checksums |
42d95a440d27aa7c38fb83205252523396d5f21e36534f3f428c901125c027ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / wavefront_local-0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | wavefront_local-0.1.5-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 113.3 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
5669aa2e91ce8603f33deb168fe68c044cbb2380a03be0251dbedd1c5319a9cf
|
|
BLAKE2b-256 checksum How to use checksums |
c4c4ccabdbea1d2a024a1f5d0cf149e32a8cf40f36d1d7b5f643a089f5473d62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / wavefront_local-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | wavefront_local-0.1.5-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
464c18fbfe20aacfdc6a3670f2585ae648c143bbe3cc85a7c6e2563c68e9a999
|
|
BLAKE2b-256 checksum How to use checksums |
cd0b42cb8f01cc071846c53627c1c4e53831c607fb357fd45341e3d572e061cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / wavefront_local-0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | wavefront_local-0.1.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 111.5 kB |
| Tags | CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3b69754233b51d945b9d5852157d13bcc7dbdc01011a1829e5781497429ac340
|
|
BLAKE2b-256 checksum How to use checksums |
ea3fda2f64525c4b0048145a6a4f41b6ad4a0cf25e87a872b7426a3b2c99eaa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for wavefront-local 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for wavefront_local-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.