Metadata-Version: 2.4
Name: fast_ctc_decoder
Version: 0.3.9
Summary: Fast CTC decoding library.
Home-Page: https://github.com/ankandrew/fast-ctc-decoder
Author: Vlado Boza <bozavlado@gmail.com>, Chris Seymour <chris.seymour@nanoporetech.com>, Jabari Holder <jholder@and.digital>, ankandrew <61120139+ankandrew@users.noreply.github.com>
Author-email: Vlado Boza <bozavlado@gmail.com>, Chris Seymour <chris.seymour@nanoporetech.com>, Jabari Holder <jholder@and.digital>, ankandrew <61120139+ankandrew@users.noreply.github.com>
License: MIT
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/ankandrew/fast-ctc-decoder
Project-URL: Source Code, https://github.com/ankandrew/fast-ctc-decoder

# fast-ctc-decoder

![test-fast-ctc-decoder](https://github.com/ankandrew/fast-ctc-decoder/workflows/test-fast-ctc-decoder/badge.svg) [![PyPI version](https://badge.fury.io/py/fast-ctc-decoder.svg)](https://badge.fury.io/py/fast-ctc-decoder)

Blitzing fast CTC decoding library.

> [!NOTE]  
> Note: compared to the original `fast-ctc-decode` project, this fork is renamed to `fast-ctc-decoder` and keeps only
> the Python/Rust extension build; the Node/WebAssembly build has been removed.

```
$ pip install fast-ctc-decoder
```

## Usage

```python
>>> from fast_ctc_decoder import beam_search, viterbi_search
>>>
>>> alphabet = "NACGT"
>>> posteriors = np.random.rand(100, len(alphabet)).astype(np.float32)
>>>
>>> seq, path = viterbi_search(posteriors, alphabet)
>>> seq
'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'
>>>
>>> seq, path = beam_search(posteriors, alphabet, beam_size=5, beam_cut_threshold=0.1)
>>> seq
'ACACTCGCAGCGCGATACGACTGATCGAGATATACTCAGTGTACACAGT'
```

## Benchmark

| Implementation       | Time (s) | URL                                                                             |
|----------------------|----------|---------------------------------------------------------------------------------|
| Viterbi (Rust)       | 0.0003   | [ankandrew/fast-ctc-decoder](https://github.com/ankandrew/fast-ctc-decoder.git) |
| Viterbi (Python)     | 0.0022   |                                                                                 |
| Beam Search (Rust)   | 0.0033   | [ankandrew/fast-ctc-decoder](https://github.com/ankandrew/fast-ctc-decoder.git) |
| Beam Search (C++)    | 0.1034   | [parlance/ctcdecode](https://github.com/parlance/ctcdecode)                     |
| Beam Search (Python) | 3.3337   | [githubharald/CTCDecoder](https://github.com/githubharald/CTCDecoder)           |


## Developer Quickstart

### Python

```
$ git clone https://github.com/ankandrew/fast-ctc-decoder.git
$ cd fast-ctc-decoder
$ pip install --user maturin
$ make test
```

Note: You'll need a recent [rust](https://www.rust-lang.org/tools/install) compiler on your path to build the project.

By default, a fast (and less accurate) version of exponentiation is used for the 2D search. This can
be disabled by passing `--cargo-extra-args="--no-default-features"` to maturin, which provides more
accurate calculations but makes the 2D search take about twice as long.

## Credits

The original 1D beam search implementation was developed by [@usamec](https://github.com/usamec) for [deepnano-blitz](https://github.com/fmfi-compbio/deepnano-blitz).

The 2D beam search is based on [@jordisr](https://github.com/jordisr) and [@ihh](https://github.com/ihh) work in their [pair consensus decoding](https://doi.org/10.1101/2020.02.25.956771) paper.

### Licence and Copyright
(c) 2019 Oxford Nanopore Technologies Ltd.

fast-ctc-decoder is distributed under the terms of the MIT License.  If a copy of the License
was not distributed with this file, You can obtain one at https://github.com/ankandrew/fast-ctc-decoder/

This project is a fork of the original
[nanoporetech/fast-ctc-decode](https://github.com/nanoporetech/fast-ctc-decode). This fork
renames the package and removes the original Node/WebAssembly build.

