Skip to main content

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.

pybind11 python langauage binding

Install the pypi package.

$ pip install wavefront_local

There are four functions.

  • wavefront_local._core.cpplwfa
  • wavefront_local._core.cpplbiwfa
  • wavefront_local.pylwfa
  • wavefront_local.pylbiwfa

All functions have the same signature, see the example. To run the example,

$ examples/example.py
  • cpplwfa implements the wavefront alignment in the local scope.
  • cpplbiwfa implements the bidirectional wavefront alignment in the local scope. It use the least time and space (even faster than cpplwfa).
  • pylwfa and pylbiwfa are 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

- [ ] 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wavefront_local-0.1.3.tar.gz (16.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wavefront_local-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

wavefront_local-0.1.3-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (98.5 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

wavefront_local-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

wavefront_local-0.1.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (96.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file wavefront_local-0.1.3.tar.gz.

File metadata

  • Download URL: wavefront_local-0.1.3.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wavefront_local-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4d49ffcf950fac670c57a668c5b1b2fcdd699d9f230fa1e2d062314ae88792cb
MD5 457ad96503f30c295d4b38581ec0cfd4
BLAKE2b-256 53f209f76e99bb7cca43658a8fc1a8094a8111e558d3a9f1e8e7b6c49ae73234

See more details on using hashes here.

Provenance

The following attestation bundles were made for wavefront_local-0.1.3.tar.gz:

Publisher: release.yml on ljw20180420/wavefront_local

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wavefront_local-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for wavefront_local-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3ee0c5b8209805779120506fee9d7342ed6d607c71f1c8bc39a75937596b815e
MD5 3886509d87669924c0b13a00aaeff500
BLAKE2b-256 a706991c3165591b10cc39a0703fd42b37c08c1a32f5a08e8c28a3d45b7cc775

See more details on using hashes here.

Provenance

The following attestation bundles were made for wavefront_local-0.1.3-cp314-cp314t-musllinux_1_2_x86_64.whl:

Publisher: release.yml on ljw20180420/wavefront_local

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wavefront_local-0.1.3-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wavefront_local-0.1.3-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b2ce2286031366da091c3bf8d5c354e7e79c4863f41ddb91d6976d546188934
MD5 43a2e3ea7da233d07a9a9e7697379bae
BLAKE2b-256 2a8d241bc3a094f7ad5872536b5a7f6478509162702c87c2b5335410b7473055

See more details on using hashes here.

Provenance

The following attestation bundles were made for wavefront_local-0.1.3-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ljw20180420/wavefront_local

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wavefront_local-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for wavefront_local-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a3da0d1fdaf1abe898cc7637a3071d51c711fa4e9700e76f9e9f99b9fd2a3c79
MD5 89b98e48c8648477cc70623cec4e6f27
BLAKE2b-256 f80023283756bf1b33fbf7f0d4e425cece77677d1cb9253297bcd15edd021053

See more details on using hashes here.

Provenance

The following attestation bundles were made for wavefront_local-0.1.3-cp314-cp314-musllinux_1_2_x86_64.whl:

Publisher: release.yml on ljw20180420/wavefront_local

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wavefront_local-0.1.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wavefront_local-0.1.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 818b3ffb6a4a7786e5a54e7c480afd304acefd98b69612b0e6d2363a557e0c85
MD5 d5ae4650366e1ead89d7e12664c8acfd
BLAKE2b-256 4b9ad0c24d83b566cf01bfa17dde4699f1a2060174c892135a649ad243d265ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for wavefront_local-0.1.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on ljw20180420/wavefront_local

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page