Wavefront alignment for the local alignment scope.
Project description
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 alignemnt 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.
Usage
c++ library
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
pybind11 python langauage binding
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.
Pypi package
$ pip install wavefront_local
Citation
In preparation.
TODO
- [ ] 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
- [ ] python binding
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wavefront_local-0.1.2.tar.gz.
File metadata
- Download URL: wavefront_local-0.1.2.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5879261c57f622da73c2366c288b1a470b2eabd17526e82b6ee7fda0def0d634
|
|
| MD5 |
3c13510bc58e643504466d69ab8b1981
|
|
| BLAKE2b-256 |
b81ee9e89f81510ce6d3238c22157c2377cf748ba8e8b64c7abe4f0fafd53985
|
Provenance
The following attestation bundles were made for wavefront_local-0.1.2.tar.gz:
Publisher:
release.yml on ljw20180420/wavefront_local
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wavefront_local-0.1.2.tar.gz -
Subject digest:
5879261c57f622da73c2366c288b1a470b2eabd17526e82b6ee7fda0def0d634 - Sigstore transparency entry: 2167531319
- Sigstore integration time:
-
Permalink:
ljw20180420/wavefront_local@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ljw20180420
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wavefront_local-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: wavefront_local-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6db5d7b2202e5ffd24a337c2f23fe77317a7f73f98a367ed6293e0abd1f4b7e
|
|
| MD5 |
4041c7f218e4391fdb26053c5182ec71
|
|
| BLAKE2b-256 |
9c95a0d9806cc661d1cc4f0750e52657b4ae85070f884e158424d6ea4ebcd82b
|
Provenance
The following attestation bundles were made for wavefront_local-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on ljw20180420/wavefront_local
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wavefront_local-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl -
Subject digest:
c6db5d7b2202e5ffd24a337c2f23fe77317a7f73f98a367ed6293e0abd1f4b7e - Sigstore transparency entry: 2167531432
- Sigstore integration time:
-
Permalink:
ljw20180420/wavefront_local@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ljw20180420
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wavefront_local-0.1.2-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: wavefront_local-0.1.2-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 98.5 kB
- Tags: CPython 3.14t, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2fd100e11de2eb08d92a2eec59d7f8d95e736bb31fbfa3378ac3843e3a77846
|
|
| MD5 |
269f3664a7b29bab96711be215a6a42c
|
|
| BLAKE2b-256 |
9388797ce7d6a2c7824f3dedcd72f2fdedd8987fbbea0b33a56a73fb852e6cee
|
Provenance
The following attestation bundles were made for wavefront_local-0.1.2-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on ljw20180420/wavefront_local
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wavefront_local-0.1.2-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
e2fd100e11de2eb08d92a2eec59d7f8d95e736bb31fbfa3378ac3843e3a77846 - Sigstore transparency entry: 2167531546
- Sigstore integration time:
-
Permalink:
ljw20180420/wavefront_local@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ljw20180420
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wavefront_local-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: wavefront_local-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8387d163282fa5132139163106d0dcba3162f261cfea4ab8a485cfbe120aa6ed
|
|
| MD5 |
c1891a6407edd9535547461b06110c6b
|
|
| BLAKE2b-256 |
bd61b171c0ed2360488243362b980cf47f6f8c052c935703cea490898e2e89a0
|
Provenance
The following attestation bundles were made for wavefront_local-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on ljw20180420/wavefront_local
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wavefront_local-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl -
Subject digest:
8387d163282fa5132139163106d0dcba3162f261cfea4ab8a485cfbe120aa6ed - Sigstore transparency entry: 2167531492
- Sigstore integration time:
-
Permalink:
ljw20180420/wavefront_local@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ljw20180420
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wavefront_local-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: wavefront_local-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 96.6 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba559d8b4fa630f0fe4532a4d702e2e31849e8c4a39ff6f9c49fd20dd3571231
|
|
| MD5 |
264193d3b7e4cac788743262537435e4
|
|
| BLAKE2b-256 |
75cc7c7a29e43d2188ebc7adde19d0fefe14e5e91a8084f486bce5029bf1dc3d
|
Provenance
The following attestation bundles were made for wavefront_local-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on ljw20180420/wavefront_local
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wavefront_local-0.1.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
ba559d8b4fa630f0fe4532a4d702e2e31849e8c4a39ff6f9c49fd20dd3571231 - Sigstore transparency entry: 2167531362
- Sigstore integration time:
-
Permalink:
ljw20180420/wavefront_local@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ljw20180420
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7aade89f8c04e5e4ca76e63018c001784c7415d6 -
Trigger Event:
release
-
Statement type: